我希望Cmake为我制定安装规则,同时自动安装配置和其他东西。我看着this question,但补充说:CMake安装:安装配置文件
add_executable(solshare_stats.conf solshare_stats.conf)
我的CMakeLists.txt文件只给了我警告和错误:
CMake Error: CMake can not determine linker language for target:solshare_stats.conf
CMake Error: Cannot determine link language for target "solshare_stats.conf".
...
make[2]: *** No rule to make target `CMakeFiles/solshare_stats.conf.dir/build'. Stop.
make[1]: *** [CMakeFiles/solshare_stats.conf.dir/all] Error 2
make: *** [all] Error 2
如何添加配置,初始化和/或日志文件向CMake安装规则?
这里是我的完整的CMakeLists.txt文件:
project(solshare_stats)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
add_executable(solshare_stats.conf solshare_stats.conf)
target_link_libraries(solshare_stats mysqlcppconn)
target_link_libraries(solshare_stats wiringPi)
if(UNIX)
if(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_EXE_LINKER_FLAGS "-s")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -std=c++0x")
endif()
install(TARGETS solshare_stats DESTINATION /usr/bin COMPONENT binaries)
install(TARGETS solshare_stats.conf DESTINATION /etc/solshare_stats COMPONENT config)
endif()
我应该更改为install()调用以使其工作?因为使用当前的install()命令,我得到这个错误:'安装TARGETS给定的目标“solshare_stats.conf”,这个目录中不存在。“ – Cheiron
对不起,我只是补充一点! – Fraser
完成。顺便说一下,通常传递一个相对路径作为'DESTINATION'参数,这样'CMAKE_INSTALL_PREFIX'得到遵守。 – Fraser