[CMake] CMakeLists.txt in different place than source

J Decker d3ck0r at gmail.com
Thu Jun 14 01:52:56 EDT 2018


On Wed, Jun 13, 2018 at 9:46 PM Andrew White <andrew.white at audinate.com>
wrote:

> J Decker wrote:
>
> You can define a variable to define the base of the sources....
>
> set( SOURCE_ROOT /some/path )
>
>
>
> could be set relative to the current cmake path per cmake that uses those
>
> souces... and then just prefix it
>
>
>
> add_library(my_lib
>
>         ${SOURCE_ROOT}/src/a.c
>
>         ${SOURCE_ROOT}/include/a.h
>
> )
>
>
>
> Thanks, but that’s approximately exactly what I’m trying to avoid doing.
> I cheat a little, in that I have a macro that will prepend a prefix to
> every element of a list.  My motivation is avoiding situations where I add
> the prefix to the files but forget to add the prefix when I call
> target_include_directories or suchlike.
>
>
>
> I’m not sure anything trickier is workable in the CMake model, however.
> For example, hacking CMAKE_CURRENT_SOURCE_DIR might make sense for file
> paths, but if I then call add_subdirectory should it be rooted at the
> CMakeList directory or the source root directory.
>
>
>
CMAKE_CURRENT_LIST_DIR
https://stackoverflow.com/questions/15662497/difference-between-cmake-current-source-dir-and-cmake-current-list-dir

yes that's an option also.
It will be pretty clear there's an error if something is omitted later;
and/or referenced from a different place.
 and then it's not just a matter of


> --
>
> Andrew
>
>
> --
>
> 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/20180613/9c389538/attachment.html>


More information about the CMake mailing list