Compare commits
6 Commits
cmake_refa
...
c816ddc21e
| Author | SHA1 | Date | |
|---|---|---|---|
| c816ddc21e | |||
| 6c0de52180 | |||
|
43a9d8be6f
|
|||
| 8f898b103d | |||
|
|
46526851f5 | ||
| 0868a20bb5 |
6
.editorconfig
Normal file
6
.editorconfig
Normal file
@@ -0,0 +1,6 @@
|
||||
root = true
|
||||
|
||||
[*.{h,c,cpp}]
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
tab_width = 4
|
||||
@@ -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(<target> [MAJOR <value>] [MINOR <value>] [REVISION <value>] [SUFFIX <value>] [BUILD <value>] [OUTPUT <file>])
|
||||
|
||||
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:
|
||||
* "/$<TARGET_FILE:myexe>" - right, TARGET_FILE is absolute path
|
||||
* "$<TARGET_FILE_NAME:myexe>" - 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}")
|
||||
@@ -572,6 +589,9 @@ macro(deploy_target _T)
|
||||
set(_dt_searchdirs "${_dt_searchdirs}${_dt_delim}${CMAKE_PREFIX_PATH}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
set(_dt_searchdirs "${_dt_searchdirs}${_dt_delim}${CMAKE_PREFIX_PATH}/../lib/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
endif()
|
||||
if (NOT "x${PIP_DEPLOY_LIBDIR}" STREQUAL "x")
|
||||
set(_dt_searchdirs "${_dt_searchdirs}${_dt_delim}${PIP_DEPLOY_LIBDIR}")
|
||||
endif()
|
||||
set(_dt_opts -L "${CMAKE_READELF}" --dpkg-workdir "${CMAKE_DPKG_WORKDIR}" -s "${_dt_searchdirs}")
|
||||
endif()
|
||||
list(APPEND _dt_opts -q "${Qt${_Qt_}_ROOT}" --qt-conf-dir "${_bin_path}" --qt-plugins-dir "${_pli_path}" --rpath)
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# Download and unpack googletest at configure time
|
||||
configure_file(GTestCMakeLists.txt.in googletest-download/CMakeLists.txt)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
endif()
|
||||
|
||||
# Prevent overriding the parent project's compiler/linker
|
||||
# settings on Windows
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
|
||||
# Add googletest directly to our build. This defines
|
||||
# the gtest and gtest_main targets.
|
||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
# The gtest/gtest_main targets carry header search path
|
||||
# dependencies automatically when using CMake 2.8.11 or
|
||||
# later. Otherwise we have to add them here ourselves.
|
||||
if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
include_directories("${gtest_SOURCE_DIR}/include")
|
||||
endif()
|
||||
@@ -313,7 +313,7 @@ macro(shstk_find_header name filename add_find_info)
|
||||
get_filename_component(_inc ${${name}_H_INCLUDE} PATH)
|
||||
set(${name}_INCLUDES "${_inc}" CACHE STRING "")
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(${name}_VERSION_NAME "${${name}_H_INCLUDE}" _${name}_version_found)
|
||||
check_symbol_exists(${${name}_uppercase}_VERSION_NAME "${${name}_H_INCLUDE}" _${name}_version_found)
|
||||
if (_${name}_version_found)
|
||||
file(STRINGS "${${name}_H_INCLUDE}" _version REGEX "^[ \t]*#define[ \t]+${${name}_uppercase}_VERSION_NAME+[ \t]+.*$")
|
||||
string(REGEX MATCH "\".*\"" _version ${_version})
|
||||
|
||||
Reference in New Issue
Block a user