diff --git a/DeployMacros.cmake b/DeployMacros.cmake index 9d71f71..e383428 100644 --- a/DeployMacros.cmake +++ b/DeployMacros.cmake @@ -6,6 +6,15 @@ in your top-level CMakeLists.txt +get_system(OS ARCH) + +Set current operating system name to OS and +target architecture to ARCH +On Linux try to retrieve OS from "os-release" or "lsb-release" + + + + set_version( [MAJOR ] [MINOR ] [REVISION ] [SUFFIX ] [BUILD ] [OUTPUT ]) Set target version, optionally creates file @@ -122,7 +131,7 @@ at cmake-time, so if entry ends with "/" it treat as directory, else - file FILES can be presents as cmake-generator-expressions. In this case -entry treated as absolute path only if it prepened wiht "/". +entry treated as absolute path only if it prepened with "/". Examples: * "/$" - right, TARGET_FILE is absolute path * "$" - right, relative item and TARGET_FILE_NAME is only filename @@ -353,6 +362,50 @@ set(__gradle_sign # Help macros end +macro(get_system _OS _ARCH) + if (NOT MY_ARCH) + target_architecture(MY_ARCH) + endif() + if ("x${CMAKE_SYSTEM_NAME}" STREQUAL "xLinux") + set(_os_id "") + set(_os_ver "") + set(_paths "/usr/lib" "/etc") + if (CMAKE_CROSSCOMPILING) + set(_paths "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/../etc") + endif() + find_file(_release_file NAMES os-release lsb-release PATHS ${_paths} NO_DEFAULT_PATH) + if (NOT "x${_release_file}" STREQUAL "x") + file(STRINGS "${_release_file}" _lines) + foreach(_l ${_lines}) + if ("${_l}" MATCHES "VERSION_ID=.*") + string(SUBSTRING "${_l}" 11 -1 _os_ver) + string(REPLACE "\"" "" _os_ver "${_os_ver}") + #message("VERSION_ID ${_os_ver}") + elseif ("${_l}" MATCHES "ID=.*") + string(SUBSTRING "${_l}" 3 -1 _os_id) + string(REPLACE "\"" "" _os_id "${_os_id}") + #message("ID ${_os_id}") + endif() + endforeach() + endif() + string(TOLOWER "${_os_id}${_os_ver}" ${_OS}) + if ("x${${_OS}}" STREQUAL "x") + set(${_OS} "linux") + endif() + set(${_ARCH} "${MY_ARCH}") + elseif(WIN32) + set(${_OS} "windows") + set(${_ARCH} "${MY_ARCH}") + elseif (APPLE) + set(${_OS} "macosx") + set(${_ARCH} "x64") + elseif (DEFINED ANDROID_PLATFORM) + set(${_OS} "android") + set(${_ARCH} "all") + endif() +endmacro() + + macro(deploy_target _T) set(_DESTINATION "${CMAKE_INSTALL_PREFIX}") set(_DEPLOY_DIR "${CMAKE_INSTALL_PREFIX}") @@ -440,43 +493,7 @@ macro(deploy_target _T) set(_TARGET_ARCH "???") set(_TARGET_PACKAGE "???") string(TIMESTAMP _TARGET_TIMESTAMP "%Y-%m-%d %H:%M:%S") - if ("x${CMAKE_SYSTEM_NAME}" STREQUAL "xLinux") - set(_os_id "") - set(_os_ver "") - set(_paths "/usr/lib" "/etc") - if (CMAKE_CROSSCOMPILING) - set(_paths "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/../etc") - endif() - find_file(_release_file NAMES os-release lsb-release PATHS ${_paths} NO_DEFAULT_PATH) - if (NOT "x${_release_file}" STREQUAL "x") - file(STRINGS "${_release_file}" _lines) - foreach(_l ${_lines}) - if ("${_l}" MATCHES "VERSION_ID=.*") - string(SUBSTRING "${_l}" 11 -1 _os_ver) - string(REPLACE "\"" "" _os_ver "${_os_ver}") - #message("VERSION_ID ${_os_ver}") - elseif ("${_l}" MATCHES "ID=.*") - string(SUBSTRING "${_l}" 3 -1 _os_id) - string(REPLACE "\"" "" _os_id "${_os_id}") - #message("ID ${_os_id}") - endif() - endforeach() - endif() - string(TOLOWER "${_os_id}${_os_ver}" _TARGET_OS) - if ("x${_TARGET_OS}" STREQUAL "x") - set(_TARGET_OS "linux") - endif() - set(_TARGET_ARCH "${MY_ARCH}") - elseif(WIN32) - set(_TARGET_OS "windows") - set(_TARGET_ARCH "${MY_ARCH}") - elseif (APPLE) - set(_TARGET_OS "macosx") - set(_TARGET_ARCH "x64") - elseif (DEFINED ANDROID_PLATFORM) - set(_TARGET_OS "android") - set(_TARGET_ARCH "all") - endif() + get_system(_TARGET_OS _TARGET_ARCH) if ("x${CMAKE_SYSTEM_NAME}" STREQUAL "xLinux") set(_build "${${_T}_VERSION_BUILD}")