如何正确指定CMAKE RUNTIME_OUTPUT_DIRECTORY?

时间:2016-07-12 13:19:08

标签: cmake

我有以下目录结构

cmake_test
├── bin
├── CMakeLists.txt
├── src
│   └── func.cxx
└── subproj
    ├── CMakeLists.txt
    └── src
        └── main.cxx

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)

project(main)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin/)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin/lib/)
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -Wall -g3 -O0")
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra")

set(META_SRC_DIR ${CMAKE_HOME_DIRECTORY}/src)

aux_source_directory(${META_SRC_DIR}/           META_SRC_LIST)

add_subdirectory(subproj)

subproj / CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)

project(subproj)

aux_source_directory(${PROJECT_SOURCE_DIR}/src  SRC_LIST)

#include_directories(${PROJECT_SOURCE_DIR}/include)

add_executable(${PROJECT_NAME} ${SRC_LIST})

当我构建这个项目(cd bin; cmake ..; make)时,我面临以下错误:

Scanning dependencies of target subproj
[ 50%] Building CXX object subproj/CMakeFiles/subproj.dir/src/main.cxx.o
[100%] Linking CXX executable .
/usr/bin/ld: cannot open output file .: Is a directory
collect2: error: ld returned 1 exit status
subproj/CMakeFiles/subproj.dir/build.make:94: recipe for target 'subproj' failed
make[2]: *** [subproj] Error 1
CMakeFiles/Makefile2:85: recipe for target 'subproj/CMakeFiles/subproj.dir/all' failed
make[1]: *** [subproj/CMakeFiles/subproj.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

如何解决?

0 个答案:

没有答案