Skip to content

Commit

Permalink
Fix cmake compilation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Luo committed Dec 4, 2024
1 parent 266affb commit 0ce2faf
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions components/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 0ce2faf

Please sign in to comment.