cmake: implement basic cpack functionality

to create ZIP package run

    cpack

to add new generator modify CPACK_GENERATOR variable.

NOTE: pay attention on CPU flags optimization when you redistribuite
the package (segmentation fault)
This commit is contained in:
Davide Gerhard 2019-11-13 15:04:52 +01:00
parent 1ab26c66e2
commit 1cf5a22333
No known key found for this signature in database
GPG Key ID: 7CBEFA144857DC97
10 changed files with 96 additions and 64 deletions

View File

@ -82,6 +82,18 @@ set(CUSTOM_TEST_DIR "${CMAKE_SOURCE_DIR}/test")
set(CUSTOM_TEST_SCRIPTS_DIR "${CUSTOM_TEST_DIR}/scripts") set(CUSTOM_TEST_SCRIPTS_DIR "${CUSTOM_TEST_DIR}/scripts")
set(CUSTOM_SHELL_SHABANG "#!/bin/sh -e") set(CUSTOM_SHELL_SHABANG "#!/bin/sh -e")
# cpack variables
set(CPACK_GENERATOR "ZIP")
set(CPACK_STRIP_FILES true)
set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${direwolf_VERSION}_${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_PACKAGE_CONTACT "https://github.com/wb2osz/direwolf")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Dire Wolf is a software soundcard AX.25 packet modem/TNC and APRS encoder/decoder")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_SOURCE_IGNORE_FILES "${PROJECT_BINARY_DIR};/.git/;.gitignore;menu.yml;.travis.yml;.appveyor.yml;default.nix;.envrc;TODOs.org;/.scripts/")
# if we don't set build_type # if we don't set build_type
if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "") if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
@ -152,6 +164,23 @@ elseif (C_GCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmax-errors=1") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmax-errors=1")
endif() endif()
# set installation directories
if (WIN32 OR CYGWIN)
set(INSTALL_BIN_DIR ".")
set(INSTALL_DOC_DIR "doc")
set(INSTALL_CONF_DIR ".")
set(INSTALL_SCRIPTS_DIR "scripts")
set(INSTALL_MAN_DIR "man")
set(INSTALL_DATA_DIR "data")
else()
set(INSTALL_BIN_DIR "bin")
set(INSTALL_DOC_DIR "share/doc/${CMAKE_PROJECT_NAME}")
set(INSTALL_CONF_DIR "${INSTALL_DOC_DIR}/conf")
set(INSTALL_SCRIPTS_DIR "${INSTALL_DOC_DIR}/scripts")
set(INSTALL_MAN_DIR "share/man/man1")
set(INSTALL_DATA_DIR "share/${PROJECT_NAME}")
endif(WIN32 OR CYGWIN)
# requirements # requirements
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
@ -224,9 +253,9 @@ add_subdirectory(scripts)
add_subdirectory(conf) add_subdirectory(conf)
# install basic docs # install basic docs
install(FILES ${CMAKE_SOURCE_DIR}/CHANGES.md DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES ${CMAKE_SOURCE_DIR}/CHANGES.md DESTINATION ${INSTALL_DOC_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${INSTALL_DOC_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/external/LICENSE DESTINATION share/doc/${CMAKE_PROJECT_NAME}/external) install(FILES ${CMAKE_SOURCE_DIR}/external/LICENSE DESTINATION ${INSTALL_DOC_DIR}/external)
add_subdirectory(doc) add_subdirectory(doc)
add_subdirectory(man) add_subdirectory(man)

View File

@ -1 +1 @@
# empty for the moment include(CPack)

View File

@ -29,8 +29,8 @@ 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/)
endif() endif()
install(FILES "${CMAKE_BINARY_DIR}/direwolf.conf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples) install(FILES "${CMAKE_BINARY_DIR}/direwolf.conf" DESTINATION ${INSTALL_CONF_DIR})
install(FILES "${CUSTOM_CONF_DIR}/sdr.conf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples) install(FILES "${CUSTOM_CONF_DIR}/sdr.conf" DESTINATION ${INSTALL_CONF_DIR})
# Put sample configuration & startup files in home directory. # Put sample configuration & startup files in home directory.
# This step would be done as ordinary user. # This step would be done as ordinary user.

View File

@ -89,6 +89,6 @@ ExternalProject_Add(download_symbolsx
add_custom_target(update-data) add_custom_target(update-data)
add_dependencies(update-data data_rename download_tocalls download_symbols-new download_symbolsx) add_dependencies(update-data data_rename download_tocalls download_symbols-new download_symbolsx)
install(FILES "${CUSTOM_BINARY_DATA_DIR}/${TOCALLS_TXT}" DESTINATION share/${PROJECT_NAME}) install(FILES "${CUSTOM_BINARY_DATA_DIR}/${TOCALLS_TXT}" DESTINATION ${INSTALL_DATA_DIR})
install(FILES "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLS-NEW_TXT}" DESTINATION share/${PROJECT_NAME}) install(FILES "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLS-NEW_TXT}" DESTINATION ${INSTALL_DATA_DIR})
install(FILES "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLSX_TXT}" DESTINATION share/${PROJECT_NAME}) install(FILES "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLSX_TXT}" DESTINATION ${INSTALL_DATA_DIR})

View File

@ -1,18 +1,18 @@
install(FILES "${CUSTOM_DOC_DIR}/README.md" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/README.md" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/2400-4800-PSK-for-APRS-Packet-Radio.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/2400-4800-PSK-for-APRS-Packet-Radio.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/A-Closer-Look-at-the-WA8LMF-TNC-Test-CD.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/A-Closer-Look-at-the-WA8LMF-TNC-Test-CD.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/APRS-Telemetry-Toolkit.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/APRS-Telemetry-Toolkit.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/APRStt-Implementation-Notes.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/APRStt-Implementation-Notes.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/APRStt-interface-for-SARTrack.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/APRStt-interface-for-SARTrack.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/APRStt-Listening-Example.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/APRStt-Listening-Example.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/Bluetooth-KISS-TNC.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/Bluetooth-KISS-TNC.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/Going-beyond-9600-baud.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/Going-beyond-9600-baud.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/Raspberry-Pi-APRS.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/Raspberry-Pi-APRS.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/Raspberry-Pi-APRS-Tracker.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/Raspberry-Pi-APRS-Tracker.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/Raspberry-Pi-SDR-IGate.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/Raspberry-Pi-SDR-IGate.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/Successful-APRS-IGate-Operation.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/Successful-APRS-IGate-Operation.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/User-Guide.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/User-Guide.pdf" DESTINATION ${INSTALL_DOC_DIR})
install(FILES "${CUSTOM_DOC_DIR}/WA8LMF-TNC-Test-CD-Results.pdf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}) install(FILES "${CUSTOM_DOC_DIR}/WA8LMF-TNC-Test-CD-Results.pdf" DESTINATION ${INSTALL_DOC_DIR})

View File

@ -1,11 +1,13 @@
install(FILES "${CUSTOM_MAN_DIR}/aclients.1" DESTINATION share/man/man1) if(NOT (WIN32 OR CYGWIN))
install(FILES "${CUSTOM_MAN_DIR}/atest.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/aclients.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/decode_aprs.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/atest.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/direwolf.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/decode_aprs.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/gen_packets.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/direwolf.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/kissutil.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/gen_packets.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/ll2utm.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/kissutil.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/log2gpx.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/ll2utm.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/text2tt.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/log2gpx.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/tt2text.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/text2tt.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/utm2ll.1" DESTINATION share/man/man1) install(FILES "${CUSTOM_MAN_DIR}/tt2text.1" DESTINATION ${INSTALL_MAN_DIR})
install(FILES "${CUSTOM_MAN_DIR}/utm2ll.1" DESTINATION ${INSTALL_MAN_DIR})
endif(NOT (WIN32 OR CYGWIN))

View File

@ -1,6 +1,6 @@
if(NOT (WIN32 OR CYGWIN)) if(NOT (WIN32 OR CYGWIN))
install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dwespeak.sh" DESTINATION bin) install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dwespeak.sh" DESTINATION ${INSTALL_BIN_DIR})
install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples) install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" DESTINATION ${INSTALL_SCRIPTS_DIR})
add_subdirectory(telemetry-toolkit) add_subdirectory(telemetry-toolkit)
endif() endif()

View File

@ -1,13 +1,13 @@
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-balloon.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-balloon.pl" DESTINATION ${INSTALL_BIN_DIR})
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-bits.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-bits.pl" DESTINATION ${INSTALL_BIN_DIR})
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-data.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-data.pl" DESTINATION ${INSTALL_BIN_DIR})
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-data91.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-data91.pl" DESTINATION ${INSTALL_BIN_DIR})
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-eqns.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-eqns.pl" DESTINATION ${INSTALL_BIN_DIR})
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-parm.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-parm.pl" DESTINATION ${INSTALL_BIN_DIR})
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-seq.sh" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-seq.sh" DESTINATION ${INSTALL_BIN_DIR})
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-unit.pl" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-unit.pl" DESTINATION ${INSTALL_BIN_DIR})
install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-volts.py" DESTINATION bin) install(PROGRAMS "${CUSTOM_TELEMETRY_DIR}/telem-volts.py" DESTINATION ${INSTALL_BIN_DIR})
install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-m0xer-3.txt" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples) install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-m0xer-3.txt" DESTINATION ${INSTALL_CONF_DIR})
install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-balloon.conf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples) install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-balloon.conf" DESTINATION ${INSTALL_CONF_DIR})
install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-volts.conf" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples) install(FILES "${CUSTOM_TELEMETRY_DIR}/telem-volts.conf" DESTINATION ${INSTALL_CONF_DIR})

View File

@ -455,18 +455,18 @@ if(WIN32 OR CYGWIN)
target_link_libraries(ttcalc ws2_32) target_link_libraries(ttcalc ws2_32)
endif() endif()
install(TARGETS direwolf DESTINATION bin) install(TARGETS direwolf DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS decode_aprs DESTINATION bin) install(TARGETS decode_aprs DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS text2tt DESTINATION bin) install(TARGETS text2tt DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS tt2text DESTINATION bin) install(TARGETS tt2text DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS ll2utm DESTINATION bin) install(TARGETS ll2utm DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS utm2ll DESTINATION bin) install(TARGETS utm2ll DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS aclients DESTINATION bin) install(TARGETS aclients DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS log2gpx DESTINATION bin) install(TARGETS log2gpx DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS gen_packets DESTINATION bin) install(TARGETS gen_packets DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS atest DESTINATION bin) install(TARGETS atest DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS ttcalc DESTINATION bin) install(TARGETS ttcalc DESTINATION ${INSTALL_BIN_DIR})
install(TARGETS kissutil DESTINATION bin) install(TARGETS kissutil DESTINATION ${INSTALL_BIN_DIR})
if(UDEV_FOUND) if(UDEV_FOUND)
install(TARGETS cm108 DESTINATION bin) install(TARGETS cm108 DESTINATION ${INSTALL_BIN_DIR})
endif() endif()

View File

@ -265,6 +265,7 @@ static const struct {
static const char *search_locations[] = { static const char *search_locations[] = {
(const char *) "symbols-new.txt", (const char *) "symbols-new.txt",
(const char *) "data/symbols-new.txt",
(const char *) "../data/symbols-new.txt", (const char *) "../data/symbols-new.txt",
#ifndef __WIN32__ #ifndef __WIN32__
(const char *) "/usr/local/share/direwolf/symbols-new.txt", (const char *) "/usr/local/share/direwolf/symbols-new.txt",