[CMake] multiple cmake files in one directory

Tyler Roscoe tyler at cryptio.net
Thu Sep 24 09:50:25 EDT 2009


On Thu, Sep 24, 2009 at 09:32:54AM +0200, th.tom at gmx.de wrote:
> Maybe I did not get the point of CMAKE_SOURCE_DIR :-/
> What I do is creating a directory "packages\project1" here I place the
> starting CMakeLists.txt file and another subdirectory "build". 
> 
> The CMakeLists.txt consists of 
> 
> ADD_SUBDIRECTORY(../../myfirstdir)
> ADD_SUBDIRECTORY(../../myseconddir)
> ADD_SUBDIRECTORY(../../mythirddir)
> 
> Within the "build" directory I start "cmake ..".
> 
> What I think is happening is that the CMAKE_SOURCE_DIR is set to
> [whatever]\package\project1
>  
> This is not what I want, as the source root (where all
> CMakeLists.txt-files written up until now depend on) is [whatever].
> 
> So the solution would be to change _all_ ${CMAKE_SOURCE_DIR} to
> ${CMAKE_SOURCE_DIR}\..\.. or not to use ${CMAKE_SOURCE_DIR} and to
> navigate by relative paths.

Maybe you explained it upthread but why not put your top-level
CMakeLists.txt in [whatever]?

You could also set a myProjectRoot and point it to
"${CMAKE_SOURCE_DIR}/../..". If you don't like the .. in your path, use
get_filename_component to normalize that path.

tyler


More information about the CMake mailing list