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

J Decker d3ck0r at gmail.com
Tue Jul 9 13:25:02 EDT 2019


On Tue, Jul 9, 2019 at 9:38 AM hex <hex7c3 at gmail.com> wrote:

> 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.
>
>
> +1 I think; You said it was generated?  It should be in the build
directory anyway :)
And out of source always.  (makes it easier to source version control)


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


More information about the CMake mailing list