2013-06-29 16 views
5

Chcę, aby Cmake ustalał dla mnie reguły instalacji, które automatycznie instalują również konfigurację i inne rzeczy. Spojrzałem na this question, ale dodając:Instalacja CMake: instalowanie plików konfiguracyjnych

add_executable(solshare_stats.conf solshare_stats.conf)

do mojego pliku CMakeLists.txt tylko dał mi ostrzeżenia i błędy:

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 

Jak mogę dodać config, init i/lub logi do cmake zainstalować reguły?

Oto mój pełny plik 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() 

Odpowiedz

8

Plik .conf powinny być zawarte w add_executable gdzie można zdefiniować wykonywalny cel, a nie w osobnej rozmowy:

add_executable(${PROJECT_NAME} ${SRC_LIST} solshare_stats.conf) 


Następnie należy użyć install(FILE ...) zamiast install(TARGET ...):

install(TARGETS solshare_stats DESTINATION /usr/bin COMPONENT binaries) 
install(FILES solshare_stats.conf DESTINATION etc/solshare_stats COMPONENT config) 


Robiąc

add_executable(${PROJECT_NAME} ${SRC_LIST}) 
add_executable(solshare_stats.conf solshare_stats.conf) 

mówisz chcesz utworzyć 2 wykonywalne, jeden o nazwie "solshare_stats" i inną o nazwie "solshare_stats.conf".

Jedynym plikiem źródłowym drugiego celu jest rzeczywisty plik "solshare_stats.conf". Ponieważ żaden z plików źródłowych w tym celu nie ma sufiksu, który daje pojęcie o języku (np. ".cc" lub ".cpp" oznacza C++, ".asm" oznacza asembler), nie można wywnioskować żadnego języka, stąd CMake błąd.

+0

Co powinienem zmienić na wywołania install(), aby to działało? Ponieważ z bieżącymi komendami install() otrzymuję ten błąd: 'install TARGETS given target" solshare_stats.conf ", który nie istnieje w tym katalogu." – Cheiron

+0

Przepraszam - dodam to! – Fraser

+3

Gotowe. Przy okazji, zwykle przekazuje się względną ścieżkę jako argument "DESTINATION", aby wyróżnić "CMAKE_INSTALL_PREFIX". – Fraser

Powiązane problemy