VTK/Tutorials/CMakeListsFile
From KitwarePublic
Jump to navigationJump to search
To use CMake to generate your project, this is what the CMakeLists.txt file should look like:
CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(Test)
set(VTK_DIR "PATH/TO/VTK/BUILD/DIRECTORY")
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_executable(Test Test.cxx)
target_link_libraries(Test ${VTK_LIBRARIES})
Explanation
Here is a line by line break down of what is going on:
This will prevent annoying cmake warnings about "you must specifiy a minimum required version".
cmake_minimum_required(VERSION 2.6)
Name the project.
project(Test)
Tell cmake that this project needs to use VTK.
set(VTK_DIR "/PATH/TO/VTK/BUILD/DIRECTORY")
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
Tell cmake we want to compile Test.cpp into a binary called Test.
add_executable(Test Test.cxx)
Tell cmake we need to link Test against the VTK libraries.
target_link_libraries(Test ${VTK_LIBRARIES})