cmake_minimum_required(VERSION 3.0.0...4.0.0 FATAL_ERROR)
project(cli-downloader VERSION 2.1.0 )
set(CMAKE_BUILD_TYPE Release)
# turn on verbose if you uncomment the set
#set(CMAKE_VERBOSE_MAKEFILE ON)
# this CMakeLists.txt was manually generated for cli-downloader
# by bigbass updated to 2.0.0 Sept 8 2022
# first QT5 build of a bacon app
# reduce binary size and strip
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
# variables to handle the various colours in cmake
string(ASCII 27 Esc)
set(ColourReset "${Esc}[m")
set(ColourBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
# declare which folders will be used
include_directories(src)
#include_directories(documentation)
#include_directories(syntax)
#include_directories(icons)
# make a configure time system check for the cmake version
execute_process(COMMAND cmake --version
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE _RESULT )
#----------------------------------------------
# ADDING an UNINSTALL option to the makefile
#----------------------------------------------
# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
message("\n ${Cyan}Host ${CMAKE_HOST_SYSTEM_PROCESSOR} for target ${CMAKE_HOST_SYSTEM_PROCESSOR} ${ColourReset} \n")
message("\n ${Cyan}Now type ${ColourReset} ${BoldYellow} cmake --build .${ColourReset} \n")
message(" ${Cyan}After building if you are feeling brave type ${ColourReset} ${BoldYellow} sudo make install ${ColourReset} \n")
#message(" ${Cyan}*You can also generate a debian package and an RPM type ${ColourReset} ${BoldYellow} cpack ${ColourReset} \n")
message(" ${Cyan}*You can also generate a debian package type ${ColourReset} ${BoldYellow} cpack ${ColourReset} \n")
message(" ${Cyan}*And double click on the deb package and it will install ${ColourReset} \n")
message(" ${Cyan}*using your built in package manager ${ColourReset} \n")
# SOURCES
# Can manually add the sources using the set command as follows:
# we can work with multiple .cxx files if needed
set(SOURCES src/cli-downloader.bac.cxx)
# we can shorten the code using file(GLOB...) allows for wildcard additions:
file(GLOB CONFIGURE_DEPENDS "src *.h")
# COMPILE OPTIONS
# QT was more complex to find the libs and compiler options
# reduce binary size
add_compile_options( -Wno-return-type -Wno-write-strings
-Wno-pointer-arith -Wformat=1
-I/usr/include/arm-linux-gnueabihf/qt5
-I/usr/include/arm-linux-gnueabihf/qt5/QtNetwork -fPIC -c -Os )
# we may have multiple .cxx files
add_executable(cli-downloader ${SOURCES})
# FIX needs ${CMAKE_DL_LIBS} for cli-downloader to compile
target_link_libraries(cli-downloader ${CMAKE_DL_LIBS} -lQt5Network -lQt5Core -lpthread -latomic -lm )
#----------------------------------------------------------------------
# INSTALLER
#----------------------------------------------------------------------
# cli-downloader
install(TARGETS cli-downloader DESTINATION /usr/bin )
#----------------------------------------------------------------------
# DEBIAN PACKAGE MAKER
#----------------------------------------------------------------------
# manual hack here you can set it to build with a "yes" or "no"
SET(DEBIAN_BUILD "yes")
if( DEBIAN_BUILD STREQUAL "yes")
# added DEC 29 2020
# autogenerate dependency information only pulls in libc for cli-downloader
#set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
# needed to add this manually added Sept 8 2022
set (CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5websockets5")
# build an official debian package with depencencies
SET(CPACK_GENERATOR "DEB")
# the "DEB-DEFAULT" automatically gets the arch and version
# it also could be done manually setting your variables
# hard coded package name
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_AUTOREQ "no")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Author bigbass <bigbass@basic-converter.proboards.com> cmake package maintainer bigbass <bigbass@basic-converter.proboards.com>")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "basic-converter.proboards.com")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "command line downloader QT5 ")
endif()
#----------------------------------------------------------------------
# RPM PACKAGE MAKER
#----------------------------------------------------------------------
# manual hack here you can set it to build with a "yes" or "no"
SET(RPM_BUILD "no")
if( RPM_BUILD STREQUAL "yes")
# rpmbuild executable must be installed for this to work
# on debian it has a different package name
# sudo apt-get install rpm
# which rpmbuild
# /usr/bin/rpmbuild
SET(CPACK_GENERATOR "RPM")
# the "RPM-DEFAULT" automatically gets the arch and version
# it also could be done manually setting your variables
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
#set(CPACK_RPM_PACKAGE_AUTOREQ "no")
SET(CPACK_RPM_PACKAGE_MAINTAINER "Author bigbass <bigbass@basic-converter.proboards.com> cmake package maintainer bigbass <bigbass@basic-converter.proboards.com>")
set(CPACK_RPM_PACKAGE_HOMEPAGE "basic-converter.proboards.com")
set(CPACK_RPM_PACKAGE_DESCRIPTION "command line downloader QT5 ")
endif()
INCLUDE(CPack)