cmake SupperBuild how to include source file for local project

Hi,
I use the ExternalPorject_Add to added external dependencies to my local projects. Specifically, I use EExternalPrject_Add to add my local projects such that my projects’ external dependencies can be build properly. Here is the example of my local project:

ExternalProject_Add(my_example
DEPENDS
VTK_external
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/my_example
CMAKE_ARGS
-DVTK_DIR = ${VTK_DIR}
CMAKE_CACHE_ARGS
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS
1
INSTALL_COMMAND
“”
)

Here my project depends on VTK external project. In the generated solution files for visual studio I only see the CMakeLists.txt but not the actual C++ source files. How can I include the source files so that I can debug my project in Visual Studio?

Thanks,
BC

That project lives inside of a separate CMake generation step. Something like my_example-prefix/src/build or the like in the build tree.

Thanks for the reply, but I am quite new to cmake. I don’t quite understand what you mean. Could you give a simple example?

ExternalProject sets up a source/build directory in the top-level build directory (though providing the source directory like you do will skip the source bit). Looking for the CMakeCache.txt file related to my_example in the build tree will help you find the project that needs loaded in Visual Studio.

1 Like