[CMake] How to get current directory of the included files

Brad King brad.king at kitware.com
Tue Sep 26 10:52:45 EDT 2006


Eduard Bloch wrote:
> Hello,
> 
> I need to add a certain variable and a set of strings in a set of
> applications, beeing in different paths. This is required because a
> static library is compiled with different settings, therefore the set of
> additional libraries varies.
> 
> To avoid code duplication and adding the test multiple times, I stored
> the code in a .cmake file included into various CMakeLists.txt. The code
> works almost as expected, however: I wish to run a test program to
> detect a system feature. I need to refer to this test code file in the
> included file with the full path (because of Out-of-tree build mode).
> But I cannot get this path (directory of the included file) inside of
> the included .cmake file itself. ${CMAKE_CURRENT_SOURCE_DIR}/ gives me
> the path of the including CMakeLists.txt and not what I need.

CMAKE_CURRENT_LIST_FILE

-Brad



More information about the CMake mailing list