[CMake] question about combining cmake builds

Michael Wild themiwi at gmail.com
Fri Nov 4 01:19:20 EDT 2011


On 11/03/2011 07:23 PM, Bill Hoffman wrote:
> On 11/3/2011 1:19 PM, Paul Whelan wrote:
>> Hi guys,
>>
>> I have a possibly naive question about cmake. I've got three
>> applications that build with cmake. Normally they build and run
>> independently. However, for a particular release I have to combine them
>> in a source distribution. I wanted to create a cmake script in a parent
>> directory containing all three source trees and give the end-user one
>> simple cmake command to run. Sounds simple enough.
>>
>> The problem I run into in doing that is that with the CMakeList.txt
>> files of each source tree, there are some directory references relative
>> to ${CMAKE_BINARY_DIR} and ${CMAKE_SOURCE_DIR}. So, when cmake is run
>> from a higher level directory, these directory macros are one level up
>> from where they normally are and it throws off the build.
>>
>> The question I have is "Is there a way to use cmake in a parent
>> directory to recursively invoke cmake on the CMakeList.txt files in each
>> of these source trees such that the source and binary root directories
>> are set to what they are normally expected to be?
>>
> 
> You should look at the ExternalProject module.
> 
> -Bill

Alternatively, if that is your only problem, modify the individual
projects to use the PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR variables
instead.

Michael



More information about the CMake mailing list