Files
FairMQ/cmake/FairMQBundlePackageHelper.cmake
Claude 230a614bb1 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>
2026-11-10 10:21:32 +01:00

42 lines
1.5 KiB
CMake

################################################################################
# Copyright (C) 2018-2026 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
# #
# This software is distributed under the terms of the #
# GNU Lesser General Public Licence (LGPL) version 3, #
# copied verbatim in the file "LICENSE" #
################################################################################
include_guard(GLOBAL)
find_package(Git QUIET)
# fairmq_init_submodule(<path>)
#
# Checks out the Git submodule <path> (relative to PROJECT_SOURCE_DIR) if its
# folder is empty. Stops with an error if the folder stays empty.
function(fairmq_init_submodule path)
set(dir "${PROJECT_SOURCE_DIR}/${path}")
file(GLOB content "${dir}/*")
if(content)
return()
endif()
if(GIT_EXECUTABLE AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
message(STATUS "Checking out submodule ${path}")
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init -- ${path}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE log
ERROR_VARIABLE log
RESULT_VARIABLE res
)
file(GLOB content "${dir}/*")
endif()
if(NOT content)
message(FATAL_ERROR "The bundled package in ${path} is missing. "
"Run `git submodule update --init` in ${PROJECT_SOURCE_DIR}, "
"or install the package. ${log}")
endif()
endfunction()