summaryrefslogtreecommitdiffstats
path: root/cmake/cmake.d
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-06-28 18:10:46 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-06-28 18:10:46 +0200
commit8d60cd89fb3dbca16ac50abd1cceabf8662676b9 (patch)
tree8525a03b696f7bd2947413db62ff82bc2b124866 /cmake/cmake.d
parent3a798fa04ebfd9f7644f304af41baedd1e2a591f (diff)
Fix: Debian detection, only valid in native env
Generate packaging files for Debian isn't available from SDK. Only native and configured environment is supported about now. Change-Id: I70f6b19a4a04ecd7a902ef9d6f2300f4f98209a5 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh> # Conflicts: # cmake/cmake.d/01-variables.cmake
Diffstat (limited to 'cmake/cmake.d')
-rw-r--r--cmake/cmake.d/01-variables.cmake8
-rw-r--r--cmake/cmake.d/03-extra_targets.cmake107
2 files changed, 59 insertions, 56 deletions
diff --git a/cmake/cmake.d/01-variables.cmake b/cmake/cmake.d/01-variables.cmake
index 123c0f6..9314061 100644
--- a/cmake/cmake.d/01-variables.cmake
+++ b/cmake/cmake.d/01-variables.cmake
@@ -21,7 +21,7 @@
#--------------------------------------------------------------------------
# WARNING:
# Do not change this cmake template
-# Customise your preferences in "./conf.d/cmake/config.cmake"
+# Customise your preferences in "./etc/config.cmake"
#--------------------------------------------------------------------------
# Get colorized message output non Windows OS. You know bash ? :)
@@ -58,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 "")
@@ -115,7 +115,7 @@ 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)
@@ -123,4 +123,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")
+endif(OSRELEASE MATCHES "debian" AND NOT DEFINED $ENV{SDKTARGETSYSROOT}) \ No newline at end of file
diff --git a/cmake/cmake.d/03-extra_targets.cmake b/cmake/cmake.d/03-extra_targets.cmake
index 45749bf..daae43c 100644
--- a/cmake/cmake.d/03-extra_targets.cmake
+++ b/cmake/cmake.d/03-extra_targets.cmake
@@ -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()