Alex Rivera | Logout

CMake executable location

Asked 2012-02-19T01:21:35.057
36

I have a very simple directory structure:

Project
Project/src
Project/build

Source files are in Project/src, and I do the out-of-src build in Project/build. After running cmake ../ ; make, I can run the executable thusly: Project/build$ src/Executable - that is, the Executable is created in the build/src directory.

How do I set the location of the executable in the CMakeLists.txt file? I've attempted to follow some of the examples found at cmake.org, but the links that work don't seem to show this behaviour.

My Project/src/CMakeLists.txt file is listed here.


include_directories(${SBSProject_SOURCE_DIR}/src)
link_directories(${SBSProject_BINARY_DIR}/src)

set ( SBSProject_SOURCES
    main.cpp
    )

add_executable( TIOBlobs ${SBSProject_SOURCES})

And the top-level Project/CMakeLists.txt:


cmake_minimum_required (VERSION 2.6)
project (SBSProject)

set (CMAKE_CXX_FLAGS "-g3 -Wall -O0") 

add_subdirectory(src)
Edit
Report

1 Answer

10

Another way of relocating the executable file location is via set(EXECUTABLE_OUTPUT_PATH Dir_where_executable_program_is_located)

answered 2013-05-31T14:49:00.893

Your Answer