Compare commits
22 Commits
45d7f7054d
...
36073091bc
Author | SHA1 | Date | |
---|---|---|---|
36073091bc | |||
cd3afd21c8 | |||
aa267e4bfc | |||
db4487b798 | |||
156d74f581 | |||
0a2d9a4fce | |||
e57792f316 | |||
bf099295ab | |||
e3e3ecfc3a | |||
f0760fcd11 | |||
6be68e5e51 | |||
f76b9c6758 | |||
d57bbeb634 | |||
abfce824d2 | |||
c9ac3f56ed | |||
499285d23b | |||
a51a6fd9e7 | |||
97ccbf69ac | |||
fc5bbbd4c1 | |||
f630318d67 | |||
29669a2b12 | |||
30bda5c4b6 |
151
.cmake-format
Normal file
151
.cmake-format
Normal file
@@ -0,0 +1,151 @@
|
||||
|
||||
# --------------------------
|
||||
# General Formatting Options
|
||||
# --------------------------
|
||||
# How wide to allow formatted cmake files
|
||||
line_width = 100
|
||||
|
||||
# How many spaces to tab for indent
|
||||
tab_size = 2
|
||||
|
||||
# If arglists are longer than this, break them always
|
||||
max_subargs_per_line = 3
|
||||
|
||||
# If true, separate flow control names from their parentheses with a space
|
||||
separate_ctrl_name_with_space = False
|
||||
|
||||
# If true, separate function names from parentheses with a space
|
||||
separate_fn_name_with_space = False
|
||||
|
||||
# If a statement is wrapped to more than one line, than dangle the closing
|
||||
# parenthesis on it's own line
|
||||
dangle_parens = False
|
||||
|
||||
# If the statement spelling length (including space and parenthesis is larger
|
||||
# than the tab width by more than this amoung, then force reject un-nested
|
||||
# layouts.
|
||||
max_prefix_chars = 2
|
||||
|
||||
# If a candidate layout is wrapped horizontally but it exceeds this many lines,
|
||||
# then reject the layout.
|
||||
max_lines_hwrap = 2
|
||||
|
||||
# What style line endings to use in the output.
|
||||
line_ending = 'unix'
|
||||
|
||||
# Format command names consistently as 'lower' or 'upper' case
|
||||
command_case = 'canonical'
|
||||
|
||||
# Format keywords consistently as 'lower' or 'upper' case
|
||||
keyword_case = 'upper'
|
||||
|
||||
# Specify structure for custom cmake functions
|
||||
additional_commands = {
|
||||
"foo": {
|
||||
"flags": [
|
||||
"BAR",
|
||||
"BAZ"
|
||||
],
|
||||
"kwargs": {
|
||||
"HEADERS": "*",
|
||||
"SOURCES": "*",
|
||||
"DEPENDS": "*"
|
||||
}
|
||||
},
|
||||
"pvs_studio_add_target" : {
|
||||
"flags": [
|
||||
"COMPILE_COMMANDS",
|
||||
"OUTPUT",
|
||||
"HIDE_HELP"
|
||||
],
|
||||
"kwargs": {
|
||||
"TARGET": "*",
|
||||
"DEPENDS": "*",
|
||||
"FORMAT": "*",
|
||||
"CONFIG": "*",
|
||||
"ARGS": "*",
|
||||
"MODE": "*"
|
||||
}
|
||||
},
|
||||
"write_compiler_detection_header" : {
|
||||
"flags": [ ],
|
||||
"kwargs": {
|
||||
"FILE": "*",
|
||||
"PREFIX": "*",
|
||||
"COMPILERS": "*",
|
||||
"FEATURES": "*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# A list of command names which should always be wrapped
|
||||
always_wrap = []
|
||||
|
||||
# Specify the order of wrapping algorithms during successive reflow attempts
|
||||
algorithm_order = [0, 1, 2, 3, 4]
|
||||
|
||||
# If true, the argument lists which are known to be sortable will be sorted
|
||||
# lexicographicall
|
||||
enable_sort = True
|
||||
|
||||
# If true, the parsers may infer whether or not an argument list is sortable
|
||||
# (without annotation).
|
||||
autosort = False
|
||||
|
||||
# If a comment line starts with at least this many consecutive hash characters,
|
||||
# then don't lstrip() them off. This allows for lazy hash rulers where the first
|
||||
# hash char is not separated by space
|
||||
hashruler_min_length = 10
|
||||
|
||||
# A dictionary containing any per-command configuration overrides. Currently
|
||||
# only `command_case` is supported.
|
||||
per_command = {}
|
||||
|
||||
|
||||
# --------------------------
|
||||
# Comment Formatting Options
|
||||
# --------------------------
|
||||
# What character to use for bulleted lists
|
||||
bullet_char = '*'
|
||||
|
||||
# What character to use as punctuation after numerals in an enumerated list
|
||||
enum_char = '.'
|
||||
|
||||
# enable comment markup parsing and reflow
|
||||
enable_markup = False
|
||||
|
||||
# If comment markup is enabled, don't reflow the first comment block in each
|
||||
# listfile. Use this to preserve formatting of your copyright/license
|
||||
# statements.
|
||||
first_comment_is_literal = False
|
||||
|
||||
# If comment markup is enabled, don't reflow any comment block which matches
|
||||
# this (regex) pattern. Default is `None` (disabled).
|
||||
literal_comment_pattern = None
|
||||
|
||||
# Regular expression to match preformat fences in comments
|
||||
# default=r'^\s*([`~]{3}[`~]*)(.*)$'
|
||||
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
|
||||
|
||||
# Regular expression to match rulers in comments
|
||||
# default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'
|
||||
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
|
||||
|
||||
# If true, then insert a space between the first hash char and remaining hash
|
||||
# chars in a hash ruler, and normalize it's length to fill the column
|
||||
canonicalize_hashrulers = True
|
||||
|
||||
|
||||
# ---------------------------------
|
||||
# Miscellaneous Options
|
||||
# ---------------------------------
|
||||
# If true, emit the unicode byte-order mark (BOM) at the start of the file
|
||||
emit_byteorder_mark = False
|
||||
|
||||
# Specify the encoding of the input file. Defaults to utf-8.
|
||||
input_encoding = 'utf-8'
|
||||
|
||||
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
|
||||
# only claims to support utf-8 so be careful when using anything else
|
||||
output_encoding = 'utf-8'
|
||||
|
@@ -1,46 +0,0 @@
|
||||
set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator")
|
||||
set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO)
|
||||
|
||||
find_package(Doxygen)
|
||||
find_package(Perl)
|
||||
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2)
|
||||
find_package(PythonInterp)
|
||||
if (PYTHONINTERP_FOUND)
|
||||
find_package(Sphinx)
|
||||
include(FindPythonModule)
|
||||
find_python_module(breathe)
|
||||
find_python_module(recommonmark)
|
||||
if(DOXYGEN_FOUND AND PERL_FOUND AND PYTHONINTERP_FOUND AND SPHINX_EXECUTABLE AND breathe AND recommonmark)
|
||||
set(BREATHE_FOUND ON CACHE STRING "Breathe documentation generator enabled" FORCE)
|
||||
else()
|
||||
set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE)
|
||||
endif()
|
||||
else()
|
||||
set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE)
|
||||
endif()
|
||||
|
||||
|
||||
function(add_breathe_target)
|
||||
if(BREATHE_FOUND)
|
||||
set(options)
|
||||
set(oneValueArgs SOURCE_DIR BUILD_DIR CACHE_DIR HTML_DIR DOXY_FILE CONF_FILE TARGET_NAME COMMENT)
|
||||
set(multiValueArgs)
|
||||
|
||||
cmake_parse_arguments(_BREATHE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
set(BREATHE_DOCS_BUILD_DIR ${_BREATHE_BUILD_DIR})
|
||||
|
||||
configure_file(${_BREATHE_CONF_FILE} ${_BREATHE_BUILD_DIR}/conf.py @ONLY)
|
||||
configure_file(${_BREATHE_DOXY_FILE} ${_BREATHE_BUILD_DIR}/Doxyfile @ONLY)
|
||||
|
||||
add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM
|
||||
COMMAND ${SPHINX_EXECUTABLE} -q -b html -c ${_BREATHE_BUILD_DIR}
|
||||
-d ${_BREATHE_CACHE_DIR}
|
||||
${_BREATHE_SOURCE_DIR}
|
||||
${_BREATHE_HTML_DIR}
|
||||
COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe"
|
||||
)
|
||||
else()
|
||||
add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM
|
||||
COMMENT "Breathe is not found. Skipping target ${_BREATHE_TARGET_NAME} build")
|
||||
endif()
|
||||
endfunction()
|
@@ -6,7 +6,13 @@ if(CMAKE_CONFIGURATION_TYPES)
|
||||
list(APPEND CMAKE_CONFIGURATION_TYPES Profile)
|
||||
endif()
|
||||
else()
|
||||
set(_allowed_build_types None Debug Release Profile RelWithDebInfo MinSizeRel)
|
||||
set(_allowed_build_types
|
||||
None
|
||||
Debug
|
||||
Release
|
||||
Profile
|
||||
RelWithDebInfo
|
||||
MinSizeRel)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${_allowed_build_types})
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
||||
@@ -17,21 +23,25 @@ endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Profile)
|
||||
# Ключи компиляции для режима профилирования в зависимости от типа компилятора
|
||||
if (CMAKE_CXX_COMPILER_IS_Clang OR CMAKE_CXX_COMPILER_IS_GCC)
|
||||
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -g -p" CACHE STRING "")
|
||||
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -g -p" CACHE STRING "")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -g -p" CACHE STRING "")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" CACHE STRING "")
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_PROFILE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE}" CACHE STRING "")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_PROFILE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -g -p" CACHE STRING "")
|
||||
elseif (CMAKE_CXX_COMPILER_IS_Intel)
|
||||
if(CMAKE_CXX_COMPILER_IS_Clang OR CMAKE_CXX_COMPILER_IS_GCC)
|
||||
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -ggdb -pg" CACHE STRING "")
|
||||
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -ggdb -pg" CACHE STRING "")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "")
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_PROFILE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_PROFILE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "")
|
||||
elseif(CMAKE_CXX_COMPILER_IS_Intel)
|
||||
message("Set options for profiling with Intel C++")
|
||||
elseif (CMAKE_CXX_COMPILER_IS_MSVC)
|
||||
elseif(CMAKE_CXX_COMPILER_IS_MSVC)
|
||||
message("Set options for profiling with Visual Studio C++")
|
||||
endif()
|
||||
set(PROFILE 1)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
# В режиме отладки подробный вывод сообщений компилятора
|
||||
if(CMAKE_CXX_COMPILER_IS_Clang OR CMAKE_CXX_COMPILER_IS_GCC)
|
||||
string(APPEND CMAKE_C_FLAGS_DEBUG " -ggdb")
|
||||
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -ggdb")
|
||||
endif()
|
||||
set(CMAKE_VERBOSE_MAKEFILE 1)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(DEBUG 1)
|
||||
@@ -46,4 +56,3 @@ elseif(CMAKE_BUILD_TYPE STREQUAL None)
|
||||
# set(USE_CPPCHECK ON CACHE BOOL "Use cppcheck")
|
||||
set(USE_PVS_STUDIO ON CACHE BOOL "Use PVS-Studio")
|
||||
endif()
|
||||
|
||||
|
@@ -1,11 +1,12 @@
|
||||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
set(CPACK_SOURCE_GENERATOR TXZ)
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||
set(CPACK_IGNORE_FILE "cmake/etc/cpack_ignore.txt")
|
||||
file(STRINGS ${CPACK_IGNORE_FILE} CPACK_SOURCE_IGNORE_FILES)
|
||||
set_property(DIRECTORY
|
||||
APPEND
|
||||
PROPERTY CMAKE_CONFIGURE_DEPENDS ${CPACK_IGNORE_FILE})
|
||||
|
||||
set(CPACK_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
set(CPACK_TARGET_ARCH "amd64")
|
||||
endif()
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}")
|
||||
|
||||
include(CPack)
|
||||
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
|
||||
|
||||
|
@@ -1,16 +1,19 @@
|
||||
find_program(CLANG_CHECK_EXE
|
||||
NAMES clang-check-10
|
||||
clang-check-9
|
||||
clang-check-8
|
||||
clang-check-7
|
||||
clang-check-6.0
|
||||
clang-check)
|
||||
if(CLANG_CHECK_EXE)
|
||||
option(CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF)
|
||||
endif()
|
||||
|
||||
function(add_clang_analyze_check)
|
||||
list(GET ARGN 0 _target)
|
||||
set(_sources ${ARGN})
|
||||
list(REMOVE_AT _sources 0)
|
||||
|
||||
option(CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF)
|
||||
find_program(CLANG_CHECK_EXE
|
||||
NAMES clang-check-10
|
||||
clang-check-9
|
||||
clang-check-8
|
||||
clang-check-7
|
||||
clang-check-6.0
|
||||
clang-check)
|
||||
if(CLANG_CHECK_EXE)
|
||||
if(CLANG_CHECK_FIX)
|
||||
list(APPEND _args "-fix")
|
||||
@@ -19,8 +22,13 @@ function(add_clang_analyze_check)
|
||||
add_custom_target(clang-analyze-check)
|
||||
endif()
|
||||
add_custom_target(clang-analyze-check-${_target}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLANG_CHECK_EXE} -analyze -extra-arg="-Wno-unknown-warning-option" -p ${CMAKE_BINARY_DIR} ${_sources})
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLANG_CHECK_EXE}
|
||||
-analyze
|
||||
-extra-arg="-Wno-unknown-warning-option"
|
||||
-p
|
||||
${CMAKE_BINARY_DIR}
|
||||
${_sources})
|
||||
add_dependencies(clang-analyze-check-${_target} ${_target})
|
||||
add_dependencies(clang-analyze-check clang-analyze-check-${_target})
|
||||
else()
|
||||
@@ -28,4 +36,3 @@ function(add_clang_analyze_check)
|
||||
message(STATUS " Clang-Check analyzer is not found")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
@@ -1,26 +1,33 @@
|
||||
find_program(CLANG_TIDY_EXE
|
||||
NAMES clang-tidy-10
|
||||
clang-tidy-9
|
||||
clang-tidy-8
|
||||
clang-tidy-7
|
||||
clang-tidy-6.0
|
||||
clang-tidy)
|
||||
if(CLANG_TIDY_EXE)
|
||||
option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF)
|
||||
if(CLANG_TIDY_FIX)
|
||||
list(APPEND _args "-fix")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
function(add_clang_tidy_check)
|
||||
list(GET ARGN 0 _target)
|
||||
set(_sources ${ARGN})
|
||||
list(REMOVE_AT _sources 0)
|
||||
|
||||
option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF)
|
||||
find_program(CLANG_TIDY_EXE
|
||||
NAMES clang-tidy-10
|
||||
clang-tidy-9
|
||||
clang-tidy-8
|
||||
clang-tidy-7
|
||||
clang-tidy-6.0
|
||||
clang-tidy)
|
||||
if(CLANG_TIDY_EXE)
|
||||
if(CLANG_TIDY_FIX)
|
||||
list(APPEND _args "-fix")
|
||||
endif()
|
||||
if(NOT TARGET clang-tidy-check)
|
||||
add_custom_target(clang-tidy-check)
|
||||
endif()
|
||||
add_custom_target(clang-tidy-check-${_target}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLANG_TIDY_EXE} -extra-arg="-Wno-unknown-warning-option" -p ${CMAKE_BINARY_DIR} ${_sources})
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLANG_TIDY_EXE}
|
||||
-extra-arg="-Wno-unknown-warning-option"
|
||||
-p
|
||||
${CMAKE_BINARY_DIR}
|
||||
${_sources})
|
||||
add_dependencies(clang-tidy-check-${_target} ${_target})
|
||||
add_dependencies(clang-tidy-check clang-tidy-check-${_target})
|
||||
else()
|
||||
@@ -28,4 +35,3 @@ function(add_clang_tidy_check)
|
||||
message(STATUS " ClangTidy analyzer is not found")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
@@ -1,17 +1,23 @@
|
||||
set(clazy_checks container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,isempty-vs-count,qt-keywords,unneeded-cast)
|
||||
|
||||
function(add_clazy_check)
|
||||
list(GET ARGN 0 _target)
|
||||
set(_sources ${ARGN})
|
||||
list(REMOVE_AT _sources 0)
|
||||
|
||||
find_program(CLAZY_EXE
|
||||
NAMES clazy-standalone)
|
||||
find_program(CLAZY_EXE NAMES clazy-standalone)
|
||||
if(CLAZY_EXE)
|
||||
if(NOT TARGET clazy-check)
|
||||
add_custom_target(clazy-check)
|
||||
endif()
|
||||
add_custom_target(clazy-check-${_target}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLAZY_EXE} -checks=level2 -extra-arg="-Wno-unknown-warning-option" -p ${CMAKE_BINARY_DIR} ${_sources})
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLAZY_EXE}
|
||||
-checks=level2,${clazy_checks}
|
||||
-extra-arg="-Wno-unknown-warning-option"
|
||||
-p
|
||||
${CMAKE_BINARY_DIR}
|
||||
${_sources})
|
||||
add_dependencies(clazy-check-${_target} ${_target})
|
||||
add_dependencies(clazy-check clazy-check-${_target})
|
||||
else()
|
||||
@@ -19,4 +25,3 @@ function(add_clazy_check)
|
||||
message(STATUS " Clazy analyzer is not found")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
function(add_pvs_check)
|
||||
list(GET ARGN 0 _target)
|
||||
|
||||
if (CMAKE_EXPORT_COMPILE_COMMANDS)
|
||||
if(CMAKE_EXPORT_COMPILE_COMMANDS)
|
||||
include(PVS-Studio)
|
||||
find_program(PVS_STUDIO_ANALYZER_EXE NAMES pvs-studio-analyzer)
|
||||
if(PVS_STUDIO_ANALYZER_EXE)
|
||||
@@ -10,12 +10,13 @@ function(add_pvs_check)
|
||||
endif()
|
||||
pvs_studio_add_target(TARGET pvs-check-${_target}
|
||||
DEPENDS ${_target}
|
||||
COMPILE_COMMANDS
|
||||
HIDE_HELP
|
||||
OUTPUT FORMAT errorfile
|
||||
COMPILE_COMMANDS HIDE_HELP OUTPUT
|
||||
FORMAT errorfile
|
||||
CONFIG "${CMAKE_BINARY_DIR}/PVS-Studio-${_target}.cfg"
|
||||
ARGS --analysis-mode 29
|
||||
--exclude-path ${CMAKE_CURRENT_BINARY_DIR}/${_target}_autogen
|
||||
ARGS --analysis-mode
|
||||
29
|
||||
--exclude-path
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${_target}_autogen
|
||||
MODE GA:1,2,3;64:1;OP:1,2;CS:1,2)
|
||||
add_dependencies(pvs-check pvs-check-${_target})
|
||||
else()
|
||||
@@ -24,7 +25,7 @@ function(add_pvs_check)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "CMLIB warning:")
|
||||
message(STATUS " Option CMAKE_EXPORT_COMPILE_COMMANDS is not set. PVS checks will be disabled.")
|
||||
message(
|
||||
STATUS " Option CMAKE_EXPORT_COMPILE_COMMANDS is not set. PVS checks will be disabled.")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
42
CMLibCodeCoverage.cmake
Normal file
42
CMLibCodeCoverage.cmake
Normal file
@@ -0,0 +1,42 @@
|
||||
option(ENABLE_CODE_COVERAGE "Enable code coverage support" OFF)
|
||||
find_program(LCOV_EXE NAMES lcov)
|
||||
find_program(GENHTML_EXE NAMES genhtml)
|
||||
|
||||
function(add_code_coverage)
|
||||
list(GET ARGN 0 _target)
|
||||
|
||||
if(ENABLE_CODE_COVERAGE)
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC)
|
||||
target_compile_options(${_target} PUBLIC "--coverage")
|
||||
get_target_property(LF ${_target} LINK_FLAGS)
|
||||
string(APPEND LF " --coverage")
|
||||
set_target_properties(${_target} PROPERTIES LINK_FLAGS ${LF})
|
||||
|
||||
if(LCOV_EXE)
|
||||
add_custom_target(coverage-${_target}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${LCOV_EXE}
|
||||
--test-name
|
||||
${_target}
|
||||
--output
|
||||
"${_target}.lcov"
|
||||
--capture
|
||||
--directory
|
||||
${CMAKE_BINARY_DIR})
|
||||
add_dependencies(coverage-${_target} ${_target})
|
||||
|
||||
if(GENHTML_EXE)
|
||||
add_custom_target(coverage-report-${_target}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${GENHTML_EXE}
|
||||
--output-directory
|
||||
"report-${_target}"
|
||||
"${_target}.lcov")
|
||||
add_dependencies(coverage-report-${_target} coverage-${_target})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message("Only GCC is supported for code coverage")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
@@ -18,9 +18,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
include(CMLibProjectVersion)
|
||||
set_project_version()
|
||||
|
||||
include(CMLibOrganizationName)
|
||||
set_organization_name()
|
||||
|
||||
include(CMLibRequiredVariables)
|
||||
include(CMLibGlobalVariables)
|
||||
include(CMLibLSBInfo)
|
||||
include(CMLibCompiler)
|
||||
@@ -35,15 +33,15 @@ include(CMLibCodeAnalysisPvsStudio)
|
||||
include(CMLibCodeAnalysisClangAnalyze)
|
||||
include(CMLibCodeAnalysisClangTidy)
|
||||
include(CMLibCodeAnalysisClazy)
|
||||
include(CMLibCodeCoverage)
|
||||
include(CMLibSanitizers)
|
||||
include(cotire)
|
||||
|
||||
include(CMLibFormatSources)
|
||||
include(CMLibDoxygen)
|
||||
include(CMLibBreathe)
|
||||
include(CMLibDocDoxygen)
|
||||
include(CMLibDocBreathe)
|
||||
include(CMLibQtTranslation)
|
||||
include(CMLibToday)
|
||||
include(CMLibConfigHPPGenerate)
|
||||
include(CMLibCPackSources)
|
||||
include(CMLibUninstall)
|
||||
|
||||
|
@@ -4,45 +4,51 @@ function(add_common_library)
|
||||
set(oneValueArgs TARGET OUTPUT_NAME)
|
||||
set(multiValueArgs SOURCES)
|
||||
|
||||
cmake_parse_arguments(_LOCAL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
cmake_parse_arguments(_LOCAL
|
||||
"${options}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
set(LIBNAME ${_LOCAL_TARGET})
|
||||
set(SOURCES ${_LOCAL_SOURCES})
|
||||
|
||||
if (_LOCAL_OUTPUT_NAME)
|
||||
if(_LOCAL_OUTPUT_NAME)
|
||||
set(OUTNAME ${_LOCAL_OUTPUT_NAME})
|
||||
else()
|
||||
set(OUTNAME ${LIBNAME})
|
||||
endif()
|
||||
|
||||
add_library(${LIBNAME} OBJECT ${SOURCES})
|
||||
target_include_directories(
|
||||
${LIBNAME}
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include/${LIBNAME}>)
|
||||
target_include_directories(${LIBNAME}
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include/${LIBNAME}>)
|
||||
set_target_properties(${LIBNAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_library(${LIBNAME}_shared SHARED $<TARGET_OBJECTS:${LIBNAME}>)
|
||||
set_target_properties(${LIBNAME}_shared
|
||||
PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
OUTPUT_NAME ${OUTNAME}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
|
||||
PROPERTIES VERSION
|
||||
${PROJECT_VERSION}
|
||||
SOVERSION
|
||||
${PROJECT_VERSION_MAJOR}
|
||||
OUTPUT_NAME
|
||||
${OUTNAME}
|
||||
LIBRARY_OUTPUT_DIRECTORY
|
||||
${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS ${LIBNAME}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_STATIC_LIBS)
|
||||
add_library(${LIBNAME}_static STATIC $<TARGET_OBJECTS:${LIBNAME}>)
|
||||
set_target_properties(${LIBNAME}_static
|
||||
PROPERTIES
|
||||
OUTPUT_NAME ${OUTNAME}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
|
||||
PROPERTIES OUTPUT_NAME
|
||||
${OUTNAME}
|
||||
ARCHIVE_OUTPUT_DIRECTORY
|
||||
${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS ${LIBNAME}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${LIBNAME}.pc)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/${LIBNAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
endfunction()
|
||||
|
||||
|
@@ -9,39 +9,78 @@ function(common_target_properties Name)
|
||||
endif()
|
||||
target_compile_features(${Name} ${__visibility} ${COMMON_CXX_FEATURES})
|
||||
get_target_property(_targetType ${Name} TYPE)
|
||||
if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_CXX_COMPILE_OPTIONS_PIE)
|
||||
if(_targetType STREQUAL "EXECUTABLE" AND CMAKE_CXX_COMPILE_OPTIONS_PIE)
|
||||
target_compile_options(${Name} PUBLIC "${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
|
||||
endif()
|
||||
target_include_directories(
|
||||
${Name}
|
||||
PUBLIC $<INSTALL_INTERFACE:include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
|
||||
target_include_directories(${Name}
|
||||
PUBLIC $<INSTALL_INTERFACE:include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
|
||||
if(APPLE)
|
||||
target_compile_definitions(${Name} ${__visibility} Darwin)
|
||||
endif()
|
||||
if(NOT __interface)
|
||||
if(TARGET Qt5::Core)
|
||||
if (_targetType STREQUAL "EXECUTABLE")
|
||||
if(_targetType STREQUAL "EXECUTABLE")
|
||||
target_compile_options(${Name} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
|
||||
endif()
|
||||
set_target_properties(${Name} PROPERTIES AUTOMOC TRUE AUTORCC TRUE)
|
||||
set_target_properties(${Name}
|
||||
PROPERTIES AUTOMOC
|
||||
TRUE
|
||||
AUTORCC
|
||||
TRUE)
|
||||
endif()
|
||||
if(TARGET Qt5::Widgets)
|
||||
set_target_properties(${Name} PROPERTIES AUTOUIC TRUE)
|
||||
# if(CMAKE_VERSION VERSION_LESS 3.7.99)
|
||||
# target_include_directories(
|
||||
# ${Name}
|
||||
# PUBLIC
|
||||
# $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${Name}_autogen/include>
|
||||
# )
|
||||
# endif()
|
||||
# if(CMAKE_VERSION VERSION_LESS 3.7.99)
|
||||
# target_include_directories(
|
||||
# ${Name}
|
||||
# PUBLIC
|
||||
# $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${Name}_autogen/include>
|
||||
# )
|
||||
# endif()
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE)
|
||||
set_target_properties(${Name} PROPERTIES LINK_FLAGS "-Wl,--no-as-needed")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
# LTO only for executables (not libraries) in Release build type
|
||||
get_target_property(target_type ${Name} TYPE)
|
||||
if(target_type STREQUAL "EXECUTABLE" AND CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
check_cxx_compiler_flag(-flto CXX_HAS_LTO_FLAG)
|
||||
check_cxx_compiler_flag(-fno-fat-lto-objects CXX_HAS_NO_FAT_LTO_FLAG)
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC AND CXX_HAS_LTO_FLAG)
|
||||
find_program(CMAKE_GCC_AR
|
||||
NAMES "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_TOOLCHAIN_SUFFIX}"
|
||||
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar"
|
||||
HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
|
||||
find_program(CMAKE_GCC_NM
|
||||
NAMES "${_CMAKE_TOOLCHAIN_PREFIX}gcc-nm${_CMAKE_TOOLCHAIN_SUFFIX}"
|
||||
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-nm"
|
||||
HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
|
||||
find_program(CMAKE_GCC_RANLIB
|
||||
NAMES "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib${_CMAKE_TOOLCHAIN_SUFFIX}"
|
||||
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib"
|
||||
HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
|
||||
if(CMAKE_GCC_AR AND CMAKE_GCC_NM AND CMAKE_GCC_RANLIB)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
|
||||
if(CXX_HAS_NO_FAT_LTO_FLAG)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-fat-lto-objects")
|
||||
endif()
|
||||
set(CMAKE_AR "${CMAKE_GCC_AR}")
|
||||
set(CMAKE_NM "${CMAKE_GCC_NM}")
|
||||
set(CMAKE_RANLIB "${CMAKE_GCC_RANLIB}")
|
||||
else()
|
||||
message(
|
||||
WARNING
|
||||
"GCC indicates LTO support, but binutils wrappers could not be found. Disabling LTO.")
|
||||
endif()
|
||||
else()
|
||||
check_enable_compiler_flag(-flto)
|
||||
check_enable_compiler_flag(-fno-fat-lto-objects)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
@@ -1,8 +1,7 @@
|
||||
# C compiler name
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Intel")
|
||||
set(CMAKE_C_COMPILER_IS_INTEL ON)
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang"
|
||||
OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||
set(CMAKE_C_COMPILER_IS_CLANG ON)
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_C_COMPILER_IS_GCC ON)
|
||||
@@ -13,12 +12,10 @@ endif()
|
||||
# C++ compiler name
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
set(CMAKE_CXX_COMPILER_IS_INTEL ON)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
|
||||
OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
set(CMAKE_CXX_COMPILER_IS_CLANG ON)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_COMPILER_IS_GCC ON)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
set(CMAKE_CXX_COMPILER_IS_MSVC ON)
|
||||
endif()
|
||||
|
||||
|
@@ -1,18 +1,17 @@
|
||||
include(WriteCompilerDetectionHeader)
|
||||
|
||||
write_compiler_detection_header(
|
||||
FILE include/compiler_features.hpp
|
||||
PREFIX ${CMLIB_PROJECT_NAME_CANONICAL}
|
||||
COMPILERS GNU Clang MSVC Intel
|
||||
FEATURES
|
||||
cxx_nullptr
|
||||
cxx_override
|
||||
cxx_alignas
|
||||
cxx_alignof
|
||||
cxx_attributes
|
||||
cxx_auto_type
|
||||
cxx_constexpr
|
||||
cxx_digit_separators
|
||||
cxx_range_for
|
||||
)
|
||||
|
||||
write_compiler_detection_header(FILE include/compiler_features.hpp
|
||||
PREFIX ${CMLIB_PROJECT_NAME_CANONICAL}
|
||||
COMPILERS GNU
|
||||
Clang
|
||||
MSVC
|
||||
Intel
|
||||
FEATURES cxx_nullptr
|
||||
cxx_override
|
||||
cxx_alignas
|
||||
cxx_alignof
|
||||
cxx_attributes
|
||||
cxx_auto_type
|
||||
cxx_constexpr
|
||||
cxx_digit_separators
|
||||
cxx_range_for)
|
||||
|
@@ -17,10 +17,21 @@ macro(CHECK_ENABLE_CXX_FLAG flag)
|
||||
unset(CHECK_CXX_FLAG CACHE)
|
||||
endmacro()
|
||||
|
||||
if(LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE"
|
||||
AND LSB_CODENAME STREQUAL "smolensk"
|
||||
AND LSB_RELEASE STREQUAL "1.5")
|
||||
set(_CMAKE_TOOLCHAIN_PREFIX "x86_64-linux-gnu-")
|
||||
set(_CMAKE_TOOLCHAIN_SUFFIX "-4.7")
|
||||
set(_CMAKE_TOOLCHAIN_LOCATION} "/usr/bin")
|
||||
else()
|
||||
# -Wshadow gives a lot of false positives with GCC 4.7.2 in Astra Linux 1.5
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC)
|
||||
check_enable_cxx_flag(-Wshadow)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Common configuration for GCC, clang and Intel.
|
||||
if(CMAKE_CXX_COMPILER_IS_CLANG
|
||||
OR CMAKE_CXX_COMPILER_IS_INTEL
|
||||
OR CMAKE_CXX_COMPILER_IS_GCC)
|
||||
if(CMAKE_CXX_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_IS_INTEL OR CMAKE_CXX_COMPILER_IS_GCC)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
||||
set(CMAKE_CXX_EXTENSIONS YES)
|
||||
@@ -86,30 +97,6 @@ if(CMAKE_CXX_COMPILER_IS_CLANG
|
||||
check_enable_cxx_flag(-Wstrict-null-sentinel)
|
||||
check_enable_cxx_flag(-Wshadow-all)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
check_cxx_compiler_flag(-flto CXX_HAS_LTO_FLAG)
|
||||
check_cxx_compiler_flag(-fno-fat-lto-objects CXX_HAS_NO_FAT_LTO_FLAG)
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC AND CXX_HAS_LTO_FLAG)
|
||||
find_program(CMAKE_GCC_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
|
||||
find_program(CMAKE_GCC_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
|
||||
find_program(CMAKE_GCC_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
|
||||
if(CMAKE_GCC_AR AND CMAKE_GCC_NM AND CMAKE_GCC_RANLIB)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
|
||||
if(CXX_HAS_NO_FAT_LTO_FLAG)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-fat-lto-objects")
|
||||
endif()
|
||||
set(CMAKE_AR "${CMAKE_GCC_AR}")
|
||||
set(CMAKE_NM "${CMAKE_GCC_NM}")
|
||||
set(CMAKE_RANLIB "${CMAKE_GCC_RANLIB}")
|
||||
else()
|
||||
message(WARNING "GCC indicates LTO support, but binutils wrappers could not be found. Disabling LTO.")
|
||||
endif()
|
||||
else()
|
||||
check_enable_compiler_flag(-flto)
|
||||
check_enable_compiler_flag(-fno-fat-lto-objects)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC)
|
||||
@@ -125,10 +112,6 @@ if(CMAKE_CXX_COMPILER_IS_GCC)
|
||||
# Let's just disable the warning for now.
|
||||
check_enable_cxx_flag(-Wno-attributes)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.799")
|
||||
# -Wshadow gives a lot of false positives with GCC 4.7.2 in Astra Linux 1.5
|
||||
check_enable_cxx_flag(-Wshadow)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k")
|
||||
@@ -136,4 +119,3 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k")
|
||||
add_definitions(-DQT_NO_VERSION_TAGGING)
|
||||
list(APPEND CMAKE_LIBRARY_PATH "/usr/lib/e2k-linux-gnu")
|
||||
endif()
|
||||
|
||||
|
@@ -3,7 +3,6 @@ function(cmlib_config_hpp_generate)
|
||||
cmlib_test_large_files(HAVE_LARGEFILES)
|
||||
|
||||
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
|
||||
get_property(ORGANIZATION_NAME GLOBAL PROPERTY ORGANIZATION_NAME)
|
||||
string(TOLOWER ${ORGANIZATION_NAME} ORGANIZATION_NAME_LOWER)
|
||||
string(TOUPPER ${ORGANIZATION_NAME} ORGANIZATION_NAME_UPPER)
|
||||
string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_LOWER)
|
||||
|
@@ -17,11 +17,11 @@ file(GLOB_RECURSE _cmakelists_files RELATIVE ${_source_realpath} CMakeLists.txt)
|
||||
foreach(_it ${_cmakelists_files})
|
||||
get_filename_component(_file ${_it} REALPATH)
|
||||
get_filename_component(_dir ${_file} DIRECTORY)
|
||||
file(REMOVE_RECURSE ${_dir}/CMakeFiles
|
||||
${_dir}/CMakeCache.txt
|
||||
${_dir}/cmake_install.cmake
|
||||
${_dir}/Makefile
|
||||
${_dir}/build.ninja
|
||||
${_dir}/rules.ninja)
|
||||
file(REMOVE_RECURSE
|
||||
${_dir}/CMakeFiles
|
||||
${_dir}/CMakeCache.txt
|
||||
${_dir}/cmake_install.cmake
|
||||
${_dir}/Makefile
|
||||
${_dir}/build.ninja
|
||||
${_dir}/rules.ninja)
|
||||
endforeach()
|
||||
|
||||
|
@@ -2,7 +2,8 @@ find_program(DISTCC_EXECUTABLE distcc)
|
||||
mark_as_advanced(DISTCC_EXECUTABLE)
|
||||
if(DISTCC_EXECUTABLE)
|
||||
foreach(LANG C CXX)
|
||||
if(NOT DEFINED CMAKE_${LANG}_COMPILER_LAUNCHER AND NOT CMAKE_${LANG}_COMPILER MATCHES ".*/distcc$")
|
||||
if(NOT DEFINED CMAKE_${LANG}_COMPILER_LAUNCHER
|
||||
AND NOT CMAKE_${LANG}_COMPILER MATCHES ".*/distcc$")
|
||||
message(STATUS "Enabling distcc for ${LANG}")
|
||||
set(CMAKE_${LANG}_COMPILER_LAUNCHER ${DISTCC_EXECUTABLE} CACHE STRING "")
|
||||
endif()
|
||||
|
80
CMLibDocBreathe.cmake
Normal file
80
CMLibDocBreathe.cmake
Normal file
@@ -0,0 +1,80 @@
|
||||
set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator")
|
||||
set_property(CACHE BREATHE_FOUND
|
||||
PROPERTY STRINGS
|
||||
ON
|
||||
OFF
|
||||
AUTO)
|
||||
|
||||
find_package(Doxygen)
|
||||
find_package(Perl)
|
||||
set(Python_ADDITIONAL_VERSIONS
|
||||
3.7
|
||||
3.6
|
||||
3.5
|
||||
3.4
|
||||
3.3
|
||||
3.2)
|
||||
find_package(PythonInterp)
|
||||
if(PYTHONINTERP_FOUND)
|
||||
find_package(Sphinx)
|
||||
include(FindPythonModule)
|
||||
find_python_module(breathe)
|
||||
find_python_module(recommonmark)
|
||||
if(DOXYGEN_FOUND
|
||||
AND PERL_FOUND
|
||||
AND PYTHONINTERP_FOUND
|
||||
AND SPHINX_EXECUTABLE
|
||||
AND breathe
|
||||
AND recommonmark)
|
||||
set(BREATHE_FOUND ON CACHE STRING "Breathe documentation generator enabled" FORCE)
|
||||
else()
|
||||
set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE)
|
||||
endif()
|
||||
else()
|
||||
set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE)
|
||||
endif()
|
||||
|
||||
function(add_breathe_target)
|
||||
set(options)
|
||||
set(oneValueArgs
|
||||
TARGET_NAME
|
||||
SOURCE_DIR
|
||||
DOXY_FILE
|
||||
CONF_FILE
|
||||
OUTPUT_DIR
|
||||
COMMENT)
|
||||
set(multiValueArgs)
|
||||
|
||||
cmake_parse_arguments(_BREATHE
|
||||
"${options}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
if(BREATHE_FOUND)
|
||||
set(WORK_DIR ${CMAKE_BINARY_DIR}/_breathe)
|
||||
set(BREATHE_DOCS_BUILD_DIR ${WORK_DIR})
|
||||
set(GENERATE_XML YES)
|
||||
set(GENERATE_HTML NO)
|
||||
set(GENERATE_LATEX NO)
|
||||
set(OUTPUT_DIRECTORY ${WORK_DIR})
|
||||
|
||||
configure_file(${_BREATHE_CONF_FILE} ${WORK_DIR}/conf.py @ONLY)
|
||||
configure_file(${_BREATHE_DOXY_FILE} ${WORK_DIR}/Doxyfile @ONLY)
|
||||
|
||||
add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM
|
||||
COMMAND ${SPHINX_EXECUTABLE}
|
||||
-q
|
||||
-b
|
||||
html
|
||||
-c
|
||||
${WORK_DIR}
|
||||
-d
|
||||
${WORK_DIR}/cache
|
||||
${_BREATHE_SOURCE_DIR}
|
||||
${_BREATHE_OUTPUT_DIR}
|
||||
COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe")
|
||||
else()
|
||||
add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM
|
||||
COMMENT "Breathe is not found. Skipping target ${_BREATHE_TARGET_NAME} build")
|
||||
endif()
|
||||
endfunction()
|
55
CMLibDocDoxygen.cmake
Normal file
55
CMLibDocDoxygen.cmake
Normal file
@@ -0,0 +1,55 @@
|
||||
set(DOXYGEN_FOUND AUTO CACHE STRING "Enable Doxygen documentation generator")
|
||||
set_property(CACHE DOXYGEN_FOUND
|
||||
PROPERTY STRINGS
|
||||
ON
|
||||
OFF
|
||||
AUTO)
|
||||
|
||||
find_package(Doxygen)
|
||||
if(DOXYGEN_FOUND)
|
||||
set(DOXYGEN_FOUND ON CACHE STRING "Doxygen documentation generator enabled" FORCE)
|
||||
else()
|
||||
set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE)
|
||||
endif()
|
||||
|
||||
function(add_doxygen_target)
|
||||
set(options)
|
||||
set(oneValueArgs
|
||||
TARGET_NAME
|
||||
SOURCE_DIR
|
||||
DOXY_FILE
|
||||
OUTPUT_DIR
|
||||
LATEX
|
||||
HTML)
|
||||
set(multiValueArgs)
|
||||
|
||||
cmake_parse_arguments(_DOXYGEN
|
||||
"${options}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
if(DOXYGEN_FOUND)
|
||||
set(GENERATE_XML NO)
|
||||
set(GENERATE_HTML NO)
|
||||
set(GENERATE_LATEX NO)
|
||||
set(OUTPUT_DIRECTORY ${_DOXYGEN_OUTPUT_DIR})
|
||||
set(SOURCE_DIR ${_DOXYGEN_SOURCE_DIR})
|
||||
if(_DOXYGEN_HTML)
|
||||
set(GENERATE_HTML YES)
|
||||
endif()
|
||||
if(_DOXYGEN_LATEX)
|
||||
set(GENERATE_LATEX YES)
|
||||
endif()
|
||||
|
||||
set(WORK_DIR ${CMAKE_BINARY_DIR}/_doxygen)
|
||||
configure_file(${_DOXYGEN_DOXY_FILE} ${WORK_DIR}/Doxyfile @ONLY)
|
||||
|
||||
add_custom_target(${_DOXYGEN_TARGET_NAME} VERBATIM
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${WORK_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${WORK_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen")
|
||||
else()
|
||||
add_custom_target(${_DOXYGEN_TARGET_NAME} VERBATIM
|
||||
COMMENT "Doxygen is not found. Skipping target ${_DOXYGEN_TARGET_NAME} build")
|
||||
endif()
|
||||
endfunction()
|
@@ -1,32 +0,0 @@
|
||||
set(DOXYGEN_FOUND AUTO CACHE STRING "Enable Doxygen documentation generator")
|
||||
set_property(CACHE DOXYGEN_FOUND PROPERTY STRINGS ON OFF AUTO)
|
||||
|
||||
find_package(Doxygen)
|
||||
if (DOXYGEN_FOUND)
|
||||
set(DOXYGEN_FOUND ON CACHE STRING "Doxygen documentation generator enabled" FORCE)
|
||||
else()
|
||||
set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE)
|
||||
endif()
|
||||
|
||||
|
||||
function(add_doxygen_target)
|
||||
if (DOXYGEN_FOUND)
|
||||
set(options)
|
||||
set(oneValueArgs TARGET_NAME IN OUT)
|
||||
set(multiValueArgs)
|
||||
|
||||
cmake_parse_arguments(_DOXYGEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
configure_file(${_DOXYGEN_IN} ${_DOXYGEN_OUT} @ONLY)
|
||||
message("Doxygen build started")
|
||||
|
||||
add_custom_target(${_DOXYGEN_TARGET_NAME} VERBATIM
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen"
|
||||
VERBATIM)
|
||||
else()
|
||||
add_custom_target(${_DOXYGEN_TARGET_NAME} VERBATIM
|
||||
COMMENT "Doxygen is not found. Skipping target ${_BREATHE_TARGET_NAME} build")
|
||||
endif()
|
||||
endfunction()
|
@@ -10,8 +10,7 @@ macro(remove_flag_from_target _target _flag)
|
||||
get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS)
|
||||
if(_target_cxx_flags)
|
||||
list(REMOVE_ITEM _target_cxx_flags ${_flag})
|
||||
set_target_properties(${_target}
|
||||
PROPERTIES COMPILE_OPTIONS "${_target_cxx_flags}")
|
||||
set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${_target_cxx_flags}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -23,7 +22,10 @@ endmacro()
|
||||
#
|
||||
# Pre: apply_global_cxx_flags_to_all_targets() must be invoked.
|
||||
#
|
||||
macro(remove_flag_from_file _target _file _flag)
|
||||
macro(remove_flag_from_file
|
||||
_target
|
||||
_file
|
||||
_flag)
|
||||
get_target_property(_target_sources ${_target} SOURCES)
|
||||
# Check if a sync is required, in which case we'll force a rewrite of the cache variables.
|
||||
if(_flag_sync_required)
|
||||
@@ -41,19 +43,21 @@ macro(remove_flag_from_file _target _file _flag)
|
||||
# Apply the target compile flags to each source file.
|
||||
foreach(_source_file ${_target_sources})
|
||||
# Check for pre-existing flags set by set_source_files_properties().
|
||||
get_source_file_property(_source_file_cxx_flags ${_source_file}
|
||||
COMPILE_FLAGS)
|
||||
get_source_file_property(_source_file_cxx_flags ${_source_file} COMPILE_FLAGS)
|
||||
if(_source_file_cxx_flags)
|
||||
separate_arguments(_source_file_cxx_flags UNIX_COMMAND
|
||||
${_source_file_cxx_flags})
|
||||
separate_arguments(_source_file_cxx_flags UNIX_COMMAND ${_source_file_cxx_flags})
|
||||
list(APPEND _source_file_cxx_flags "${_target_cxx_flags}")
|
||||
else()
|
||||
set(_source_file_cxx_flags "${_target_cxx_flags}")
|
||||
endif()
|
||||
# Apply the compile flags to the current source file.
|
||||
string(REPLACE ";" " " _source_file_cxx_flags_string
|
||||
string(REPLACE ";"
|
||||
" "
|
||||
_source_file_cxx_flags_string
|
||||
"${_source_file_cxx_flags}")
|
||||
set_source_files_properties(${_source_file} PROPERTIES COMPILE_FLAGS
|
||||
set_source_files_properties(${_source_file}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS
|
||||
"${_source_file_cxx_flags_string}")
|
||||
endforeach()
|
||||
endif()
|
||||
@@ -63,18 +67,18 @@ macro(remove_flag_from_file _target _file _flag)
|
||||
# Cache the compile flags for the specified file.
|
||||
# This is the list that we'll be removing flags from.
|
||||
get_source_file_property(_source_file_cxx_flags ${_file} COMPILE_FLAGS)
|
||||
separate_arguments(_source_file_cxx_flags UNIX_COMMAND
|
||||
${_source_file_cxx_flags})
|
||||
set(_cached_${_target}_${_file}_cxx_flags ${_source_file_cxx_flags}
|
||||
CACHE INTERNAL "")
|
||||
separate_arguments(_source_file_cxx_flags UNIX_COMMAND ${_source_file_cxx_flags})
|
||||
set(_cached_${_target}_${_file}_cxx_flags ${_source_file_cxx_flags} CACHE INTERNAL "")
|
||||
endif()
|
||||
# Remove the specified flag, then re-apply the rest.
|
||||
list(REMOVE_ITEM _cached_${_target}_${_file}_cxx_flags ${_flag})
|
||||
string(REPLACE ";" " " _cached_${_target}_${_file}_cxx_flags_string
|
||||
string(REPLACE ";"
|
||||
" "
|
||||
_cached_${_target}_${_file}_cxx_flags_string
|
||||
"${_cached_${_target}_${_file}_cxx_flags}")
|
||||
set_source_files_properties(
|
||||
${_file} PROPERTIES COMPILE_FLAGS
|
||||
"${_cached_${_target}_${_file}_cxx_flags_string}")
|
||||
set_source_files_properties(${_file}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS
|
||||
"${_cached_${_target}_${_file}_cxx_flags_string}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
@@ -8,12 +8,14 @@ function(add_uncrustify_format)
|
||||
if(NOT TARGET uncrustify-format)
|
||||
add_custom_target(uncrustify-format)
|
||||
endif()
|
||||
list(APPEND OPTS -lCPP --replace --no-backup)
|
||||
list(APPEND OPTS
|
||||
-lCPP
|
||||
--replace
|
||||
--no-backup)
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg)
|
||||
list(APPEND OPTS -c ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg)
|
||||
endif()
|
||||
add_custom_target(uncrustify-format-${_target}
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${OPTS} ${_sources})
|
||||
add_custom_target(uncrustify-format-${_target} COMMAND ${UNCRUSTIFY_EXE} ${OPTS} ${_sources})
|
||||
add_dependencies(uncrustify-format uncrustify-format-${_target})
|
||||
else()
|
||||
message(STATUS "CMLIB warning:")
|
||||
|
@@ -1,6 +1,10 @@
|
||||
# CMLIB_PROJECT_NAME_CANONICAL
|
||||
string(TOUPPER ${PROJECT_NAME} _project_name_uppercase)
|
||||
string(REGEX REPLACE "[ -]" "_" _project_name_fixed ${_project_name_uppercase})
|
||||
string(REGEX
|
||||
REPLACE "[ -]"
|
||||
"_"
|
||||
_project_name_fixed
|
||||
${_project_name_uppercase})
|
||||
set(CMLIB_PROJECT_NAME_CANONICAL ${_project_name_fixed})
|
||||
|
||||
# CMLIB_MODULE_DIR
|
||||
@@ -19,4 +23,3 @@ if(IS_DIRECTORY "${CMLIB_MODULE_DIR}")
|
||||
else()
|
||||
message(FATAL_ERROR "CMLib directory not found.")
|
||||
endif()
|
||||
|
||||
|
@@ -10,7 +10,7 @@ set(LSB_DISTRIBUTOR_ID "unknown")
|
||||
set(LSB_CODENAME "unknown")
|
||||
set(LSB_RELEASE "unknown")
|
||||
|
||||
if (EXISTS /etc/mcst_version)
|
||||
if(EXISTS /etc/mcst_version)
|
||||
set(LSB_DISTRIBUTOR_ID "ElbrusD")
|
||||
set(LSB_CODENAME "Jessie")
|
||||
execute_process(COMMAND cat /etc/mcst_version
|
||||
@@ -32,4 +32,3 @@ else()
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@@ -51,79 +51,75 @@
|
||||
|
||||
include(CheckTypeSize)
|
||||
|
||||
MACRO(cmlib_test_large_files VARIABLE)
|
||||
IF(NOT DEFINED ${VARIABLE})
|
||||
macro(cmlib_test_large_files VARIABLE)
|
||||
if(NOT DEFINED ${VARIABLE})
|
||||
|
||||
# On most platforms it is probably overkill to first test the flags for 64-bit off_t,
|
||||
# and then separately fseeko. However, in the future we might have 128-bit filesystems
|
||||
# (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64.
|
||||
|
||||
MESSAGE(STATUS "Checking for 64-bit off_t")
|
||||
message(STATUS "Checking for 64-bit off_t")
|
||||
|
||||
# First check without any special flags
|
||||
TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}"
|
||||
"${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c")
|
||||
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c")
|
||||
if(FILE64_OK)
|
||||
MESSAGE(STATUS "Checking for 64-bit off_t - present")
|
||||
message(STATUS "Checking for 64-bit off_t - present")
|
||||
endif()
|
||||
|
||||
if(NOT FILE64_OK)
|
||||
# Test with _FILE_OFFSET_BITS=64
|
||||
TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}"
|
||||
"${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c"
|
||||
COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" )
|
||||
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c"
|
||||
COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
|
||||
if(FILE64_OK)
|
||||
MESSAGE(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
|
||||
message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
|
||||
set(_FILE_OFFSET_BITS 64 CACHE INTERNAL "64-bit off_t requires _FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT FILE64_OK)
|
||||
# Test with _LARGE_FILES
|
||||
TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}"
|
||||
"${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c"
|
||||
COMPILE_DEFINITIONS "-D_LARGE_FILES" )
|
||||
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c"
|
||||
COMPILE_DEFINITIONS "-D_LARGE_FILES")
|
||||
if(FILE64_OK)
|
||||
MESSAGE(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
|
||||
message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
|
||||
set(_LARGE_FILES 1 CACHE INTERNAL "64-bit off_t requires _LARGE_FILES")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT FILE64_OK)
|
||||
# Test with _LARGEFILE_SOURCE
|
||||
TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}"
|
||||
"${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c"
|
||||
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
|
||||
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c"
|
||||
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE")
|
||||
if(FILE64_OK)
|
||||
MESSAGE(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
|
||||
message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
|
||||
set(_LARGEFILE_SOURCE 1 CACHE INTERNAL "64-bit off_t requires _LARGEFILE_SOURCE")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT FILE64_OK)
|
||||
MESSAGE(STATUS "Checking for 64-bit off_t - not present")
|
||||
message(STATUS "Checking for 64-bit off_t - not present")
|
||||
else()
|
||||
# 64-bit off_t found. Now check that ftello/fseeko is available.
|
||||
|
||||
# Set the flags we might have determined to be required above
|
||||
configure_file("${CMLIB_MODULE_DIR}/tests/TestLargeFiles.c.in"
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||
|
||||
MESSAGE(STATUS "Checking for fseeko/ftello")
|
||||
message(STATUS "Checking for fseeko/ftello")
|
||||
# Test if ftello/fseeko are available
|
||||
TRY_COMPILE(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}"
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||
try_compile(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}"
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||
if(FSEEKO_COMPILE_OK)
|
||||
MESSAGE(STATUS "Checking for fseeko/ftello - present")
|
||||
message(STATUS "Checking for fseeko/ftello - present")
|
||||
endif()
|
||||
|
||||
if(NOT FSEEKO_COMPILE_OK)
|
||||
# glibc 2.2 neds _LARGEFILE_SOURCE for fseeko (but not 64-bit off_t...)
|
||||
TRY_COMPILE(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}"
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
|
||||
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
|
||||
try_compile(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}"
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
|
||||
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE")
|
||||
if(FSEEKO_COMPILE_OK)
|
||||
MESSAGE(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
|
||||
message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
|
||||
set(_LARGEFILE_SOURCE 1 CACHE INTERNAL "64-bit fseeko requires _LARGEFILE_SOURCE")
|
||||
else()
|
||||
set(FILE64_OK 0)
|
||||
@@ -134,29 +130,27 @@ MACRO(cmlib_test_large_files VARIABLE)
|
||||
|
||||
if(NOT FILE64_OK)
|
||||
# now check for Windows stuff
|
||||
TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}"
|
||||
"${CMLIB_MODULE_DIR}/tests/TestWindowsFSeek.c")
|
||||
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestWindowsFSeek.c")
|
||||
if(FILE64_OK)
|
||||
MESSAGE(STATUS "Checking for 64-bit off_t - present with _fseeki64")
|
||||
message(STATUS "Checking for 64-bit off_t - present with _fseeki64")
|
||||
set(HAVE__FSEEKI64 1 CACHE INTERNAL "64-bit off_t requires _fseeki64")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FSEEKO_COMPILE_OK)
|
||||
SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
|
||||
set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
|
||||
set(HAVE_FSEEKO 1 CACHE INTERNAL "64bit fseeko is available" FORCE)
|
||||
elseif(HAVE__FSEEKI64)
|
||||
SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
|
||||
SET(HAVE__FSEEKI64 1 CACHE INTERNAL "Windows 64-bit fseek" FORCE)
|
||||
set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
|
||||
set(HAVE__FSEEKI64 1 CACHE INTERNAL "Windows 64-bit fseek" FORCE)
|
||||
else()
|
||||
check_type_size("long int" SIZEOF_LONG_INT)
|
||||
check_type_size("long int" SIZEOF_LONG_INT)
|
||||
if(SIZEOF_LONG_INT EQUAL 8) #standard fseek is OK for 64bit
|
||||
SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
|
||||
set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
|
||||
else()
|
||||
MESSAGE(FATAL_ERROR "Checking for 64bit file support failed.")
|
||||
message(FATAL_ERROR "Checking for 64bit file support failed.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ENDIF()
|
||||
ENDMACRO(cmlib_test_large_files VARIABLE)
|
||||
|
||||
endif()
|
||||
endmacro(cmlib_test_large_files VARIABLE)
|
||||
|
@@ -6,16 +6,16 @@ function(set_organization_name)
|
||||
message(FATAL_ERROR "File ${ORGANIZATION_FILE} doesn't exist")
|
||||
endif()
|
||||
file(READ "${_organization_file}" _org)
|
||||
set_property(DIRECTORY
|
||||
APPEND
|
||||
PROPERTY CMAKE_CONFIGURE_DEPENDS ${_organization_file})
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_organization_file})
|
||||
|
||||
if(NOT "${_org}" MATCHES "^([0-9A-Za-z ,.]+)\n")
|
||||
message(FATAL_ERROR "File ${_organization_file} has wrong format")
|
||||
endif()
|
||||
|
||||
string(REGEX MATCH "^([0-9A-Za-z ,.]+)\n" _ ${_org})
|
||||
string(REGEX MATCH
|
||||
"^([0-9A-Za-z ,.]+)\n"
|
||||
_
|
||||
${_org})
|
||||
|
||||
set_property(GLOBAL PROPERTY ORGANIZATION_NAME ${CMAKE_MATCH_1})
|
||||
endfunction()
|
||||
|
||||
|
@@ -3,8 +3,8 @@ function(set_project_version)
|
||||
message(FATAL_ERROR "Please set project version in X.Y.Z format")
|
||||
endif()
|
||||
|
||||
math(EXPR _version_int
|
||||
math(
|
||||
EXPR _version_int
|
||||
"(${PROJECT_VERSION_MAJOR} << 16) + (${PROJECT_VERSION_MINOR} << 8) + ${PROJECT_VERSION_PATCH}")
|
||||
set_property(GLOBAL PROPERTY PROJECT_VERSION_INT ${_version_int})
|
||||
endfunction()
|
||||
|
||||
|
@@ -5,7 +5,11 @@ function(qt_translation)
|
||||
set(oneValueArgs TARGET TS_DIR)
|
||||
set(multiValueArgs LANGUAGES)
|
||||
|
||||
cmake_parse_arguments(_QTTR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
cmake_parse_arguments(_QTTR
|
||||
"${options}"
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
set(_target ${_QTTR_TARGET})
|
||||
set(_ts_dir ${_QTTR_TS_DIR})
|
||||
set(_languages ${_QTTR_LANGUAGES})
|
||||
@@ -22,8 +26,13 @@ function(qt_translation)
|
||||
string(APPEND L10N_QRC_BODY "<file alias=\"${_qm}\">${CMAKE_BINARY_DIR}/${_qm}</file>\n")
|
||||
|
||||
add_custom_target(${_target}_l10n_${_lang}
|
||||
COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${_sources} -ts ${_ts_dir}/${_ts} -target-language ${_lang}
|
||||
DEPENDS ${_sources})
|
||||
COMMAND ${Qt5_LUPDATE_EXECUTABLE}
|
||||
${_sources}
|
||||
-ts
|
||||
${_ts_dir}/${_ts}
|
||||
-target-language
|
||||
${_lang}
|
||||
DEPENDS ${_sources})
|
||||
|
||||
if(NOT EXISTS "${_ts_dir}/${_ts}")
|
||||
add_custom_target(${_ts} DEPENDS ${_target}_l10n_${_lang})
|
||||
@@ -33,12 +42,14 @@ function(qt_translation)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${_qm}
|
||||
COMMAND ${Qt5_LRELEASE_EXECUTABLE}
|
||||
ARGS ${_ts_dir}/${_ts} -qm ${CMAKE_BINARY_DIR}/${_qm}
|
||||
ARGS
|
||||
${_ts_dir}/${_ts}
|
||||
-qm
|
||||
${CMAKE_BINARY_DIR}/${_qm}
|
||||
DEPENDS ${_ts} ${_sources})
|
||||
endforeach()
|
||||
|
||||
configure_file(${CMLIB_MODULE_DIR}/qrc/l10n.qrc.in
|
||||
${CMAKE_BINARY_DIR}/${_target}_l10n.qrc)
|
||||
configure_file(${CMLIB_MODULE_DIR}/qrc/l10n.qrc.in ${CMAKE_BINARY_DIR}/${_target}_l10n.qrc)
|
||||
qt5_add_resources(_qrc ${CMAKE_BINARY_DIR}/${_target}_l10n.qrc)
|
||||
add_custom_target(${_target}_qrc DEPENDS ${_qrc})
|
||||
add_custom_target(${_target}_l10n DEPENDS ${_l10n_targets})
|
||||
@@ -50,4 +61,3 @@ function(qt_translation)
|
||||
add_dependencies(${_target} ${_target}_qrc)
|
||||
target_sources(${_target} PUBLIC ${_qrc})
|
||||
endfunction()
|
||||
|
||||
|
35
CMLibRequiredVariables.cmake
Normal file
35
CMLibRequiredVariables.cmake
Normal file
@@ -0,0 +1,35 @@
|
||||
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/etc/Variables.cmake")
|
||||
message(FATAL_ERROR "Required file cmake/etc/Variables.cmake does not exist")
|
||||
endif()
|
||||
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/etc/Variables.cmake")
|
||||
|
||||
if(NOT ORGANIZATION_NAME)
|
||||
message(FATAL_ERROR "Required variable ORGANIZATION_NAME is not defined")
|
||||
endif()
|
||||
|
||||
set(CPACK_PACKAGE_VENDOR ${ORGANIZATION_NAME})
|
||||
|
||||
if(NOT CPACK_GENERATOR)
|
||||
message(FATAL_ERROR "Required variable CPACK_GENERATOR is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_PACKAGE_CONTACT)
|
||||
message(FATAL_ERROR "Required variable CPACK_PACKAGE_CONTACT is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
|
||||
message(FATAL_ERROR "Required variable CPACK_PACKAGE_DESCRIPTION_SUMMARY is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_DEBIAN_PACKAGE_SECTION)
|
||||
message(FATAL_ERROR "Required variable CPACK_DEBIAN_PACKAGE_SECTION is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
|
||||
message(FATAL_ERROR "Required variable CPACK_DEBIAN_PACKAGE_PRIORITY is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_SOURCE_IGNORE_FILES)
|
||||
message(FATAL_ERROR "Required variable CPACK_SOURCE_IGNORE_FILES is not defined")
|
||||
endif()
|
@@ -10,4 +10,3 @@ if(IS_DIRECTORY "${CMLIB_MODULE_DIR}")
|
||||
else()
|
||||
message(FATAL_ERROR "CMLib directory not found.")
|
||||
endif()
|
||||
|
||||
|
@@ -4,5 +4,9 @@ if(NOT TODAY)
|
||||
else()
|
||||
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE TODAY)
|
||||
endif()
|
||||
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" TODAY ${TODAY})
|
||||
string(REGEX
|
||||
REPLACE "(..)/(..)/(....).*"
|
||||
"\\3-\\2-\\1"
|
||||
TODAY
|
||||
${TODAY})
|
||||
endif()
|
||||
|
@@ -1,8 +1,8 @@
|
||||
if(NOT TARGET uninstall)
|
||||
configure_file("${CMLIB_MODULE_DIR}/CMLibUninstall.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE
|
||||
@ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P
|
||||
${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user