Merge pull request #8568 from chennes/cmakeFixFmt
cMake: Add manual find_package() for fmt
This commit is contained in:
@@ -177,8 +177,8 @@ macro(PrintFinalReport)
|
||||
endif()
|
||||
conditional(Doxygen DOXYGEN_FOUND "not found" "${DOXYGEN_VERSION} Language: ${DOXYGEN_LANGUAGE}")
|
||||
conditional(Coin3D_DOC COIN3D_DOC_FOUND "not found" ${COIN3D_DOC_PATH})
|
||||
conditional(PYCXX ${PYCXX_FOUND} "not found" "${PYCXX_VERSION} Incl: ${PYCXX_INCLUDE_DIR} Src:${PYCXX_SOURCE_DIR}")
|
||||
conditional(fmt ${fmt_FOUND} "${fmt_VERSION}" "Source located in ${fmt_SOURCE_DIR}")
|
||||
conditional(PYCXX PYCXX_FOUND "not found" "${PYCXX_VERSION} Incl: ${PYCXX_INCLUDE_DIR} Src:${PYCXX_SOURCE_DIR}")
|
||||
conditional(fmt fmt_FOUND "Sources downloaded to ${fmt_SOURCE_DIR}" "${fmt_VERSION}")
|
||||
|
||||
section_end()
|
||||
|
||||
|
||||
@@ -3,40 +3,44 @@ macro(SetupLibFmt)
|
||||
# This internet check idea is borrowed from:
|
||||
# https://stackoverflow.com/questions/62214621/how-to-check-for-internet-connection-with-cmake-automatically-prevent-fails-if
|
||||
|
||||
message(STATUS "Checking for connection to GitHub...")
|
||||
if (WIN32)
|
||||
set(ping_command "ping /n 1 /w 1000 github.com")
|
||||
else()
|
||||
set(ping_command "ping -c 1 -W 1000 github.com")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${ping_command}
|
||||
RESULT_VARIABLE NO_CONNECTION
|
||||
)
|
||||
if(NO_CONNECTION GREATER 0)
|
||||
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
|
||||
message(WARNING "NO INTERNET CONNECTION: Using disconnected mode for FetchContent updates")
|
||||
else()
|
||||
message(STATUS "GitHub connection established for FetchContent")
|
||||
set(FETCHCONTENT_UPDATES_DISCONNECTED OFF)
|
||||
endif()
|
||||
find_package(fmt QUIET)
|
||||
|
||||
include(FetchContent)
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
endif()
|
||||
FetchContent_Declare(fmt
|
||||
URL https://github.com/fmtlib/fmt/archive/refs/tags/9.1.0.zip
|
||||
URL_MD5 e6754011ff56bfc37631fcc90961e377
|
||||
)
|
||||
FetchContent_MakeAvailable(fmt)
|
||||
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
if (${fmt_FOUND})
|
||||
message(STATUS "find_package() was used to locate the fmt version ${fmt_VERSION}")
|
||||
elseif(${fmt_POPULATED})
|
||||
message(STATUS "fmt was downloaded using FetchContent into ${fmt_SOURCE_DIR}")
|
||||
if(fmt_FOUND)
|
||||
message(STATUS "find_package() was used to locate fmt version ${fmt_VERSION}")
|
||||
else()
|
||||
message(ERROR "Failed to install the fmt library")
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
message(STATUS "Checking for connection to GitHub...")
|
||||
if (WIN32)
|
||||
set(ping_command "ping /n 1 /w 3 github.com")
|
||||
else()
|
||||
set(ping_command "ping -c 1 -W 3 github.com")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${ping_command}
|
||||
RESULT_VARIABLE NO_CONNECTION
|
||||
)
|
||||
if(NO_CONNECTION GREATER 0)
|
||||
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
|
||||
message(WARNING "NO INTERNET CONNECTION: Using disconnected mode for FetchContent updates")
|
||||
else()
|
||||
message(STATUS "GitHub connection established for FetchContent")
|
||||
set(FETCHCONTENT_UPDATES_DISCONNECTED OFF)
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
endif()
|
||||
FetchContent_Declare(fmt
|
||||
URL https://github.com/fmtlib/fmt/archive/refs/tags/9.1.0.zip
|
||||
URL_MD5 e6754011ff56bfc37631fcc90961e377
|
||||
)
|
||||
FetchContent_MakeAvailable(fmt)
|
||||
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
if(${fmt_POPULATED})
|
||||
message(STATUS "fmt was downloaded using FetchContent into ${fmt_SOURCE_DIR}")
|
||||
else()
|
||||
message(ERROR "Failed to install the fmt library")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
Reference in New Issue
Block a user