[CMake] Controlling CMake directories for some files

Eric Noulard eric.noulard at gmail.com
Fri Jan 5 03:16:14 EST 2007


2007/1/5, gga <ggarra at advancedsl.com.ar>:
> Hi.  I have some code that creates out-of-source builds, by defining:
>
> EXECUTABLE_OUTPUT_PATH
> LIBRARY_OUTPUT_PATH
> CMAKE_LIBRARY_PATH
> CMAKE_BUILD_TYPE
>
> This is working okay, but my problem is that cmake's build system is
> still a tad simplistic for my taste.   Even when I set all those
> variables, there are still some files that cmake creates that I don't
> know how to control.
> Ideally, I want to have an out-of-source build with 4 main root directories:
>
> bin/
> obj/
> lib/
> aux/

We do out-of-source build with a scheme similar to yours.
We proceed as follow:

source are in /path/to/my_src
the root build_tree is located in /path/to/my_build

we do a 'normal' CMake out-of-source build by doing

cd  /path/to/my_build
cmake /path/to/my_src

then the root build tree directory ' /path/to/my_build'
play the role of your "aux".

For bin/ and lib/ we out them by redefining
EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH
to be something like:
SET(EXECUTABLE_OUTPUT_PATH
${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/${CMAKE_BUILD_TYPE}/bin)

SET(EXECUTABLE_LIBRARY_PATH
${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/${CMAKE_BUILD_TYPE}/lib)

so that we end-up with
/path/to/my_build/Linux/Debug/bin
/path/to/my_build/Linux/Debug/lib
for a Debug build on Linux system.

obj files (and other CMake generated files)
lies in the /path/to/my_build that mimics the source tree.

This scheme works just fine, and seems near to your need
besides the obj files.

(You may relocate bin and lib out of the root build tree but
 this seems "ugly" to us moreover you don't know if user will have
 sufficient permission to write out of the build tree)

>
> Is there any way I can obtain some more fine grain control on this?

Why do you need to have obj files in obj?

-- 
Erk


More information about the CMake mailing list