From 0ce2faf128cc45b3ad3653d81ccfbb29b9ff580d Mon Sep 17 00:00:00 2001 From: Jack Luo Date: Wed, 4 Dec 2024 17:17:08 +0800 Subject: [PATCH] Fix cmake compilation issue --- components/core/CMakeLists.txt | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index 6cdb4b4cd..e2f4a518c 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -49,15 +49,19 @@ if (IS_BIG_ENDIAN) message(FATAL_ERROR "Big-endian machines are not supported") endif() +if (NOT DEFINED CLP_USE_EXACT_PINNED_LIB_VERSION) + set(CLP_USE_EXACT_PINNED_LIB_VERSION ON) +endif() + # Detect linking mode (static or shared); Default to static. set(CLP_USE_STATIC_LIBS ON CACHE BOOL "Whether to link against static libraries") if (CLP_USE_STATIC_LIBS AND APPLE) message(AUTHOR_WARNING "Building with static libraries is unsupported on macOS." " Switching to shared libraries.") set(CLP_USE_STATIC_LIBS OFF) - message(AUTHOR_WARNING "Use the system libraries for building, + message(AUTHOR_WARNING "Use the system provided library version for building, as library version pinning is not supported on macOS.") - set(CLP_USE_SYSTEM_LIBS ON) + set(CLP_USE_EXACT_PINNED_LIB_VERSION OFF) endif () if(CLP_USE_STATIC_LIBS) set(CLP_LIBS_STRING "static") @@ -102,14 +106,12 @@ endif() # NOTE: # - We only try to link to the static library # - spdlog uses fmt, so their versions need to be kept in-sync -if (CLP_USE_SYSTEM_LIBS) - # - Attempt to use a compatible version of fmt; - # it is the user's responsibility to install the appropriate fmt library version. - find_package(fmt 8.0.1 REQUIRED) +if(CLP_USE_EXACT_PINNED_LIB_VERSION) + set(FIND_FMT_PACKAGE_ARGS 8.0.1 EXACT REQUIRED) else() - # - spdlog uses fmt, so their versions need to be kept in-sync - find_package(fmt 8.0.1 EXACT REQUIRED) + set(FIND_FMT_PACKAGE_ARGS 8.0.1 REQUIRED) endif() +find_package(fmt ${FIND_FMT_PACKAGE_ARGS}) if(fmt_FOUND) message(STATUS "Found fmt ${fmt_VERSION}") else() @@ -124,13 +126,12 @@ if(CLP_USE_STATIC_LIBS) # source. set(spdlog_USE_STATIC_LIBS ON) endif() -if (CLP_USE_SYSTEM_LIBS) - # - Attempt to use a compatible version of spdlog; - # it is the user's responsibility to install the appropriate spdlog library version. - find_package(spdlog 1.9.2 REQUIRED) +if(CLP_USE_EXACT_PINNED_LIB_VERSION) + set(FIND_SPDLOG_PACKAGE_ARGS 1.9.2 EXACT REQUIRED) else() - # - spdlog uses fmt, so their versions need to be kept in-sync - find_package(spdlog 1.9.2 EXACT REQUIRED) + set(FIND_SPDLOG_PACKAGE_ARGS 1.9.2 REQUIRED) +endif() +find_package(spdlog ${FIND_SPDLOG_PACKAGE_ARGS}) if(spdlog_FOUND) message(STATUS "Found spdlog ${spdlog_VERSION}") else()