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

J Decker d3ck0r at gmail.com
Tue Jul 9 09:26:37 EDT 2019


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

> 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")*
>

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

>
>
>
> The desired outcome would be to have the path /home/user/super in both
> messages.
> How can I do this?
>
>
> thank you
> --
>
> 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/51a6f4ad/attachment.html>


More information about the CMake mailing list