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) cmake_minimum_required(VERSION 3.13)
project(iprefresher DESCRIPTION "Dynu ip refresher") project(iprefresher DESCRIPTION "Dynu ip refresher")
SET(PROJECT_VERSION 1.3.3)
SET(CMAKE_CXX_STANDARD 17) SET(CMAKE_CXX_STANDARD 17)
# CONFIGURATION
SET(CMAKE_BUILD_TYPE Release) # manually SET build type (Release / Debug) SET(CMAKE_BUILD_TYPE Release) # manually SET build type (Release / Debug)
SET(LIB_METHOD STATIC) #SHARED / STATIC SET(LIB_METHOD STATIC) #SHARED / STATIC
SET(PROJECT_VERSION 1.3.2)
option(BUILD_DOC "Build documentation" OFF) option(BUILD_DOC "Build documentation" OFF) # additional dependency for Doxygen
set(WinBuild true) 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_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -151,6 +153,37 @@ add_executable(iprefresher ${SOURCE})
# LINK generated LIBS # # LINK generated LIBS #
target_link_libraries(iprefresher api logger ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES}) target_link_libraries(iprefresher api logger ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
# setting install targets
IF (NOT ${WinBuild})
# INSTALL to Linux SYSTEM #
# install binaries
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: # General Packaging options:
message(STATUS "config of Package build") message(STATUS "config of Package build")
@ -165,13 +198,6 @@ SET(CPACK_PACKAGE_CONTACT "Lukas Heiligenbrunner <lukas.heiligenbrunner@gmail.co
SET(CMAKE_INSTALL_PREFIX "/") SET(CMAKE_INSTALL_PREFIX "/")
IF (NOT ${WinBuild}) IF (NOT ${WinBuild})
# INSTALL to Linux SYSTEM #
# install binaries
install(TARGETS iprefresher DESTINATION usr/bin)
# install systemd service and enable it
install(FILES service/iprefresher.service DESTINATION lib/systemd/system)
# generate post script for checking if configuration already exists # generate post script for checking if configuration already exists
FILE(WRITE ${CMAKE_SOURCE_DIR}/postinst FILE(WRITE ${CMAKE_SOURCE_DIR}/postinst
"#!/bin/bash "#!/bin/bash
@ -218,27 +244,6 @@ fi\n"
SET(CPACK_PACKAGE_SECTION "games") SET(CPACK_PACKAGE_SECTION "games")
ELSE () 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 .)
# Pack a NSIS intaller # Pack a NSIS intaller
set(CPACK_GENERATOR NSIS) set(CPACK_GENERATOR NSIS)
message(STATUS "Using NSIS Package build.") message(STATUS "Using NSIS Package build.")
@ -253,8 +258,9 @@ INCLUDE(CPack)
add_custom_target(build-packages add_custom_target(build-packages
"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target package "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target package
DEPENDS ${PROJECT_NAME} DEPENDS ${PROJECT_NAME}
COMMENT "Installing ${PROJECT_NAME}") COMMENT "Packing ${PROJECT_NAME}")
message("") message("")
ENDIF ()
# check if Doxygen is installed # check if Doxygen is installed
if (BUILD_DOC) if (BUILD_DOC)