options to allow/deny package build

option cleanup
This commit is contained in:
lukas 2020-05-06 11:33:29 +02:00
parent 2e3a39f38c
commit b133ab6961

View File

@ -9,14 +9,16 @@
cmake_minimum_required(VERSION 3.13)
project(iprefresher DESCRIPTION "Dynu ip refresher")
SET(PROJECT_VERSION 1.3.3)
SET(CMAKE_CXX_STANDARD 17)
# CONFIGURATION
SET(CMAKE_BUILD_TYPE Release) # manually SET build type (Release / Debug)
SET(LIB_METHOD STATIC) #SHARED / STATIC
SET(PROJECT_VERSION 1.3.2)
option(BUILD_DOC "Build documentation" OFF)
set(WinBuild true)
option(BUILD_DOC "Build documentation" OFF) # additional dependency for Doxygen
option(PACKAGING "Allow Packaging to <exe>, <deb> or <rpm>" ON) # additional dependencies for RPMbuild,dpkg or NSIS
set(WinBuild false)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -151,19 +153,7 @@ add_executable(iprefresher ${SOURCE})
# LINK generated LIBS #
target_link_libraries(iprefresher api logger ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
# General Packaging options:
message(STATUS "config of Package build")
set(CPACK_PACKAGE_NAME "DynuIpRefresher")
SET(CPACK_PACKAGE_DESCRIPTION "IPrefresher to refresh Dynu ip address and notify user via Telegram")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "IPrefresher to refresh Dynu ip address and notify user via Telegram")
SET(CPACK_PACKAGE_VENDOR "Lukas Heilgienbrunner")
SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}")
SET(CPACK_PACKAGE_CONTACT "Lukas Heiligenbrunner <lukas.heiligenbrunner@gmail.com>")
SET(CMAKE_INSTALL_PREFIX "/")
# setting install targets
IF (NOT ${WinBuild})
# INSTALL to Linux SYSTEM #
@ -171,7 +161,43 @@ IF (NOT ${WinBuild})
install(TARGETS iprefresher DESTINATION usr/bin)
# install systemd service and enable it
install(FILES service/iprefresher.service DESTINATION lib/systemd/system)
ELSE ()
# INSTALL to Windows SYSTEM #
# install binary to current folder
set_target_properties(iprefresher PROPERTIES SUFFIX ".exe")
install(TARGETS iprefresher DESTINATION .)
# install .dll dependencies
# todo check if files exist...
install(FILES /usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libcurl-4.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libssh2-1.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libstdc++-6.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libgcc_s_seh-1.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libcrypto-1_1-x64.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libssl-1_1-x64.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libwinpthread-1.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/zlib1.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libidn2-0.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libconfig++-11.dll
DESTINATION .)
ENDIF ()
if (${PACKAGING})
# General Packaging options:
message(STATUS "config of Package build")
set(CPACK_PACKAGE_NAME "DynuIpRefresher")
SET(CPACK_PACKAGE_DESCRIPTION "IPrefresher to refresh Dynu ip address and notify user via Telegram")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "IPrefresher to refresh Dynu ip address and notify user via Telegram")
SET(CPACK_PACKAGE_VENDOR "Lukas Heilgienbrunner")
SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}")
SET(CPACK_PACKAGE_CONTACT "Lukas Heiligenbrunner <lukas.heiligenbrunner@gmail.com>")
SET(CMAKE_INSTALL_PREFIX "/")
IF (NOT ${WinBuild})
# generate post script for checking if configuration already exists
FILE(WRITE ${CMAKE_SOURCE_DIR}/postinst
"#!/bin/bash
@ -217,28 +243,7 @@ fi\n"
SET(CPACK_SOURCE_GENERATOR "TGZ;TBZ2")
SET(CPACK_PACKAGE_SECTION "games")
ELSE ()
# INSTALL to Windows SYSTEM #
# install binary to current folder
set_target_properties(iprefresher PROPERTIES SUFFIX ".exe")
install(TARGETS iprefresher DESTINATION .)
# install .dll dependencies
# todo check if files exist...
install(FILES /usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libcurl-4.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libssh2-1.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libstdc++-6.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libgcc_s_seh-1.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libcrypto-1_1-x64.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libssl-1_1-x64.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libwinpthread-1.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/zlib1.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libidn2-0.dll
/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/bin/libconfig++-11.dll
DESTINATION .)
ELSE ()
# Pack a NSIS intaller
set(CPACK_GENERATOR NSIS)
message(STATUS "Using NSIS Package build.")
@ -246,15 +251,16 @@ ELSE ()
set(CPACK_NSIS_testcomp_INSTALL_DIRECTORY /)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "DynuIpRefresher")
SET(CPACK_NSIS_MODIFY_PATH ON)
ENDIF ()
ENDIF ()
INCLUDE(CPack)
INCLUDE(CPack)
add_custom_target(build-packages
add_custom_target(build-packages
"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target package
DEPENDS ${PROJECT_NAME}
COMMENT "Installing ${PROJECT_NAME}")
message("")
COMMENT "Packing ${PROJECT_NAME}")
message("")
ENDIF ()
# check if Doxygen is installed
if (BUILD_DOC)