我希望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