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

hex hex7c3 at gmail.com
Tue Jul 9 12:38:07 EDT 2019


thank you J Decker for your reply.


Your suggestion does work but I want to preserve standalone use of the 
project, meaning that I want a reference to CMake source root directory.

Assuming there is only 1 hierarchy I could add an option:


if ( SUPERBUILD )

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

/else ()/

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

endif ()


I think the better solution now is to make it relative to build 
directory and force out of source builds.


On 09/07/2019 14:26, J Decker wrote:
>
> /message("${CMAKE_SOURCE_DIR}/.. = /home/user/super/ext1/..")/  which 
> == /home/user/super
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190709/63ec067b/attachment.html>


More information about the CMake mailing list