VTK/Tutorials/CMakeListsFile: Difference between revisions
Daviddoria (talk | contribs) No edit summary |
Hal Canary (talk | contribs) (vtkHybrid --> ${VTK_LIBRARIES}) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
To use | To use CMake to generate your project, this is what the CMakeLists.txt file should look like: | ||
<source lang= | == CMakeLists.txt == | ||
<source lang=cmake> | |||
cmake_minimum_required(VERSION 2.6) | 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}) | |||
</source> | |||
==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". | |||
<source lang=cmake> | |||
cmake_minimum_required(VERSION 2.6) | |||
</source> | |||
Name the project. | |||
<source lang=cmake>project(Test)</source> | |||
Tell cmake that this project needs to use VTK. | |||
<source lang=cmake> | |||
set(VTK_DIR "/PATH/TO/VTK/BUILD/DIRECTORY") | |||
find_package(VTK REQUIRED) | |||
include(${VTK_USE_FILE}) | |||
</source> | |||
Tell cmake we want to compile Test.cpp into a binary called Test. | |||
<source lang=cmake> | |||
add_executable(Test Test.cxx) | |||
</source> | |||
Tell cmake we need to link Test against the VTK libraries. | |||
<source lang=cmake> | |||
target_link_libraries(Test ${VTK_LIBRARIES}) | |||
</source> | </source> |
Latest revision as of 17:53, 14 August 2012
To use CMake to generate your project, this is what the CMakeLists.txt file should look like:
CMakeLists.txt
<source lang=cmake> 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})
</source>
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". <source lang=cmake> cmake_minimum_required(VERSION 2.6) </source>
Name the project. <source lang=cmake>project(Test)</source>
Tell cmake that this project needs to use VTK. <source lang=cmake> set(VTK_DIR "/PATH/TO/VTK/BUILD/DIRECTORY") find_package(VTK REQUIRED) include(${VTK_USE_FILE}) </source>
Tell cmake we want to compile Test.cpp into a binary called Test. <source lang=cmake> add_executable(Test Test.cxx) </source>
Tell cmake we need to link Test against the VTK libraries. <source lang=cmake> target_link_libraries(Test ${VTK_LIBRARIES}) </source>