Skip to content

Commit

Permalink
CMake: Explicitly handle incompatible option overrides
Browse files Browse the repository at this point in the history
Provide sensible defaults for the *ONLY* builds and explicitly
verify incompatible configurations.
  • Loading branch information
Kentzo committed Jan 18, 2024
1 parent 8dd3248 commit b8f0ccc
Showing 1 changed file with 34 additions and 37 deletions.
71 changes: 34 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,60 +222,51 @@ message(STATUS "Building GammaRay ${GAMMARAY_VERSION_STRING} in ${CMAKE_BUILD_TY
#
# Build options
#
set(GAMMARAY_BUILD_UI_DEFAULT ON)
if(QNXNTO OR ANDROID)
set(GAMMARAY_BUILD_UI_DEFAULT OFF)
endif()
gammaray_option(GAMMARAY_STATIC_PROBE "Build the probe as static library for compile-time injection." OFF)
gammaray_option(GAMMARAY_INSTALL_QT_LAYOUT "Install into Qt directory layout." OFF)
gammaray_option(GAMMARAY_MULTI_BUILD "Build multiple applicable probe configurations." ON)
gammaray_option(GAMMARAY_ENFORCE_QT_ASSERTS "Force QT_ASSERT in all builds." OFF)

set(GAMMARAY_PROBE_ONLY_BUILD_DEFAULT OFF)
if(GAMMARAY_STATIC_PROBE)
set(GAMMARAY_PROBE_ONLY_BUILD_DEFAULT ON)
endif()
gammaray_option(
GAMMARAY_PROBE_ONLY_BUILD "Build only an additional probe configuration for an already existing launcher." OFF
GAMMARAY_PROBE_ONLY_BUILD "Build only an additional probe configuration for an already existing launcher." ${GAMMARAY_PROBE_ONLY_BUILD_DEFAULT}
)

gammaray_option(GAMMARAY_CLIENT_ONLY_BUILD "Build the client part only." OFF)

if(GAMMARAY_CLIENT_ONLY_BUILD)
set(GAMMARAY_BUILD_UI_DEFAULT ON)
endif()

if(GAMMARAY_PROBE_ONLY_BUILD)
set(GAMMARAY_BUILD_UI_DEFAULT OFF)
if(GAMMARAY_STATIC_PROBE AND NOT GAMMARAY_PROBE_ONLY_BUILD)
message(FATAL_ERROR "Must use PROBE_ONLY_BUILD for STATIC_PROBE.")
elseif(GAMMARAY_STATIC_PROBE)
set(GAMMARAY_LIBRARY_TYPE STATIC)
set(GAMMARAY_PLUGIN_TYPE STATIC)
else()
set(GAMMARAY_LIBRARY_TYPE SHARED)
set(GAMMARAY_PLUGIN_TYPE MODULE)
endif()

gammaray_option(GAMMARAY_BUILD_UI "Build the GammaRay client and in-process UI." ${GAMMARAY_BUILD_UI_DEFAULT})

gammaray_option(GAMMARAY_CLIENT_ONLY_BUILD "Build the client part only." OFF)
if(GAMMARAY_PROBE_ONLY_BUILD AND GAMMARAY_CLIENT_ONLY_BUILD)
message(FATAL_ERROR "You can only use one of the *ONLY* option.")
message(FATAL_ERROR "Cannot use PROBE_ONLY_BUILD and CLIENT_ONLY_BUILD at the same time.")
endif()

gammaray_option(GAMMARAY_INSTALL_QT_LAYOUT "Install into Qt directory layout." OFF)
gammaray_option(GAMMARAY_MULTI_BUILD "Build multiple applicable probe configurations." ON)
gammaray_option(GAMMARAY_BUILD_CLI_INJECTOR "Build command line injector on Windows." ON)

set(GAMMARAY_BUILD_DOCS_DEFAULT ON)
set(GAMMARAY_DISABLE_FEEDBACK_DEFAULT OFF)
if(GAMMARAY_PROBE_ONLY_BUILD OR CMAKE_CROSSCOMPILING)
set(GAMMARAY_BUILD_DOCS_DEFAULT OFF)
set(GAMMARAY_DISABLE_FEEDBACK_DEFAULT ON)
endif()
gammaray_option(GAMMARAY_BUILD_DOCS "Build GammaRay documentation." ${GAMMARAY_BUILD_DOCS_DEFAULT})
gammaray_option(GAMMARAY_STATIC_PROBE "Build the probe as static library for compile-time injection." OFF)

gammaray_option(GAMMARAY_ENFORCE_QT_ASSERTS "Force QT_ASSERT in all builds." OFF)

gammaray_option(GAMMARAY_DISABLE_FEEDBACK "Disable user feedback support." ${GAMMARAY_DISABLE_FEEDBACK_DEFAULT})

#
# Static probe setup
#
if(GAMMARAY_STATIC_PROBE)
set(GAMMARAY_BUILD_UI OFF)
set(GAMMARAY_PROBE_ONLY_BUILD ON)

set(GAMMARAY_LIBRARY_TYPE STATIC)
set(GAMMARAY_PLUGIN_TYPE STATIC)
else()
set(GAMMARAY_LIBRARY_TYPE SHARED)
set(GAMMARAY_PLUGIN_TYPE MODULE)
set(GAMMARAY_BUILD_UI_DEFAULT ON)
if(GAMMARAY_PROBE_ONLY_BUILD)
set(GAMMARAY_BUILD_UI_DEFAULT OFF)
elseif(QNXNTO OR ANDROID)
set(GAMMARAY_BUILD_UI_DEFAULT OFF)
endif()
gammaray_option(GAMMARAY_BUILD_UI "Build the GammaRay client and in-process UI." ${GAMMARAY_BUILD_UI_DEFAULT})
if(GAMMARAY_BUILD_UI AND GAMMARAY_PROBE_ONLY_BUILD)
message(FATAL_ERROR "Cannot use BUILD_UI and PROBE_ONLY_BUILD at the same time.")
endif()

gammaray_option(GAMMARAY_USE_PCH "Enable Precompiled Headers support" OFF)
Expand All @@ -297,6 +288,12 @@ if(GAMMARAY_USE_PCH)
)
endif()

if(WIN32)
gammaray_option(GAMMARAY_BUILD_CLI_INJECTOR "Build command line injector on Windows." ON)
else()
set(GAMMARAY_BUILD_CLI_INJECTOR OFF)
endif()

#
# Compiler & linker settings
#
Expand Down

0 comments on commit b8f0ccc

Please sign in to comment.