This commit is contained in:
Andrei Astafev 2022-10-05 10:01:02 +03:00
parent be3788ebe4
commit 572b0be826
12 changed files with 18 additions and 45 deletions

View File

@ -6,8 +6,8 @@ list(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake/find")
get_filename_component(MYX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) get_filename_component(MYX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
set(MYX_CMAKE_BACKPORTS_DIR "${MYX_CMAKE_SOURCE_DIR}/backports") set(MYX_CMAKE_BACKPORTS_DIR "${MYX_CMAKE_SOURCE_DIR}/backports" CACHE PATH "")
set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib") set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib" CACHE PATH "")
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake) include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake) include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake)

View File

@ -1,4 +1,4 @@
set(MYX_CMAKE_PACKAGE_VERSION "1.99.85") set(MYX_CMAKE_PACKAGE_VERSION "1.99.86")
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE) set(PACKAGE_VERSION_COMPATIBLE FALSE)
else() else()

View File

@ -36,10 +36,10 @@ if(MYX_CMAKE_DIR)
set(ENV{MYX_CMAKE_DIR} ${MYX_CMAKE_DIR}) set(ENV{MYX_CMAKE_DIR} ${MYX_CMAKE_DIR})
endif() endif()
if(DEFINED ENV{MYX_CMAKE_DIR}) if(DEFINED ENV{MYX_CMAKE_DIR})
find_package(MyxCMake 1.99.85 REQUIRED) find_package(MyxCMake 1.99.86 REQUIRED)
else() else()
if(MYX_CMAKE_USE_SYSTEM) if(MYX_CMAKE_USE_SYSTEM)
find_package(MyxCMake 1.99.85 REQUIRED) find_package(MyxCMake 1.99.86 REQUIRED)
else() else()
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake) include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
endif() endif()

View File

@ -1 +1 @@
1.99.85 1.99.86

View File

@ -1,6 +1,6 @@
include_guard(GLOBAL) include_guard(GLOBAL)
if(CMAKE_VERSION VERSION_LESS 3.21) if(${CMAKE_VERSION} VERSION_LESS 3.21)
get_property(nt DIRECTORY PROPERTY PARENT_DIRECTORY) get_property(nt DIRECTORY PROPERTY PARENT_DIRECTORY)
if(NOT nt) if(NOT nt)
set(PROJECT_IS_TOP_LEVEL true) set(PROJECT_IS_TOP_LEVEL true)

View File

@ -19,12 +19,6 @@ myx_add_library
include_guard(GLOBAL) include_guard(GLOBAL)
# Переменная `CMAKE_CURRENT_FUNCTION_LIST_DIR` позволяет определить
# каталог файла.
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
endif()
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(GenerateExportHeader) include(GenerateExportHeader)
@ -142,7 +136,7 @@ function(myx_add_library NAME TYPE)
) )
configure_package_config_file( configure_package_config_file(
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/library-config.cmake.in ${MYX_CMAKE_LIB_DIR}/library-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME} INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
NO_SET_AND_CHECK_MACRO NO_SET_AND_CHECK_MACRO

View File

@ -36,7 +36,7 @@ function(myx_target_setup NAME)
endif() endif()
if(ARG_PCH) if(ARG_PCH)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16 AND PROJECT_IS_TOP_LEVEL OR MYX_USE_LOCAL_DIRECTORIES) if((${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16) AND (PROJECT_IS_TOP_LEVEL OR MYX_USE_LOCAL_DIRECTORIES))
target_precompile_headers(${NAME} PRIVATE ${ARG_PCH}) target_precompile_headers(${NAME} PRIVATE ${ARG_PCH})
else() else()
target_compile_options(${NAME} PRIVATE -include ${ARG_PCH}) target_compile_options(${NAME} PRIVATE -include ${ARG_PCH})
@ -73,7 +73,9 @@ function(myx_target_setup NAME)
target_sources(${NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>) target_sources(${NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
target_sources(${NAME} PUBLIC ${ARG_PUBLIC_HEADERS}) target_sources(${NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
target_sources(${NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS}) target_sources(${NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
target_link_libraries(${NAME} PRIVATE ${ARG_LINK_LIBRARIES}) if(NOT target_type STREQUAL "OBJECT_LIBRARY")
target_link_libraries(${NAME} PRIVATE ${ARG_LINK_LIBRARIES})
endif()
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS}) target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
# Установка публичных заголовочных файлов # Установка публичных заголовочных файлов

View File

@ -52,12 +52,12 @@ function(myx_uncrustify target)
endif() endif()
if(NOT EXISTS ${ARG_CONFIG}) if(NOT EXISTS ${ARG_CONFIG})
myx_message_notify("MyxCMake: uncrustify config is not found") myx_message_notice("MyxCMake: uncrustify config is not found")
return() return()
endif() endif()
if(NOT UNCRUSTIFY_EXE) if(NOT UNCRUSTIFY_EXE)
myx_message_notify("MyxCMake: uncrustify executable is not found") myx_message_notice("MyxCMake: uncrustify executable is not found")
return() return()
endif() endif()

View File

@ -1,11 +1,5 @@
include_guard(GLOBAL) include_guard(GLOBAL)
# Переменная `CMAKE_CURRENT_FUNCTION_LIST_DIR` позволяет определить
# каталог файла.
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
endif()
function(myx_doc_doxygen NAME) function(myx_doc_doxygen NAME)
find_package(Doxygen) find_package(Doxygen)
if(DOXYGEN_FOUND) if(DOXYGEN_FOUND)
@ -45,7 +39,7 @@ function(myx_doc_doxygen NAME)
set(ARG_LANGUAGE "Russian") set(ARG_LANGUAGE "Russian")
endif() endif()
if(NOT ARG_DOXYFILE_TEMPLATE OR NOT EXISTS "${ARG_DOXYFILE_TEMPLATE}") if(NOT ARG_DOXYFILE_TEMPLATE OR NOT EXISTS "${ARG_DOXYFILE_TEMPLATE}")
set(ARG_DOXYFILE_TEMPLATE "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Doxyfile.in") set(ARG_DOXYFILE_TEMPLATE "${MYX_CMAKE_LIB_DIR}/doc/Doxyfile.in")
endif() endif()
if(NOT DOXYGEN_PROJECT_NAME) if(NOT DOXYGEN_PROJECT_NAME)
set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME}) set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME})

View File

@ -1,11 +1,6 @@
cmake_policy(PUSH) cmake_policy(PUSH)
cmake_policy(SET CMP0053 NEW) # IN_LIST operator cmake_policy(SET CMP0053 NEW) # IN_LIST operator
# Переменная `CMAKE_CURRENT_FUNCTION_LIST_DIR` позволяет определить каталог файла.
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
endif()
set(ARG_PREFIX "${PREFIX}") set(ARG_PREFIX "${PREFIX}")
set(GIT_REV "N/A") set(GIT_REV "N/A")
set(GIT_DIFF "") set(GIT_DIFF "")

View File

@ -16,12 +16,6 @@ myx_generate_git_info_header
include_guard(GLOBAL) include_guard(GLOBAL)
# Переменная `CMAKE_CURRENT_FUNCTION_LIST_DIR` позволяет
# определить каталог файла.
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
endif()
function(myx_generate_git_info_header target base_filename) function(myx_generate_git_info_header target base_filename)
set(options) set(options)
set(oneValueArgs PREFIX) set(oneValueArgs PREFIX)
@ -41,9 +35,9 @@ function(myx_generate_git_info_header target base_filename)
if(NOT TARGET ${target}-git-info-header) if(NOT TARGET ${target}-git-info-header)
add_custom_target(${target}-git-info-header ALL add_custom_target(${target}-git-info-header ALL
${CMAKE_COMMAND} -DGIT_INFO_FILE=${filename} -DPREFIX=${PREFIX} ${CMAKE_COMMAND} -DGIT_INFO_FILE=${filename} -DPREFIX=${PREFIX}
-P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/GitInfo.cmake -P ${MYX_CMAKE_LIB_DIR}/generators/GitInfo.cmake
BYPRODUCTS ${filename} BYPRODUCTS ${filename}
WORKING_DIRECTORY ${CMAKE_CURRENT_FUNCTION_LIST_DIR}) WORKING_DIRECTORY ${MYX_CMAKE_LIB_DIR}/generators)
endif() endif()
# cmake-format: on # cmake-format: on

View File

@ -14,19 +14,13 @@ myx_generate_private_config_header
include_guard(GLOBAL) include_guard(GLOBAL)
# Переменная `CMAKE_CURRENT_FUNCTION_LIST_DIR` позволяет определить
# каталог файла.
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
endif()
function(myx_generate_private_config_header target base_filename) function(myx_generate_private_config_header target base_filename)
set(BUILD_DATE ${MYX_TODAY}) set(BUILD_DATE ${MYX_TODAY})
myx_project_version_int() myx_project_version_int()
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT) get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
set(filename "${PROJECT_BINARY_DIR}/include/${base_filename}") set(filename "${PROJECT_BINARY_DIR}/include/${base_filename}")
configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PrivateConfig.hpp.in" ${filename}) configure_file("${MYX_CMAKE_LIB_DIR}/generators/PrivateConfig.hpp.in" ${filename})
set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename}) set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename})
target_sources(${target} PRIVATE ${filename}) target_sources(${target} PRIVATE ${filename})