[CMake] CMakeLists.txt in different place than source

Andrew White andrew.white at audinate.com
Tue Jun 12 22:22:27 EDT 2018


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.

--
Andrew




More information about the CMake mailing list