Core: Add libfmt via FetchContent

This commit is contained in:
Chris Hennes
2023-02-15 21:34:07 -06:00
parent c98022e7fd
commit 59c95496b4
4 changed files with 42 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ InitializeFreeCADBuildOptions()
CheckInterModuleDependencies()
FreeCADLibpackChecks()
SetupDoxygen()
SetupLibFmt()
if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
SetupPython()
SetupPCL()

View File

@@ -178,6 +178,7 @@ macro(PrintFinalReport)
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}")
section_end()

View File

@@ -0,0 +1,39 @@
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()
include(FetchContent)
FetchContent_Declare(fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG 9.1.0
)
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}")
else()
message(ERROR "Failed to install the fmt library")
endif()
endmacro()

View File

@@ -65,6 +65,7 @@ include_directories(
set(FreeCADApp_LIBS
FreeCADBase
${Boost_LIBRARIES}
fmt::fmt
)
include_directories(