[Cmake] Combining Separate CMake Projects

Brad King brad.king at kitware.com
Mon Jun 28 11:41:58 EDT 2004


Chris Scharver wrote:
> On Jun 28, 2004, at 9:06 AM, Brad King wrote:
> 
>> Chris Scharver wrote:
>>
>>> Is there something that I could use other than SUBDIRS? The libraries 
>>> can stand alone, but I want to compile such that building the 
>>> application ensures that the libraries are built within the build 
>>> directory. Is there something akin to SUBDIRS that will allow me to 
>>> import another CMake project? I noticed that I cannot use an absolute 
>>> path in the SUBDIRS command, but that seems exactly what I want to be 
>>> able to do. FIND_PACKAGE doesn't seem to be quite what I'm looking 
>>> for--I want everything built from one CMake run without having to go 
>>> through several CMake-configure-build cycles for each directory. Any 
>>> help would be much appreciated.
>>
>>
>> As far as I know there is currently no way to do this short of setting 
>> up the build system to copy the library source directories into a 
>> subdirectory of the application.  What you want to do is easily 
>> accomplished by creating a single CMakeLists.txt file in the directory 
>> above all three source trees.  Doing this will allow the whole thing 
>> to be built as one application, but you will still be able to point 
>> cmake to one of the subdirectories to build it individually.
> 
> 
> I did try this approach, and it worked perfectly. There is one extra 
> directory layer, so maybe I should finally add a CUSTOM_COMMAND to 
> install the resulting executable into the original source directory. 
> That way, the end user doesn't have to care about how many directory 
> layers are in place during the build as long as the executable is in the 
> correct location relative to the data files. CUSTOM_COMMAND is still the 
> only way to perform a target install for Visual Studio workspaces, correct?

There are a couple of choices.  You can set LIBRARY_OUTPUT_PATH and 
EXECUTABLE_OUTPUT_PATH to point at somewhere in the build tree (like 
foo-build/bin) and then all executables and libraries will be placed 
there as part of the normal build process.  Also, CMake 2.0 has support 
for install targets in windows.

-Brad


More information about the Cmake mailing list