[CMake] CMakeLists.txt in different place than source
Andrew White
andrew.white at audinate.com
Thu Jun 14 00:46:38 EDT 2018
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.
--
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180614/0e8e1ecb/attachment.html>
More information about the CMake
mailing list