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
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to