cmake: move install-conf target to conf/install_conf.cmake file

this way permit to use cmake language to manipulate the target and
avoid restriction imposed by CMAKE_COMMAND command mode
This commit is contained in:
Davide Gerhard 2019-08-27 18:15:44 +02:00
parent df22522126
commit d06b644630
No known key found for this signature in database
GPG Key ID: 7CBEFA144857DC97
6 changed files with 48 additions and 19 deletions

View File

@ -24,7 +24,6 @@ string(REGEX REPLACE "^%C%([^\n]*)" "\\1" file_content "${file_content}")
file(WRITE "${CMAKE_BINARY_DIR}/direwolf.conf" "${file_content}") file(WRITE "${CMAKE_BINARY_DIR}/direwolf.conf" "${file_content}")
# install udev rules for CM108 # install udev rules for CM108
if(LINUX) if(LINUX)
install(FILES "${CUSTOM_CONF_DIR}/99-direwolf-cmedia.rules" DESTINATION etc/udev/rules.d/) install(FILES "${CUSTOM_CONF_DIR}/99-direwolf-cmedia.rules" DESTINATION etc/udev/rules.d/)
@ -37,12 +36,13 @@ install(FILES "${CUSTOM_CONF_DIR}/sdr.conf" DESTINATION share/doc/${CMAKE_PROJEC
# This step would be done as ordinary user. # This step would be done as ordinary user.
# Some people like to put the direwolf config file in /etc/ax25. # Some people like to put the direwolf config file in /etc/ax25.
# Note that all of these are also in $(DESTDIR)/share/doc/direwolf/examples/. # Note that all of these are also in $(DESTDIR)/share/doc/direwolf/examples/.
add_custom_target(install-conf-conf
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/direwolf.conf" ~
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_CONF_DIR}/sdr.conf" ~
)
if(NOT WIN32) if(NOT WIN32)
add_custom_target(install-conf) add_custom_target(install-conf
add_dependencies(install-conf install-conf-conf install-conf-scripts install-conf-telemetry) COMMAND ${CMAKE_COMMAND}
-DCMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}"
-DCUSTOM_CONF_DIR="${CUSTOM_CONF_DIR}"
-DCUSTOM_SCRIPTS_DIR="${CUSTOM_SCRIPTS_DIR}"
-DCUSTOM_TELEMETRY_DIR="${CUSTOM_TELEMETRY_DIR}"
-P "${CMAKE_SOURCE_DIR}/conf/install_conf.cmake"
)
endif() endif()

23
conf/install_conf.cmake Normal file
View File

@ -0,0 +1,23 @@
if(NOT EXISTS ~/direwolf.conf)
install(FILES "${CMAKE_BINARY_DIR}/direwolf.conf" DESTINATION ~)
endif()
if(NOT EXISTS ~/sdr.conf)
install(FILES "${CUSTOM_CONF_DIR}/sdr.conf" DESTINATION ~)
endif()
if(NOT EXISTS ~/dw-start.sh)
install(FILES "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" DESTINATION ~)
endif()
if(NOT EXISTS ~/telem-m0xer-3.txt)
install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-m0xer-3.txt" DESTINATION ~)
endif()
if(NOT EXISTS ~/telem-balloon.conf)
install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-balloon.conf" DESTINATION ~)
endif()
if(NOT EXISTS ~/telem-volts.conf)
install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-volts.conf" DESTINATION ~)
endif()

View File

@ -26,6 +26,8 @@ set(SYMBOLSX_TXT_BKP "symbolsX.txt.old")
set(SYMBOLSX_URL "http://www.aprs.org/symbols/symbolsX.txt") set(SYMBOLSX_URL "http://www.aprs.org/symbols/symbolsX.txt")
set(CUSTOM_BINARY_DATA_DIR "${CMAKE_BINARY_DIR}/data") set(CUSTOM_BINARY_DATA_DIR "${CMAKE_BINARY_DIR}/data")
# we can also move to a separate cmake file and use file(download)
# see conf/install_conf.cmake as example
file(COPY "${CUSTOM_DATA_DIR}/${TOCALLS_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}") file(COPY "${CUSTOM_DATA_DIR}/${TOCALLS_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}")
file(COPY "${CUSTOM_DATA_DIR}/${SYMBOLS-NEW_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}") file(COPY "${CUSTOM_DATA_DIR}/${SYMBOLS-NEW_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}")
file(COPY "${CUSTOM_DATA_DIR}/${SYMBOLSX_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}") file(COPY "${CUSTOM_DATA_DIR}/${SYMBOLSX_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}")

View File

@ -2,10 +2,5 @@
if(NOT WIN32) if(NOT WIN32)
install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dwespeak.sh" DESTINATION bin) install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dwespeak.sh" DESTINATION bin)
install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples) install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples)
add_custom_target(install-conf-scripts
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" ~
)
add_subdirectory(telemetry-toolkit) add_subdirectory(telemetry-toolkit)
endif() endif()

View File

@ -1,9 +1,3 @@
add_custom_target(install-conf-telemetry
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_TELEMETRY_DIR}/telem-m0xer-3.txt" ~
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_TELEMETRY_DIR}/telem-balloon.conf" ~
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_TELEMETRY_DIR}/telem-volts.conf" ~
)
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-balloon.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-balloon.pl" DESTINATION bin)
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-bits.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-bits.pl" DESTINATION bin)
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-data.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-data.pl" DESTINATION bin)

View File

@ -438,3 +438,18 @@ install(TARGETS kissutil DESTINATION bin)
if(UDEV_FOUND) if(UDEV_FOUND)
install(TARGETS cm108 DESTINATION bin) install(TARGETS cm108 DESTINATION bin)
endif() endif()
## TESTS
# Note CMake will generate tests only if the enable_testing() command
# has been invoked. The CTest module invokes the command automatically
# when the BUILD_TESTING option is ON.
include(CTest)
if(BUILD_TESTING)
# add_test(NAME <name> COMMAND <command> [<arg>...]
# [CONFIGURATIONS <config>...]
# [WORKING_DIRECTORY <dir>])
endif()