Merge 'build: cmake: add "mode_list" target ' from Kefu Chai

scylla uses build modes like "debug" and "release" to differentiate
different build modes. while we intend to use the typical build
configurations / build types used by CMake like "Debug" and
"RelWithDebInfo" for naming CMAKE_CONFIGURATION_TYPES and
CMAKE_BUILD_TYPE. the former is used for naming the build directory and
for the preprocess macro named "SCYLLA_BUILD_MODE".

`test.py` and scylladb's CI are designed based on the naming of build
directory. in which, `test.py` lists the build modes using the dedicated
build target named `list_modes`, which is added by `configure.py`.

so, in this change, the target is added to CMake as well. the variables
of "scylla_build_mode" defined by the per-mode configuration are
collected and printed by the `list_modes`.

because, by default, CMake generates a target for each build
configuration when a multi-config generator is used. but we only want to
print the build mode for a single time when "list_modes" is built. so
a "BYPRODUCTS" is deliberately added for the target, and the patch of
this "BYPRODUCTS" is named without the "$<CONFIG>" it its path.

Closes scylladb/scylladb#16532

* github.com:scylladb/scylladb:
  build: cmake: add "mode_list" target
  build: cmake: define scylla_build_mode
This commit is contained in:
Avi Kivity
2023-12-25 18:20:34 +02:00
6 changed files with 19 additions and 5 deletions

View File

@@ -28,9 +28,18 @@ include(mode.common)
if(CMAKE_CONFIGURATION_TYPES)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
include(mode.${config})
list(APPEND scylla_build_modes ${scylla_build_mode})
endforeach()
add_custom_target(mode_list
COMMAND ${CMAKE_COMMAND} -E echo "$<JOIN:${scylla_build_modes}, >"
COMMENT "List configured modes"
BYPRODUCTS mode-list.phony.stamp
COMMAND_EXPAND_LISTS)
else()
include(mode.${CMAKE_BUILD_TYPE})
add_custom_target(mode_list
${CMAKE_COMMAND} -E echo "${scylla_build_mode}"
COMMENT "List configured modes")
endif()
add_compile_definitions(

View File

@@ -7,8 +7,9 @@ update_cxx_flags(CMAKE_CXX_FLAGS_COVERAGE
WITH_DEBUG_INFO
OPTIMIZATION_LEVEL "g")
set(scylla_build_mode "coverage")
set(Seastar_DEFINITIONS_COVERAGE
SCYLLA_BUILD_MODE=coverage
SCYLLA_BUILD_MODE=${scylla_build_mode}
DEBUG
SANITIZE
DEBUG_LSA_SANITIZER

View File

@@ -9,8 +9,9 @@ update_cxx_flags(CMAKE_CXX_FLAGS_DEBUG
WITH_DEBUG_INFO
OPTIMIZATION_LEVEL ${OptimizationLevel})
set(scylla_build_mode "debug")
set(Seastar_DEFINITIONS_DEBUG
SCYLLA_BUILD_MODE=debug
SCYLLA_BUILD_MODE=${scylla_build_mode}
DEBUG
SANITIZE
DEBUG_LSA_SANITIZER

View File

@@ -6,8 +6,9 @@ set(CMAKE_CXX_FLAGS_DEV
update_cxx_flags(CMAKE_CXX_FLAGS_DEV
OPTIMIZATION_LEVEL "2")
set(scylla_build_mode "dev")
set(Seastar_DEFINITIONS_DEV
SCYLLA_BUILD_MODE=dev
SCYLLA_BUILD_MODE=${scylla_build_mode}
DEVEL
SEASTAR_ENABLE_ALLOC_FAILURE_INJECTION
SCYLLA_ENABLE_ERROR_INJECTION)

View File

@@ -7,8 +7,9 @@ update_cxx_flags(CMAKE_CXX_FLAGS_RELWITHDEBINFO
WITH_DEBUG_INFO
OPTIMIZATION_LEVEL "3")
set(scylla_build_mode "release")
add_compile_definitions(
$<$<CONFIG:RelWithDebInfo>:SCYLLA_BUILD_MODE=release>)
$<$<CONFIG:RelWithDebInfo>:SCYLLA_BUILD_MODE=${scylla_build_mode}>)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
set(clang_inline_threshold 300)

View File

@@ -7,8 +7,9 @@ update_cxx_flags(CMAKE_CXX_FLAGS_SANITIZE
WITH_DEBUG_INFO
OPTIMIZATION_LEVEL "s")
set(scylla_build_mode "sanitize")
set(Seastar_DEFINITIONS_SANITIZE
SCYLLA_BUILD_MODE=sanitize
SCYLLA_BUILD_MODE=${scylla_build_mode}
DEBUG
SANITIZE
DEBUG_LSA_SANITIZER