[CMake] Include VTK Project and Link Targets
Nicholas Draper
nickd2225 at gmail.com
Mon Oct 28 02:01:05 EDT 2019
Hello,
I am having some difficulty trying to add an external project, in this
particular case the VTK (Visualization Toolkit) project, to my own project
using the *ExternalProject_Add *command. My goal is to download the project
from the git repository to a *third_party_folder* in my repo and then link
my executables against its targets.
My directory structure is as follows
- CMakeLists.txt
- src_folder
- CMakeLists.txt
- main.cpp
- third_party_folder
- CMakeLists.txt
- cmake_folder
- External-VTK.cmake
## CMakeLists.txt
cmake_minimum_version(VERSION 3.1)
project(MyProj)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_folder")
include(ExternalProject)
add_subdirectory(src_folder)
add_subdirectory(third_party_folder)
## third_party_folder/CMakeLists.txt
include(External-VTK)
## cmake_folder/External-VTK.cmake
ExternalProject_Add(VTK
GIT_REPOSITORY https://github.com/Kitware/VTK.git
GIT_TAG master
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/VTK"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/VTK")
## src_folder/CMakeLists.txt
add_executable(CylinderExample main.cpp)
target_link_libraries(CylinderExample PRIVATE ${VTK_LIBRARIES})
vtk_module_autoinit(
TARGETS CylinderExample
MODULES ${VTK_LIBRARIES})
This still does not seem to be doing what I want, so I was wondering if
anyone could offer some advice. I am unsure of how to get the outputted
targets from an external project. Thank you.
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191027/ddf1a990/attachment.html>
More information about the CMake
mailing list