mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-26 05:31:36 +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:
@@ -39,20 +39,41 @@ endif()
|
||||
|
||||
if(BUILD_FAIRMQ)
|
||||
find_package2(PRIVATE ZeroMQ REQUIRED VERSION 4.1.4)
|
||||
if(NOT PicoSHA2_BUNDLED)
|
||||
build_bundled(PicoSHA2 extern/PicoSHA2)
|
||||
endif()
|
||||
# Header-only, always bundled
|
||||
fairmq_init_submodule(extern/PicoSHA2)
|
||||
set(PicoSHA2_ROOT ${PROJECT_SOURCE_DIR}/extern/PicoSHA2)
|
||||
set(PicoSHA2_BUNDLED ON)
|
||||
find_package2(BUNDLED PicoSHA2 REQUIRED)
|
||||
set(PicoSHA2_VERSION "1.0.0")
|
||||
set(PicoSHA2_PREFIX "<bundled>")
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
if(NOT GTest_FOUND AND NOT GTest_BUNDLED AND NOT USE_EXTERNAL_GTEST)
|
||||
build_bundled(GTest extern/googletest)
|
||||
endif()
|
||||
find_package2(BUNDLED GTest REQUIRED)
|
||||
if(GTest_BUNDLED)
|
||||
if(USE_EXTERNAL_GTEST)
|
||||
find_package2(PRIVATE GTest REQUIRED)
|
||||
else()
|
||||
# Build the bundled GoogleTest as part of this build, with the same
|
||||
# compiler and flags. OVERRIDE_FIND_PACKAGE lets find_package(GTest)
|
||||
# below find it.
|
||||
fairmq_init_submodule(extern/googletest)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(GTest
|
||||
SOURCE_DIR ${PROJECT_SOURCE_DIR}/extern/googletest
|
||||
OVERRIDE_FIND_PACKAGE
|
||||
)
|
||||
block()
|
||||
set(BUILD_GMOCK OFF)
|
||||
set(INSTALL_GTEST OFF)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
# Do not analyse third-party code
|
||||
set(CMAKE_CXX_CLANG_TIDY "")
|
||||
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "")
|
||||
set(CMAKE_CXX_CPPLINT "")
|
||||
FetchContent_MakeAvailable(GTest)
|
||||
endblock()
|
||||
set(GTest_BUNDLED ON)
|
||||
find_package2(BUNDLED GTest REQUIRED)
|
||||
set(GTest_VERSION "Dec 26 2024 @7d76a23")
|
||||
set(GTest_PREFIX "<bundled>")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user