[CMake] how to set current source directory relative to external project

hex hex7c3 at gmail.com
Tue Jul 9 08:35:19 EDT 2019


hello CMake community,


I am experimenting with external projects. I have some files in an 
external project which are generated in `${CMAKE_SOURCE_DIR}`.


When I add the external project, however, it is using 
`${CMAKE_SOURCE_DIR}` of the external project.


I need `${CMAKE_SOURCE_DIR}` to be relative to the "super build", 
instead of the external project path.


Example:

/message("${CMAKE_SOURCE_DIR} = /home/user/super")//
//
//ExternalProject_Add(ext1//
//    # directory options//
//    SOURCE_DIR      "${CMAKE_SOURCE_DIR}/ext1"//
//)/


${CMAKE_SOURCE_DIR}/ext1/CMakeLists.txt:


/message("${CMAKE_SOURCE_DIR} = /home/user/super/ext1")/


The desired outcome would be to have the path /home/user/super in both 
messages.
How can I do this?


thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190709/64dd4d06/attachment.html>


More information about the CMake mailing list