CMake安装到/bin [英] CMake install to /bin
本文介绍了CMake安装到/bin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在CMake中具有如下目录结构:
I have a directory structure in CMake as follows:
root
CMakeLists.txt
subproject_folder
my_dll_library
CMakeLists.txt
src
source1.cpp
source2.cpp
inc
library.h
CMakeLists.txt
library_demo
src
demo.cpp
CMakeLists.txt
build
bin
我的根目录CmakeLists.txt包含以下内容:
My root CmakeLists.txt contains this:
cmake_minimum_required(VERSION 2.8)
add_subdirectory(subproject_folder)
if(MSVC)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
子项目文件夹中的CMakeList仅包含
The CMakeLists in the subproject folder just contains
add_subdirectory(my_dll_library)
add_subdirectory(library_demo)
library_demo文件夹中的CMakeList包含
The CMakeLists in the library_demo folder contains
project(library_demo)
add_executable(librarydemo src/demo.cpp)
target_link_libraries(librarydemo my_dll_library)
install(TARGETS librarydemo DESTINATION bin)
my_dll_library文件夹中的CMakeList包含
The CMakeLists in the my_dll_library folder contains
add_library(lib_zaber SHARED src/source1.cpp src/source2.cpp)
install(TARGETS lib_zaber DESTINATION bin)
我想将演示可执行文件和库DLL复制到bin文件夹,但无法正常工作.我在做什么错了?
I want to have the demo executable and the library DLL copied to the bin folder, but it isn't working. What am I doing wrong?
推荐答案
也尝试设置这些变量:
CMAKE_BINARY_DIR
CMAKE_CURRENT_BINARY_DIR
这里有完整的变量列表,您可以在这里尝试:
There's a whole list of variables you could try here:
http://www.cmake.org/Wiki/CMake_Useful_Variables
这篇关于CMake安装到/bin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文