[CMake] Output directory

Michael Jackson mike.jackson at bluequartz.net
Fri Dec 5 15:36:07 EST 2008


On Dec 5, 2008, at 11:54 AM, Robert Dailey wrote:

> On Mon, Nov 24, 2008 at 10:34 AM, Ioan Calin Borcoman <iborco at gmail.com 
> > wrote:
> I dump all my apps in the CMAKE_BUILD_DIR with:
>
> set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
>
> Thanks for your response.
>
> I'm having a hard time understanding how this works. My project  
> structure looks like this:
>
> myroot/
>   component1/
>   component2/
>   component3/
>
> Each "component" under the "myroot" directory is a separate project.  
> Each component's project should output executable and library files  
> to component1/build/${project_name}, and place intermediate files  
> into component1/build/obj. How can I do this? When in my script do I  
> actually set CMAKE_EXECUTABLE_OUTPUT_PATH? Do I set it after the  
> project() call? Do I set it after the add_executable() call? Do I  
> have to set the variable differently for each project since the  
> output directory will be different for each project? Here's what I'm  
> currently doing:
>
> set( CMAKE_EXECUTABLE_OUTPUT_PATH "build/${project_name}" )
> project( component1 )
> add_executable( component1 ${source_files} )
>
> Thanks in advance for the help.


I _think_ you want:


project( component1 )
set( CMAKE_EXECUTABLE_OUTPUT_PATH "build/${project_name}" )
add_executable( component1 ${source_files} )

Is there a "master" cmakelists.txt within the myroot directory? Are  
you compiling all the components separately or through a master  
cmakelists.txt file?


For example if you have the following path: myroot/component1 and you  
create a build directory within that directory called BUILD so you  
have the path: myroot/component1/BUILD then run that bit of CMake code  
you will end up with executables in myroot/component1/BUILD/build/ 
component1


I think what you are looking for is:
SET (EXECUTABLE_OUTPUT_PATH
   ${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}
   CACHE PATH
   "Single Directory for all Executables."
   )

this would put component1 executables into myroot/component1/Build/ 
component1/*

HTH

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio





More information about the CMake mailing list