Skip to content

Commit d06b644

Browse files
committed
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
1 parent df22522 commit d06b644

File tree

6 files changed

+48
-19
lines changed

6 files changed

+48
-19
lines changed

conf/CMakeLists.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ string(REGEX REPLACE "^%C%([^\n]*)" "\\1" file_content "${file_content}")
2424

2525
file(WRITE "${CMAKE_BINARY_DIR}/direwolf.conf" "${file_content}")
2626

27-
2827
# install udev rules for CM108
2928
if(LINUX)
3029
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
3736
# This step would be done as ordinary user.
3837
# Some people like to put the direwolf config file in /etc/ax25.
3938
# Note that all of these are also in $(DESTDIR)/share/doc/direwolf/examples/.
40-
add_custom_target(install-conf-conf
41-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/direwolf.conf" ~
42-
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_CONF_DIR}/sdr.conf" ~
43-
)
44-
4539
if(NOT WIN32)
46-
add_custom_target(install-conf)
47-
add_dependencies(install-conf install-conf-conf install-conf-scripts install-conf-telemetry)
40+
add_custom_target(install-conf
41+
COMMAND ${CMAKE_COMMAND}
42+
-DCMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}"
43+
-DCUSTOM_CONF_DIR="${CUSTOM_CONF_DIR}"
44+
-DCUSTOM_SCRIPTS_DIR="${CUSTOM_SCRIPTS_DIR}"
45+
-DCUSTOM_TELEMETRY_DIR="${CUSTOM_TELEMETRY_DIR}"
46+
-P "${CMAKE_SOURCE_DIR}/conf/install_conf.cmake"
47+
)
4848
endif()

conf/install_conf.cmake

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
if(NOT EXISTS ~/direwolf.conf)
2+
install(FILES "${CMAKE_BINARY_DIR}/direwolf.conf" DESTINATION ~)
3+
endif()
4+
5+
if(NOT EXISTS ~/sdr.conf)
6+
install(FILES "${CUSTOM_CONF_DIR}/sdr.conf" DESTINATION ~)
7+
endif()
8+
9+
if(NOT EXISTS ~/dw-start.sh)
10+
install(FILES "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" DESTINATION ~)
11+
endif()
12+
13+
if(NOT EXISTS ~/telem-m0xer-3.txt)
14+
install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-m0xer-3.txt" DESTINATION ~)
15+
endif()
16+
17+
if(NOT EXISTS ~/telem-balloon.conf)
18+
install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-balloon.conf" DESTINATION ~)
19+
endif()
20+
21+
if(NOT EXISTS ~/telem-volts.conf)
22+
install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-volts.conf" DESTINATION ~)
23+
endif()

data/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ set(SYMBOLSX_TXT_BKP "symbolsX.txt.old")
2626
set(SYMBOLSX_URL "http://www.aprs.org/symbols/symbolsX.txt")
2727
set(CUSTOM_BINARY_DATA_DIR "${CMAKE_BINARY_DIR}/data")
2828

29+
# we can also move to a separate cmake file and use file(download)
30+
# see conf/install_conf.cmake as example
2931
file(COPY "${CUSTOM_DATA_DIR}/${TOCALLS_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}")
3032
file(COPY "${CUSTOM_DATA_DIR}/${SYMBOLS-NEW_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}")
3133
file(COPY "${CUSTOM_DATA_DIR}/${SYMBOLSX_TXT}" DESTINATION "${CUSTOM_BINARY_DATA_DIR}")

scripts/CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,5 @@
22
if(NOT WIN32)
33
install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dwespeak.sh" DESTINATION bin)
44
install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples)
5-
6-
add_custom_target(install-conf-scripts
7-
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" ~
8-
)
9-
105
add_subdirectory(telemetry-toolkit)
116
endif()

scripts/telemetry-toolkit/CMakeLists.txt

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
add_custom_target(install-conf-telemetry
2-
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_TELEMETRY_DIR}/telem-m0xer-3.txt" ~
3-
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_TELEMETRY_DIR}/telem-balloon.conf" ~
4-
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_TELEMETRY_DIR}/telem-volts.conf" ~
5-
)
6-
71
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-balloon.pl" DESTINATION bin)
82
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-bits.pl" DESTINATION bin)
93
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-data.pl" DESTINATION bin)

src/CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,18 @@ install(TARGETS kissutil DESTINATION bin)
438438
if(UDEV_FOUND)
439439
install(TARGETS cm108 DESTINATION bin)
440440
endif()
441+
442+
443+
444+
## TESTS
445+
# Note CMake will generate tests only if the enable_testing() command
446+
# has been invoked. The CTest module invokes the command automatically
447+
# when the BUILD_TESTING option is ON.
448+
include(CTest)
449+
if(BUILD_TESTING)
450+
# add_test(NAME <name> COMMAND <command> [<arg>...]
451+
# [CONFIGURATIONS <config>...]
452+
# [WORKING_DIRECTORY <dir>])
453+
454+
455+
endif()

0 commit comments

Comments
 (0)