[CMake] simple question

Tristan Carel tristan.carel at gmail.com
Fri Dec 15 08:49:29 EST 2006


On 12/15/06, Mehdi Rabah <mehdi.rabah at gmail.com> wrote:
> Hi everyone,

Hi,

> I'm new to cmake, and there's something simple I don't know how to do.
> Here what I wrote in CMakeLists.txt so far:
>
> project(test)
> subdirs(src)
>
> and in src directory I have another CMakeLists.txt :
>
> add_executable(testApp Applications/testApp.cpp)
>
> and what I want is that the compilation result of testApp.cpp goes into the
> ./bin directory, but by default it goes into ./src
> I use ccmake to set it to go to the bin directory, but when I run the
> compilation the makefile create a src/bin and use it.
>
> How to set cmake so it write the binary in ./bin ?

I've never used it but I guess you just have to set the variable
`EXECUTABLE_OUTPUT_PATH' in the CMakeLists.txt at the top of your
hierarchy so that all sub-CMakeLists.txt will inherit this variable.

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

A full documentation of this variable (and of many others) is available here:
http://www.cmake.org/Wiki/CMake_Useful_Variables

> Also, in src I have a lot of temporary files (cmake_install.cmake,
> CMakeFiles, ...), how can I avoid having this in my subdirectories ? Should
> I write one only CMakeLists.txt in the root directory ?

I guess nop. as CMake needs these files. It's not that much anoying as
it's not in your source tree, in few days you won't ever see them ;)

CU
-- 
Tristan Carel
Music with dinner is an insult both to the cook and the violinist.


More information about the CMake mailing list