diff options
Diffstat (limited to 'cmake/cmake.d')
-rw-r--r-- | cmake/cmake.d/01-variables.cmake | 17 | ||||
-rw-r--r-- | cmake/cmake.d/02-macros.cmake | 4 | ||||
-rw-r--r-- | cmake/cmake.d/03-extra_targets.cmake | 115 | ||||
-rw-r--r-- | cmake/cmake.d/04-build_options.cmake | 5 |
4 files changed, 76 insertions, 65 deletions
diff --git a/cmake/cmake.d/01-variables.cmake b/cmake/cmake.d/01-variables.cmake index 570cb4a..8ee4dff 100644 --- a/cmake/cmake.d/01-variables.cmake +++ b/cmake/cmake.d/01-variables.cmake @@ -45,6 +45,9 @@ if(NOT WIN32) set(BoldWhite "${Esc}[1;37m") endif() +# (BUG!!!) as PKG_CONFIG_PATH does not work [should be en env variable] +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON CACHE BOOLEAN "Flag for using prefix path") + # Native packaging name set(NPKG_PROJECT_NAME agl-${PROJECT_NAME}) @@ -55,7 +58,7 @@ set(CMP0048 1) # Get the os type # Used to package .deb if(EXISTS "/etc/os-release") - execute_process(COMMAND grep ID_LIKE /etc/os-release + execute_process(COMMAND grep -E "^ID(=|_LIKE=)" /etc/os-release OUTPUT_VARIABLE TMP_OSRELEASE ) if (NOT TMP_OSRELEASE STREQUAL "") @@ -77,6 +80,9 @@ set(PROJECT_RESOURCES "${CMAKE_SOURCE_DIR}/data" CACHE PATH "Subpath to data") set(AFB_TOKEN "" CACHE PATH "Default AFB_TOKEN") set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN") +# Project path variables +# ---------------------- + # If no install dir try to guess some smart default if(BINDINGS_INSTALL_PREFIX) set(BINDINGS_INSTALL_DIR ${BINDINGS_INSTALL_PREFIX}/${PROJECT_NAME} CACHE PATH "Where the binding will be installed in your system") @@ -93,6 +99,7 @@ else() set(PROJECT_PKG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PKGOUT_DIR} CACHE PATH "Application contents to be packaged") endif() +# Paths to templates files set (PKG_TEMPLATE_PREFIX ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR} CACHE PATH "Default Package Templates Directory") set(SSH_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/ssh" CACHE PATH "Subpath to a directory where are stored needed files to launch on remote target to debuging purposes") set(GDB_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/gdb" CACHE PATH "Subpath to a directory where are stored needed files to launch debuging server on a remote target. Use gdbserver.") @@ -106,13 +113,17 @@ set(DEB_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/deb" CACHE PATH "Subpath to a direc string(REGEX REPLACE "^(.*)/.*$" "\\1" ENTRY_POINT "${PKG_TEMPLATE_PREFIX}") set(PROJECT_PKG_ENTRY_POINT ${ENTRY_POINT}/packaging CACHE PATH "Where package build files, like rpm.spec file or config.xml, are write.") +# Path to autobuild template +set(PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/agl CACHE PATH "Subpath to a directory where are stored autobuild script") +set(PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux CACHE PATH "Subpath to a directory where are stored autobuild script") + # Archive target variables set(ARCHIVE_OUTPUT_ARCHIVE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}_${PROJECT_VERSION}.orig.tar) set(ARCHIVE_OUTPUT ${ARCHIVE_OUTPUT_ARCHIVE}.gz) set(TMP_ARCHIVE_SUBMODULE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}-sub) set(CMD_ARCHIVE_SUBMODULE \'git archive --verbose --prefix=${NPKG_PROJECT_NAME}-${PROJECT_VERSION}/$$path/ --format tar HEAD --output ${TMP_ARCHIVE_SUBMODULE}-$$sha1.tar\' ) -if(OSRELEASE MATCHES "debian") +if(OSRELEASE MATCHES "debian" AND NOT DEFINED $ENV{SDKTARGETSYSROOT}) # build deb spec file from template set(PACKAGING_DEB_OUTPUT_DSC ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}.dsc) set(PACKAGING_DEB_OUTPUT_INSTALL ${PROJECT_PKG_ENTRY_POINT}/debian.${NPKG_PROJECT_NAME}.install) @@ -120,4 +131,4 @@ if(OSRELEASE MATCHES "debian") set(PACKAGING_DEB_OUTPUT_COMPAT ${PROJECT_PKG_ENTRY_POINT}/debian.compat) set(PACKAGING_DEB_OUTPUT_CONTROL ${PROJECT_PKG_ENTRY_POINT}/debian.control) set(PACKAGING_DEB_OUTPUT_RULES ${PROJECT_PKG_ENTRY_POINT}/debian.rules) -endif(OSRELEASE MATCHES "debian")
\ No newline at end of file +endif(OSRELEASE MATCHES "debian" AND NOT DEFINED $ENV{SDKTARGETSYSROOT})
\ No newline at end of file diff --git a/cmake/cmake.d/02-macros.cmake b/cmake/cmake.d/02-macros.cmake index a04b915..fd0c43b 100644 --- a/cmake/cmake.d/02-macros.cmake +++ b/cmake/cmake.d/02-macros.cmake @@ -20,7 +20,7 @@ #-------------------------------------------------------------------------- # WARNING: # Do not change this cmake template -# Customise your preferences in "./etc/config.cmake" +# Customise your preferences in "./conf.d/cmake/config.cmake" #-------------------------------------------------------------------------- # Generic useful macro # ----------------------- @@ -274,4 +274,4 @@ macro(project_closing_msg) add_dependencies(${PROJECT_NAME}_build_done ${DEPENDENCIES_TARGET} ${PROJECT_TARGETS}) endif() -endmacro()
\ No newline at end of file +endmacro() diff --git a/cmake/cmake.d/03-extra_targets.cmake b/cmake/cmake.d/03-extra_targets.cmake index c1d38e8..56f9b78 100644 --- a/cmake/cmake.d/03-extra_targets.cmake +++ b/cmake/cmake.d/03-extra_targets.cmake @@ -21,7 +21,7 @@ #-------------------------------------------------------------------------- # WARNING: # Do not change this cmake template -# Customise your preferences in "./etc/config.cmake" +# Customise your preferences in "./conf.d/cmake/config.cmake" #-------------------------------------------------------------------------- # Add a dummy target to enable global dependency order @@ -54,60 +54,63 @@ add_custom_command(OUTPUT ${ARCHIVE_OUTPUT} ) add_custom_target(archive DEPENDS ${ARCHIVE_OUTPUT}) - #Format Build require package - foreach (PKG_CONFIG ${PKG_REQUIRED_LIST}) - #Unset TMP variable - unset(XPREFIX) - unset(XRULE) - unset(RPM_EXTRA_DEP) - unset(DEB_EXTRA_DEP) - #For deb package,add EOL format only for a new line - if(DEB_PKG_DEPS) - set(DEB_PKG_DEPS "${DEB_PKG_DEPS},\n") - endif() - #Get pkg-config rule on version - string(REGEX REPLACE "[<>]?=.*$" "" XPREFIX ${PKG_CONFIG}) - string(REGEX MATCH "[<>]?=" XRULE ${PKG_CONFIG}) - #Only if pkg-config has rule on version - if(XRULE) - string(REGEX REPLACE ".*[<>]?=" "" XVERS ${PKG_CONFIG}) - set(RPM_EXTRA_DEP " ${XRULE} ${XVERS}") - set(DEB_EXTRA_DEP " (${XRULE} ${XVERS})") - endif() - #Format for rpm package - set(RPM_PKG_DEPS "${RPM_PKG_DEPS}BuildRequires: pkgconfig(${XPREFIX})${RPM_EXTRA_DEP}\n") - #Format for deb package - #Because the tool "dpkg" is used on the packages db to find the - #package providing the pkg-cong file ${XPREFIX}.pc, we need - #to test the OS release package type - if( OSRELEASE MATCHES "debian" ) - execute_process( - COMMAND dpkg -S *${XPREFIX}.pc - OUTPUT_VARIABLE TMP_PKG_BIN - ) - #Need to be harden check - string(REGEX REPLACE ":.*$" "" PKG_BIN ${TMP_PKG_BIN}) - set(DEB_PKG_DEPS "${DEB_PKG_DEPS} ${PKG_BIN} ${DEB_EXTRA_DEP}") - endif() - endforeach() - - if(NOT EXISTS ${RPM_TEMPLATE_DIR}/rpm-config.spec.in) - MESSAGE(FATAL_ERROR "${Red}Missing mandatory files: you need rpm-config.spec.in in ${RPM_TEMPLATE_DIR} folder.${ColourReset}") - endif() - - set(PACKAGING_SPEC_OUTPUT ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}.spec) - add_custom_command(OUTPUT ${PACKAGING_SPEC_OUTPUT} - DEPENDS ${RPM_TEMPLATE_DIR}/rpm-config.spec.in - COMMAND ${CMAKE_COMMAND} -DINFILE=${RPM_TEMPLATE_DIR}/rpm-config.spec.in -DOUTFILE=${PACKAGING_SPEC_OUTPUT} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake - ) - # ---------------------------------------------------------------------------- # Packaging target # ---------------------------------------------------------------------------- -#Because the tool "dpkg" is used on the packages db to find the -#package providing the pkg-cong file ${XPREFIX}.pc, we need -#to test the OS release package type -if(OSRELEASE MATCHES "debian") +#Format Build require package +foreach (PKG_CONFIG ${PKG_REQUIRED_LIST}) + #Unset TMP variable + unset(XPREFIX) + unset(XRULE) + unset(RPM_EXTRA_DEP) + unset(DEB_EXTRA_DEP) + #For deb package,add EOL format only for a new line + if(DEB_PKG_DEPS) + set(DEB_PKG_DEPS "${DEB_PKG_DEPS},\n") + endif() + #Get pkg-config rule on version + string(REGEX REPLACE "[<>]?=.*$" "" XPREFIX ${PKG_CONFIG}) + string(REGEX MATCH "[<>]?=" XRULE ${PKG_CONFIG}) + #Only if pkg-config has rule on version + if(XRULE) + string(REGEX REPLACE ".*[<>]?=" "" XVERS ${PKG_CONFIG}) + set(RPM_EXTRA_DEP " ${XRULE} ${XVERS}") + set(DEB_EXTRA_DEP " (${XRULE} ${XVERS})") + endif() + # Format for rpm package + set(RPM_PKG_DEPS "${RPM_PKG_DEPS}BuildRequires: pkgconfig(${XPREFIX})${RPM_EXTRA_DEP}\n") + + # Format for deb package + # Because the tool "dpkg" is used on the packages db to find the + # package providing the pkg-cong file ${XPREFIX}.pc, we need + # to test the OS release package type + # Only doable within a native environment not under SDK + if( OSRELEASE MATCHES "debian" AND NOT DEFINED $ENV{SDKTARGETSYSROOT}) + execute_process( + COMMAND dpkg -S *${XPREFIX}.pc + OUTPUT_VARIABLE TMP_PKG_BIN + ) + #Need to be harden check + string(REGEX REPLACE ":.*$" "" PKG_BIN ${TMP_PKG_BIN}) + set(DEB_PKG_DEPS "${DEB_PKG_DEPS} ${PKG_BIN} ${DEB_EXTRA_DEP}") + endif() +endforeach() + +if(NOT EXISTS ${RPM_TEMPLATE_DIR}/rpm-config.spec.in) + MESSAGE(FATAL_ERROR "${Red}Missing mandatory files: you need rpm-config.spec.in in ${RPM_TEMPLATE_DIR} folder.${ColourReset}") +endif() + +set(PACKAGING_SPEC_OUTPUT ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}.spec) +add_custom_command(OUTPUT ${PACKAGING_SPEC_OUTPUT} + DEPENDS ${RPM_TEMPLATE_DIR}/rpm-config.spec.in + COMMAND ${CMAKE_COMMAND} -DINFILE=${RPM_TEMPLATE_DIR}/rpm-config.spec.in -DOUTFILE=${PACKAGING_SPEC_OUTPUT} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake +) + +# Because the tool "dpkg" is used on the packages db to find the +# package providing the pkg-cong file ${XPREFIX}.pc, we need +# to test the OS release package type +# Only doable within a native environment not under SDK +if(OSRELEASE MATCHES "debian" AND NOT DEFINED $ENV{SDKTARGETSYSROOT}) add_custom_command(OUTPUT ${PACKAGING_DEB_OUTPUT_DSC} ${PACKAGING_DEB_OUTPUT_INSTALL} ${PACKAGING_DEB_OUTPUT_CHANGELOG} @@ -142,7 +145,7 @@ add_dependencies(packaging packaging_rpm) if(TARGET packaging_wgt) add_dependencies(packaging packaging_wgt) endif() -if(OSRELEASE MATCHES "debian") +if(OSRELEASE MATCHES "debian" AND NOT DEFINED $ENV{SDKTARGETSYSROOT}) # Target to add dependencies indirectly to "packaging" target. add_dependencies(packaging packaging_deb) endif() @@ -172,9 +175,9 @@ add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/conf.d/autobuild/agl/autobuild ${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux/autobuild DEPENDS ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/agl/autobuild.in ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/linux/autobuild.in - COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/agl/autobuild.in -DOUTFILE=${CMAKE_SOURCE_DIR}/conf.d/autobuild/agl/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake - COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/agl/autobuild.in -DOUTFILE=${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake ) add_custom_target(autobuild ALL DEPENDS ${CMAKE_SOURCE_DIR}/conf.d/autobuild/agl/autobuild - ${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux/autobuild)
\ No newline at end of file + ${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux/autobuild) diff --git a/cmake/cmake.d/04-build_options.cmake b/cmake/cmake.d/04-build_options.cmake index 3a1fc81..45b4720 100644 --- a/cmake/cmake.d/04-build_options.cmake +++ b/cmake/cmake.d/04-build_options.cmake @@ -21,7 +21,7 @@ #-------------------------------------------------------------------------- # WARNING: # Do not change this cmake template -# Customise your preferences in "./etc/config.cmake" +# Customise your preferences in "./conf.d/cmake/config.cmake" #-------------------------------------------------------------------------- # Check GCC minimal version @@ -89,9 +89,6 @@ else() endif() set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX} CACHE STRING "Installation Prefix") -# (BUG!!!) as PKG_CONFIG_PATH does not work [should be en env variable] -set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON CACHE BOOLEAN "Flag for using prefix path") - # Loop on required package and add options foreach (PKG_CONFIG ${PKG_REQUIRED_LIST}) string(REGEX REPLACE "[<>]?=.*$" "" XPREFIX ${PKG_CONFIG}) |