diff --git a/CMLibBreathe.cmake b/CMLibBreathe.cmake index af60256..f995488 100644 --- a/CMLibBreathe.cmake +++ b/CMLibBreathe.cmake @@ -1,85 +1,45 @@ -set(BUILD_BREATHE_DOC AUTO CACHE STRING "Enable documntation in Breathe format") -set_property(CACHE BUILD_BREATHE_DOC PROPERTY STRINGS AUTO ON OFF) +set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator") +set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO) -if(BUILD_BREATHE_DOC STREQUAL 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_FOUND AND breathe_FOUND AND recommonmark_FOUND) - set(BUILD_BREATHE_DOC ON CACHE STRING "Enable documntation in Breathe format" FORCE) - else() - set(BUILD_BREATHE_DOC OFF CACHE STRING "Disable documentation in Breathe format" FORCE) - endif() - else() - set(BUILD_BREATHE_DOC OFF CACHE STRING "Disable documentation in Breathe format" FORCE) - endif() -elseif(BUILD_BREATHE_DOC) - find_package(Doxygen REQUIRED) - find_package(Perl REQUIRED) - set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2) - find_package(PythonInterp REQUIRED) - find_package(Sphinx REQUIRED) +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 REQUIRED) - find_python_module(recommonmark REQUIRED) - set(BUILD_BREATHE_DOC ON CACHE STRING "Enable documentation in Breathe format" FORCE) + 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(BUILD_BREATHE_DOC OFF CACHE STRING "Disable documentation in Breathe format" FORCE) + set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE) endif() -function(add_breathe_doc) - if(BUILD_BREATHE_DOC AND CMAKE_BUILD_TYPE STREQUAL Release) + +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(oneValueArgs SOURCE_DIR BUILD_DIR CACHE_DIR HTML_DIR DOXY_FILE CONF_FILE TARGET_NAME COMMENT) set(multiValueArgs) - cmake_parse_arguments(BREATHE_DOC - "${options}" - "${oneValueArgs}" - "${multiValueArgs}" - ${ARGN} - ) + cmake_parse_arguments(_BREATHE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - configure_file( - ${BREATHE_DOC_CONF_FILE} - ${BREATHE_DOC_BUILD_DIR}/conf.py - @ONLY - ) + configure_file(${_BREATHE_CONF_FILE} ${_BREATHE_BUILD_DIR}/conf.py @ONLY) + configure_file(${_BREATHE_DOXY_FILE} ${_BREATHE_BUILD_DIR}/Doxyfile @ONLY) - configure_file( - ${BREATHE_DOC_DOXY_FILE} - ${BREATHE_DOC_BUILD_DIR}/Doxyfile - @ONLY - ) - - add_custom_target(${BREATHE_DOC_TARGET_NAME} - ALL - COMMAND - ${SPHINX_EXECUTABLE} - -q - -b html - -c ${BREATHE_DOC_BUILD_DIR} - -d ${BREATHE_DOC_CACHE_DIR} - ${BREATHE_DOC_SOURCE_DIR} - ${BREATHE_DOC_HTML_DIR} - COMMENT - "Building ${BREATHE_DOC_TARGET_NAME} documentation with Breathe, Sphinx and Doxygen" - VERBATIM + 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() diff --git a/CMLibCodeAnalysisClangAnalyze.cmake b/CMLibCodeAnalysisClangAnalyze.cmake index 83333de..1440ca1 100644 --- a/CMLibCodeAnalysisClangAnalyze.cmake +++ b/CMLibCodeAnalysisClangAnalyze.cmake @@ -24,7 +24,8 @@ function(add_clang_analyze_check) add_dependencies(clang-analyze-check-${_target} ${_target}) add_dependencies(clang-analyze-check clang-analyze-check-${_target}) else() - message(WARNING "ClangCheck is not found") + message(STATUS "CMLIB warning:") + message(STATUS " Clang-Check analyzer is not found") endif() endfunction() diff --git a/CMLibCodeAnalysisClangTidy.cmake b/CMLibCodeAnalysisClangTidy.cmake index 1e2efbf..8fc3ab3 100644 --- a/CMLibCodeAnalysisClangTidy.cmake +++ b/CMLibCodeAnalysisClangTidy.cmake @@ -24,7 +24,8 @@ function(add_clang_tidy_check) add_dependencies(clang-tidy-check-${_target} ${_target}) add_dependencies(clang-tidy-check clang-tidy-check-${_target}) else() - message(WARNING "ClangTidy is not found") + message(STATUS "CMLIB warning:") + message(STATUS " ClangTidy analyzer is not found") endif() endfunction() diff --git a/CMLibCodeAnalysisClazy.cmake b/CMLibCodeAnalysisClazy.cmake index 7c886a3..664a144 100644 --- a/CMLibCodeAnalysisClazy.cmake +++ b/CMLibCodeAnalysisClazy.cmake @@ -15,7 +15,8 @@ function(add_clazy_check) add_dependencies(clazy-check-${_target} ${_target}) add_dependencies(clazy-check clazy-check-${_target}) else() - message(WARNING "Clazy is not found") + message(STATUS "CMLIB warning:") + message(STATUS " Clazy analyzer is not found") endif() endfunction() diff --git a/CMLibCodeAnalysisPvsStudio.cmake b/CMLibCodeAnalysisPvsStudio.cmake index d8b0b36..c7bac77 100644 --- a/CMLibCodeAnalysisPvsStudio.cmake +++ b/CMLibCodeAnalysisPvsStudio.cmake @@ -18,10 +18,12 @@ function(add_pvs_check) MODE GA:1,2,3;64:1;OP:1,2;CS:1,2) add_dependencies(pvs-check pvs-check-${_target}) else() - message(WARNING "PVS-Studio is not found") + message(STATUS "CMLIB warning:") + message(STATUS " PVS-Studio analyzer is not found") endif() else() - message(WARNING "Option CMAKE_EXPORT_COMPILE_COMMANDS is not set. PVS checks will be disabled.") + message(STATUS "CMLIB warning:") + message(STATUS " Option CMAKE_EXPORT_COMPILE_COMMANDS is not set. PVS checks will be disabled.") endif() endfunction() diff --git a/CMLibCommon.cmake b/CMLibCommon.cmake index 79dae59..926c71a 100644 --- a/CMLibCommon.cmake +++ b/CMLibCommon.cmake @@ -39,6 +39,7 @@ include(CMLibSanitizers) include(cotire) include(CMLibFormatSources) +include(CMLibDoxygen) include(CMLibBreathe) include(CMLibQtTranslation) include(CMLibToday) diff --git a/CMLibCompilerFlags.cmake b/CMLibCompilerFlags.cmake index e060008..24db8a4 100644 --- a/CMLibCompilerFlags.cmake +++ b/CMLibCompilerFlags.cmake @@ -88,11 +88,26 @@ if(CMAKE_CXX_COMPILER_IS_CLANG endif() if(CMAKE_BUILD_TYPE STREQUAL "Release") - check_enable_cxx_flag(-flto) - if(CMAKE_CXX_COMPILER_IS_GCC - AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8") - # Doesn't work with GCC 4.7.2 in Astra Linux 1.5 - check_enable_cxx_flag(-fno-fat-lto-objects) + 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() diff --git a/CMLibDoxygen.cmake b/CMLibDoxygen.cmake new file mode 100644 index 0000000..370ec38 --- /dev/null +++ b/CMLibDoxygen.cmake @@ -0,0 +1,32 @@ +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() diff --git a/CMLibFormatSources.cmake b/CMLibFormatSources.cmake index 13d7fc9..9fa0edd 100644 --- a/CMLibFormatSources.cmake +++ b/CMLibFormatSources.cmake @@ -16,6 +16,7 @@ function(add_uncrustify_format) COMMAND ${UNCRUSTIFY_EXE} ${OPTS} ${_sources}) add_dependencies(uncrustify-format uncrustify-format-${_target}) else() - message(WARNING "Uncrustify is not found") + message(STATUS "CMLIB warning:") + message(STATUS " Uncrustify is not found") endif() endfunction() diff --git a/CMLibSanitizers.cmake b/CMLibSanitizers.cmake index d5dc6c2..be3d883 100644 --- a/CMLibSanitizers.cmake +++ b/CMLibSanitizers.cmake @@ -4,7 +4,8 @@ if(IS_DIRECTORY "${CMLIB_MODULE_DIR}") list(APPEND CMAKE_MODULE_PATH ${CMLIB_SANITIZERS_DIR}) find_package(Sanitizers) else() - message(WARNING "Sanitizers submodule not found.") + message(STATUS "CMLIB warning:") + message(STATUS " Sanitizers submodule is not found.") endif() else() message(FATAL_ERROR "CMLib directory not found.") diff --git a/thirdparty/sanitizers b/thirdparty/sanitizers index 9b4aec0..26eced8 160000 --- a/thirdparty/sanitizers +++ b/thirdparty/sanitizers @@ -1 +1 @@ -Subproject commit 9b4aec096e3c05124bb46c9d9dc18468b3646e95 +Subproject commit 26eced86d8e759c625b697f6b0588d7a28746725