refactor(cmake): replace fairmq_build_option with CMake commands

- Use option() and cmake_dependent_option() directly
- Keep the error for BUILD_TESTING or BUILD_EXAMPLES without BUILD_FAIRMQ
- Option names and defaults are unchanged

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-09 22:40:43 +00:00
committed by Dennis Klein
parent d4644ae33a
commit c8d9fe355d
2 changed files with 17 additions and 63 deletions

View File

@@ -20,20 +20,24 @@ include(FairMQProjectSettings)
# Build options ################################################################ # Build options ################################################################
include(FairMQBuildOption) include(CMakeDependentOption)
fairmq_build_option(BUILD_FAIRMQ "Build FairMQ library and devices." # The dependent options below need BUILD_FAIRMQ. Keep the error for an
DEFAULT ON) # explicit request, because cmake_dependent_option() would silently disable it.
fairmq_build_option(BUILD_TESTING "Build tests." if(NOT BUILD_FAIRMQ AND DEFINED BUILD_FAIRMQ)
DEFAULT OFF REQUIRES "BUILD_FAIRMQ") foreach(opt IN ITEMS BUILD_TESTING BUILD_EXAMPLES)
fairmq_build_option(BUILD_EXAMPLES "Build FairMQ examples." if(${opt})
DEFAULT ON REQUIRES "BUILD_FAIRMQ") message(FATAL_ERROR "Cannot enable build option ${opt}, depending option is not set: BUILD_FAIRMQ")
fairmq_build_option(BUILD_TIDY_TOOL "Build the fairmq-tidy tool." endif()
DEFAULT OFF) endforeach()
fairmq_build_option(USE_EXTERNAL_GTEST "Do not use bundled GTest. Not recommended." endif()
DEFAULT OFF)
fairmq_build_option(FAIRMQ_DEBUG_MODE "Compile in debug mode (may decrease performance)." option(BUILD_FAIRMQ "Build FairMQ library and devices." ON)
DEFAULT OFF) cmake_dependent_option(BUILD_TESTING "Build tests." OFF "BUILD_FAIRMQ" OFF)
cmake_dependent_option(BUILD_EXAMPLES "Build FairMQ examples." ON "BUILD_FAIRMQ" OFF)
option(BUILD_TIDY_TOOL "Build the fairmq-tidy tool." OFF)
option(USE_EXTERNAL_GTEST "Do not use bundled GTest. Not recommended." OFF)
option(FAIRMQ_DEBUG_MODE "Compile in debug mode (may decrease performance)." OFF)
################################################################################ ################################################################################

View File

@@ -1,50 +0,0 @@
################################################################################
# Copyright (C) 2018-2021 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)
include(CMakeDependentOption)
macro(fairmq_build_option option description)
cmake_parse_arguments(ARGS "" "DEFAULT" "REQUIRES" ${ARGN})
if(ARGS_DEFAULT)
set(__default__ ON)
else()
set(__default__ OFF)
endif()
if(ARGS_REQUIRES)
set(__requires__ ${ARGS_REQUIRES})
foreach(d ${__requires__})
string(REGEX REPLACE " +" ";" __requires_condition__ "${d}")
if(${__requires_condition__})
else()
if(${option})
message(FATAL_ERROR "Cannot enable build option ${option}, depending option is not set: ${__requires_condition__}")
endif()
endif()
endforeach()
else()
set(__requires__)
endif()
if(__requires__)
cmake_dependent_option(${option} ${description} ${__default__} "${__requires__}" OFF)
else()
option(${option} ${description} ${__default__})
endif()
set(__default__)
set(__requires__)
set(__requires_condition__)
set(ARGS_DEFAULT)
set(ARGS_REQUIRES)
set(option)
set(description)
endmacro()