On Tue, Jun 12, 2018 at 7:22 PM Andrew White <andrew.wh...@audinate.com>
wrote:

> I have a situation where I want my CMakeLists.txt in a different place
> than my source.
>
> e.g.:
>
> /some/path/project/CMakeLists.txt
> /other/path/source/src/a.c
> /other/path/source/include/a.h
>
> Is there an easy way to say "process this CMakeLists.txt as if it were in
> /other/path/source" (at least as far as file paths are concerned)?
>
> e.g.:
>
> add_library(my_lib
>         src/a.c
>         include/a.h
> )
>
> target_include_directories(my_lib PUBLIC include)
>
> I know I can add a full path prefix to every file, but there are a lot of
> them.  I'm hoping for a shortcut.
>

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
)



>
> --
> 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
>
-- 

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

Reply via email to