Hello!
So this is my first time trying to achieve something like this. What I want to is basically to use some functionality provided in this example in my own project;
https://lorensen.github.io/VTKExamples/site/Cxx/IO/WriteVTP/
I have managed to build VTK and know that I can run the example without any errors, so every header is functional etc.
What I think I have to do is to use cmake in something like this:
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(MyProject VERSION 1.0.0)
add_library(
AllTheCode Bi4File.cpp Bi4File.h bi4read.c bi4read.h Block.cpp Block.h BlockHelper.h drawGeom.h Geometry.h horspool.c horspool.h Particle.cpp Particle.h Statistics.h SubBlock.cpp SubBlock.h Tuple.h Vector.h
)
#a.out is executable
add_executable(a.out main.cpp)
set(LIBS AllTheCode)
target_link_libraries(a.out PRIVATE ${LIBS})
So this code is all the code except the vtk example and I am very unsure of how to include it, since it needs its own CMakeLists.txt to even compile. I have not been succesful in doing this but I am doing something like:
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(WriteVTP)
SET(VTK_DIR “/home/aras/vtk-build/” CACHE PATH “VTK directory override” FORCE)
find_package(VTK COMPONENTS
CommonCore
CommonDataModel
IOXML)
if (NOT VTK_FOUND)
message(“Skipping WriteVTP: ${VTK_NOT_FOUND_MESSAGE}”)
return ()
endif()
message (STATUS “VTK_VERSION: ${VTK_VERSION}”)
if (VTK_VERSION VERSION_LESS “8.90.0”)
old system
include(${VTK_USE_FILE})
add_executable(WriteVTP MACOSX_BUNDLE WriteVTP.cxx )
target_link_libraries(WriteVTP PRIVATE ${VTK_LIBRARIES})
else ()
include all components
add_executable(WriteVTP MACOSX_BUNDLE WriteVTP.cxx )
target_link_libraries(WriteVTP PRIVATE ${VTK_LIBRARIES})
vtk_module_autoinit is needed
vtk_module_autoinit(
TARGETS WriteVTP MODULES ${VTK_LIBRARIES} )
endif ()
And when ever I try to include it, it ends up not working. Could anyone help me to get this up and running?
To sum up again; I want to use this specific vtk functionality in my own code - unsure how to go about that and cannot make CMake accept it, so I can use the function in my own code. If I just add it as a “header file” it can’t find the vtk headers correctly.
Kind regards