Skip to content

Commit

Permalink
[Conf] Upgraded CMake files
Browse files Browse the repository at this point in the history
  • Loading branch information
da115115 committed Nov 20, 2024
1 parent 8453443 commit ca1f00a
Show file tree
Hide file tree
Showing 11 changed files with 728 additions and 328 deletions.
20 changes: 18 additions & 2 deletions config/FindBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
FindBoost
---------
.. versionchanged:: 3.30
This module is available only if policy :policy:`CMP0167` is not set to
``NEW``. Port projects to upstream Boost's ``BoostConfig.cmake`` package
configuration file, for which ``find_package(Boost)`` now searches.
Find Boost include dirs and libraries
Use this module by invoking :command:`find_package` with the form:
Expand Down Expand Up @@ -379,6 +384,16 @@ the Boost CMake package configuration for details on what it provides.
Set ``Boost_NO_BOOST_CMAKE`` to ``ON``, to disable the search for boost-cmake.
#]=======================================================================]

cmake_policy(GET CMP0167 _FindBoost_CMP0167)
if(_FindBoost_CMP0167 STREQUAL "NEW")
message(FATAL_ERROR "The FindBoost module has been removed by policy CMP0167.")
endif()

if(_FindBoost_testing)
set(_FindBoost_included TRUE)
return()
endif()

# The FPHSA helper provides standard way of reporting final search results to
# the user including the version and component checks.
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
Expand All @@ -387,6 +402,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var)
cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>

function(_boost_get_existing_target component target_var)
set(names "${component}")
Expand Down Expand Up @@ -1394,7 +1410,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_THREAD_DEPENDENCIES chrono atomic)
set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.85.0 AND NOT Boost_NO_WARN_NEW_VERSIONS)
if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.86.0 AND NOT Boost_NO_WARN_NEW_VERSIONS)
message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets")
endif()
endif()
Expand Down Expand Up @@ -1669,7 +1685,7 @@ else()
# _Boost_COMPONENT_HEADERS. See the instructions at the top of
# _Boost_COMPONENT_DEPENDENCIES.
set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
"1.84.0" "1.84"
"1.85.0" "1.85" "1.84.0" "1.84"
"1.83.0" "1.83" "1.82.0" "1.82" "1.81.0" "1.81" "1.80.0" "1.80" "1.79.0" "1.79"
"1.78.0" "1.78" "1.77.0" "1.77" "1.76.0" "1.76" "1.75.0" "1.75" "1.74.0" "1.74"
"1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70" "1.69.0" "1.69"
Expand Down
115 changes: 21 additions & 94 deletions config/FindICU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ platform-specific library name will be automatically selected.
This module reports information about the ICU installation in
several variables. General variables::
ICU_VERSION - ICU release version
ICU_FOUND - true if the main programs and libraries were found
ICU_LIBRARIES - component libraries to be linked
ICU_INCLUDE_DIRS - the directories containing the ICU headers
ICU_LIBRARIES - component libraries to be linked
ICU_VERSION - ICU release version
Imported targets::
Expand Down Expand Up @@ -83,12 +83,10 @@ The following cache variables may also be set::
In most cases none of the above variables will require setting,
unless multiple ICU versions are available and a specific version
is required.
Other variables one may set to control this module are::
ICU_DEBUG - Set to ON to enable debug output from FindICU.
#]=======================================================================]

cmake_policy(PUSH)
cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
# Written by Roger Leigh <[email protected]>

set(icu_programs
Expand Down Expand Up @@ -136,6 +134,7 @@ function(_ICU_FIND)
HINTS ${icu_roots}
PATH_SUFFIXES ${icu_include_suffixes}
DOC "ICU include directory")
mark_as_advanced(ICU_INCLUDE_DIR)
set(ICU_INCLUDE_DIR "${ICU_INCLUDE_DIR}" PARENT_SCOPE)

# Get version
Expand Down Expand Up @@ -178,7 +177,6 @@ function(_ICU_FIND)

# Find all ICU libraries
list(APPEND icu_library_suffixes "${_lib64}" "lib")
set(ICU_REQUIRED_LIBS_FOUND ON)
set(static_prefix )
# static icu libraries compiled with MSVC have the prefix 's'
if(MSVC)
Expand All @@ -189,8 +187,9 @@ function(_ICU_FIND)
set(component_cache "ICU_${component_upcase}_LIBRARY")
set(component_cache_release "${component_cache}_RELEASE")
set(component_cache_debug "${component_cache}_DEBUG")
set(component_found "ICU_${component_upcase}_FOUND")
set(component_found "ICU_${component}_FOUND")
set(component_found_compat "${component_upcase}_FOUND")
set(component_found_compat2 "ICU_${component_upcase}_FOUND")
set(component_libnames "icu${component}")
set(component_debug_libnames "icu${component}d")

Expand Down Expand Up @@ -253,27 +252,17 @@ function(_ICU_FIND)
if(${component_cache})
set("${component_found}" ON)
set("${component_found_compat}" ON)
set("${component_found_compat2}" ON)
list(APPEND ICU_LIBRARY "${${component_cache}}")
if (ICU_FIND_REQUIRED_${component})
list(APPEND ICU_LIBS_FOUND "${component} (required): ${${component_cache}}")
else()
list(APPEND ICU_LIBS_FOUND "${component} (optional): ${${component_cache}}")
endif()
else()
if (ICU_FIND_REQUIRED_${component})
set(ICU_REQUIRED_LIBS_FOUND OFF)
list(APPEND ICU_LIBS_NOTFOUND "${component} (required)")
else()
list(APPEND ICU_LIBS_NOTFOUND "${component} (optional)")
endif()
endif()
mark_as_advanced("${component_found}")
mark_as_advanced("${component_found_compat}")
mark_as_advanced("${component_found_compat2}")
set("${component_cache}" "${${component_cache}}" PARENT_SCOPE)
set("${component_found}" "${${component_found}}" PARENT_SCOPE)
set("${component_found_compat}" "${${component_found_compat}}" PARENT_SCOPE)
set("${component_found_compat2}" "${${component_found_compat2}}" PARENT_SCOPE)
endforeach()
set(_ICU_REQUIRED_LIBS_FOUND "${ICU_REQUIRED_LIBS_FOUND}" PARENT_SCOPE)
set(ICU_LIBRARY "${ICU_LIBRARY}" PARENT_SCOPE)

# Find all ICU data files
Expand Down Expand Up @@ -302,43 +291,21 @@ function(_ICU_FIND)
mark_as_advanced("${cache_var}")
set("${data_var}" "${${cache_var}}" PARENT_SCOPE)
endforeach()

if(NOT ICU_FIND_QUIETLY)
if(ICU_LIBS_FOUND)
message(STATUS "Found the following ICU libraries:")
foreach(found ${ICU_LIBS_FOUND})
message(STATUS " ${found}")
endforeach()
endif()
if(ICU_LIBS_NOTFOUND)
message(STATUS "The following ICU libraries were not found:")
foreach(notfound ${ICU_LIBS_NOTFOUND})
message(STATUS " ${notfound}")
endforeach()
endif()
endif()

if(ICU_DEBUG)
message(STATUS "--------FindICU.cmake search debug--------")
message(STATUS "ICU binary path search order: ${icu_roots}")
message(STATUS "ICU include path search order: ${icu_roots}")
message(STATUS "ICU library path search order: ${icu_roots}")
message(STATUS "----------------")
endif()
endfunction()

_ICU_FIND()

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ICU
FOUND_VAR ICU_FOUND
REQUIRED_VARS ICU_INCLUDE_DIR
ICU_LIBRARY
_ICU_REQUIRED_LIBS_FOUND
VERSION_VAR ICU_VERSION
FAIL_MESSAGE "Failed to find all ICU components")

unset(_ICU_REQUIRED_LIBS_FOUND)
find_package_handle_standard_args(ICU
REQUIRED_VARS
ICU_INCLUDE_DIR
ICU_LIBRARY
VERSION_VAR
ICU_VERSION
HANDLE_COMPONENTS
FAIL_MESSAGE
"Failed to find all ICU components"
)

if(ICU_FOUND)
set(ICU_INCLUDE_DIRS "${ICU_INCLUDE_DIR}")
Expand Down Expand Up @@ -392,45 +359,5 @@ if(ICU_FOUND)
endforeach()
endif()

if(ICU_DEBUG)
message(STATUS "--------FindICU.cmake results debug--------")
message(STATUS "ICU found: ${ICU_FOUND}")
message(STATUS "ICU_VERSION number: ${ICU_VERSION}")
message(STATUS "ICU_ROOT directory: ${ICU_ROOT}")
message(STATUS "ICU_INCLUDE_DIR directory: ${ICU_INCLUDE_DIR}")
message(STATUS "ICU_LIBRARIES: ${ICU_LIBRARIES}")

foreach(program IN LISTS icu_programs)
string(TOUPPER "${program}" program_upcase)
set(program_lib "ICU_${program_upcase}_EXECUTABLE")
message(STATUS "${program} program: ${program_lib}=${${program_lib}}")
unset(program_upcase)
unset(program_lib)
endforeach()

foreach(data IN LISTS icu_data)
string(TOUPPER "${data}" data_upcase)
string(REPLACE "." "_" data_upcase "${data_upcase}")
set(data_lib "ICU_${data_upcase}")
message(STATUS "${data} data: ${data_lib}=${${data_lib}}")
unset(data_upcase)
unset(data_lib)
endforeach()

foreach(component IN LISTS ICU_FIND_COMPONENTS)
string(TOUPPER "${component}" component_upcase)
set(component_lib "ICU_${component_upcase}_LIBRARIES")
set(component_found "ICU_${component_upcase}_FOUND")
set(component_found_compat "${component_upcase}_FOUND")
message(STATUS "${component} library found: ${component_found}=${${component_found}}")
message(STATUS "${component} library found (compat name): ${component_found_compat}=${${component_found_compat}}")
message(STATUS "${component} library: ${component_lib}=${${component_lib}}")
unset(component_upcase)
unset(component_lib)
unset(component_found)
unset(component_found_compat)
endforeach()
message(STATUS "----------------")
endif()

unset(icu_programs)
cmake_policy(POP)
5 changes: 4 additions & 1 deletion config/FindPackageHandleStandardArgs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ macro(_FPHSA_FAILURE_MESSAGE _msg)
set (__msg "${_msg}")
if (FPHSA_REASON_FAILURE_MESSAGE)
string(APPEND __msg "\n Reason given by package: ${FPHSA_REASON_FAILURE_MESSAGE}\n")
elseif(NOT DEFINED PROJECT_NAME)
string(APPEND __msg "\n"
"Hint: The project() command has not yet been called. It sets up system-specific search paths.")
endif()
if (${_NAME}_FIND_REQUIRED)
message(FATAL_ERROR "${__msg}")
Expand Down Expand Up @@ -342,7 +345,7 @@ function(FIND_PACKAGE_CHECK_VERSION version result)
set(version_msg "Found unsuitable version \"${version}\", but required is exact version \"${${package}_FIND_VERSION}\"")
else ()
set(version_ok TRUE)
set(version_msg "(found suitable exact version \"${_FOUND_VERSION}\")")
set(version_msg "(found suitable exact version \"${version}\")")
endif ()
else ()
if (NOT ${package}_FIND_VERSION VERSION_EQUAL version)
Expand Down
1 change: 1 addition & 0 deletions config/FindPackageMessage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function(find_package_message pkg msg details)
set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
# The message has not yet been printed.
string(STRIP "${msg}" msg)
message(STATUS "${msg}")

# Save the find details in the cache to avoid printing the same
Expand Down
Loading

0 comments on commit ca1f00a

Please sign in to comment.