mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 21:21:37 +00:00
build(cmake): build bundled GoogleTest with FetchContent
- Add the bundled GoogleTest with FetchContent and OVERRIDE_FIND_PACKAGE, so it uses the compiler and flags of the FairMQ build - Build it in a block() without gmock, install and static analysis - Replace build_bundled() with fairmq_init_submodule(), which runs git submodule update only if the submodule folder is empty, and stops with a clear error if it stays empty - Install the bundled FairCMakeModules into the build directory with its tests off, as before - Use the bundled PicoSHA2 headers directly from the source tree - With USE_EXTERNAL_GTEST, GTest is a private dependency and no longer in FairMQ_PACKAGE_DEPENDENCIES Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,38 @@ set(PROJECT_FairCMakeModules_VERSION 0.2)
|
||||
find_package(FairCMakeModules ${PROJECT_FairCMakeModules_VERSION} QUIET)
|
||||
|
||||
if(NOT FairCMakeModules_FOUND AND NOT FairCMakeModules_BUNDLED)
|
||||
build_bundled(FairCMakeModules extern/FairCMakeModules)
|
||||
# FairCMakeModules expects to be the top-level project, so it cannot be added
|
||||
# with add_subdirectory(). Install the bundled copy into the build directory
|
||||
# at configure time instead. It contains only CMake modules.
|
||||
message(STATUS "Building bundled FairCMakeModules")
|
||||
fairmq_init_submodule(extern/FairCMakeModules)
|
||||
set(_fcm_src ${PROJECT_SOURCE_DIR}/extern/FairCMakeModules)
|
||||
set(_fcm_bin ${PROJECT_BINARY_DIR}/extern/FairCMakeModules)
|
||||
set(_fcm_prefix ${PROJECT_BINARY_DIR}/extern/FairCMakeModules_install)
|
||||
set(_fcm_log ${_fcm_bin}/build.log)
|
||||
file(MAKE_DIRECTORY ${_fcm_bin})
|
||||
file(REMOVE ${_fcm_log})
|
||||
foreach(_fcm_step IN ITEMS configure install)
|
||||
if(_fcm_step STREQUAL configure)
|
||||
set(_fcm_cmd ${CMAKE_COMMAND} -S ${_fcm_src} -B ${_fcm_bin} -G ${CMAKE_GENERATOR}
|
||||
-DCMAKE_INSTALL_PREFIX=${_fcm_prefix}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DBUILD_TESTING=OFF)
|
||||
else()
|
||||
set(_fcm_cmd ${CMAKE_COMMAND} --build ${_fcm_bin} --target install)
|
||||
endif()
|
||||
execute_process(COMMAND ${_fcm_cmd}
|
||||
OUTPUT_VARIABLE _fcm_out
|
||||
ERROR_VARIABLE _fcm_out
|
||||
RESULT_VARIABLE _fcm_res
|
||||
)
|
||||
file(APPEND ${_fcm_log} "${_fcm_out}")
|
||||
if(_fcm_res)
|
||||
message(FATAL_ERROR "Building bundled FairCMakeModules failed. See ${_fcm_log}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(FairCMakeModules_ROOT ${_fcm_prefix} CACHE PATH "Location of bundled package FairCMakeModules")
|
||||
set(FairCMakeModules_BUNDLED ON CACHE BOOL "Whether bundled FairCMakeModules was used")
|
||||
message(STATUS "Building bundled FairCMakeModules - done")
|
||||
find_package(FairCMakeModules REQUIRED)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user