Skip to content

Commit f9bbd67

Browse files
committed
Shorten build type string in example builds (#478)
Part of #476. Signed-off-by: Steve Peters <[email protected]> (cherry picked from commit 5db0bf9)
1 parent 094ef53 commit f9bbd67

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

examples/CMakeLists.txt

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ include(GNUInstallDirs)
33

44
# test multiple build types
55
set(build_types Release RelWithDebInfo Debug)
6+
function(shorten_build_type build_type output_var)
7+
if (${build_type} STREQUAL "Release")
8+
set(short_bt "R")
9+
elseif (${build_type} STREQUAL "RelWithDebInfo")
10+
set(short_bt "RWD")
11+
elseif (${build_type} STREQUAL "Debug")
12+
set(short_bt "D")
13+
elseif (${build_type} STREQUAL "Coverage")
14+
set(short_bt "C")
15+
else()
16+
message(FATAL_ERROR "Unknown build_type ${build_type}")
17+
endif()
18+
set (${output_var} ${short_bt} PARENT_SCOPE)
19+
endfunction()
20+
621
find_program(EXAMPLE_LCOV_PATH lcov)
722
if (NOT WIN32 AND EXAMPLE_LCOV_PATH)
823
list(APPEND build_types Coverage)
@@ -67,7 +82,8 @@ foreach(example ${example_directories})
6782
endif()
6883

6984
foreach (build_type ${build_types})
70-
set(TEST_NAME ${example}_${build_type})
85+
shorten_build_type("${build_type}" short_bt)
86+
set(TEST_NAME ${example}_${short_bt})
7187
string(TIMESTAMP TEST_TIME)
7288
configure_file(
7389
"${CMAKE_CURRENT_SOURCE_DIR}/junit_pass.xml.in"
@@ -77,7 +93,7 @@ foreach(example ${example_directories})
7793
"${CMAKE_CURRENT_SOURCE_DIR}/junit_fail.xml.in"
7894
"${CMAKE_CURRENT_BINARY_DIR}/test_results/${TEST_NAME}.xml"
7995
@ONLY)
80-
set(example_INSTALL_DIR ${CMAKE_BINARY_DIR}/install/${build_type})
96+
set(example_INSTALL_DIR ${CMAKE_BINARY_DIR}/install/${short_bt})
8197
ExternalProject_Add(
8298
${TEST_NAME}
8399

@@ -163,17 +179,18 @@ endforeach()
163179
# hard to use DEPENDS in ExternalProject_Add because targets
164180
# need to exist before they can be used there
165181
foreach (build_type ${build_types})
166-
add_dependencies(core_child_${build_type} core_nodep_${build_type})
167-
add_dependencies(core_child_private_${build_type} core_nodep_${build_type})
168-
add_dependencies(core_static_child_${build_type} core_nodep_static_${build_type})
169-
if (TARGET use_component_depsA_${build_type})
170-
add_dependencies(use_component_depsA_${build_type} comp_deps_${build_type})
182+
shorten_build_type("${build_type}" short_bt)
183+
add_dependencies(core_child_${short_bt} core_nodep_${short_bt})
184+
add_dependencies(core_child_private_${short_bt} core_nodep_${short_bt})
185+
add_dependencies(core_static_child_${short_bt} core_nodep_static_${short_bt})
186+
if (TARGET use_component_depsA_${short_bt})
187+
add_dependencies(use_component_depsA_${short_bt} comp_deps_${short_bt})
171188
endif()
172-
if (TARGET use_component_depsB_${build_type})
173-
add_dependencies(use_component_depsB_${build_type} comp_deps_${build_type})
189+
if (TARGET use_component_depsB_${short_bt})
190+
add_dependencies(use_component_depsB_${short_bt} comp_deps_${short_bt})
174191
endif()
175-
if (TARGET use_component_depsC_${build_type})
176-
add_dependencies(use_component_depsC_${build_type} comp_deps_${build_type})
192+
if (TARGET use_component_depsC_${short_bt})
193+
add_dependencies(use_component_depsC_${short_bt} comp_deps_${short_bt})
177194
endif()
178195
endforeach()
179196

0 commit comments

Comments
 (0)