Skip to content

Commit 2323991

Browse files
authored
Merge pull request #12208 from gottesmm/pr-d7a43e8fc00361e35ead91db5b65290ee5091091
[benchmark] Only add -external suffix to targets in standalone builds where SWIFT_BENCHMARK_SUBCMAKE_BUILD is set.
2 parents 36a21ec + 48f4a27 commit 2323991

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

benchmark/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ cmake_minimum_required(VERSION 2.8.12)
1111
list(APPEND CMAKE_MODULE_PATH
1212
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
1313

14+
# Load utility modules.
15+
include(SwiftBenchmarkUtils)
16+
1417
set(SWIFT_BENCHMARK_BUILT_STANDALONE FALSE)
1518
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
1619
set(SWIFT_BENCHMARK_BUILT_STANDALONE TRUE)
1720
endif()
1821

22+
if(SWIFT_BENCHMARK_SUBCMAKE_BUILD)
23+
precondition(SWIFT_BENCHMARK_BUILD_STANDALONE
24+
MESSAGE "If we are a subcmake build, we must be built standalone")
25+
endif()
26+
1927
include(AddSwiftBenchmarkSuite)
2028

2129
set(SWIFT_BENCH_MODULES

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,15 +488,15 @@ function(swift_benchmark_compile)
488488
list(APPEND platform_executables ${new_output_exec})
489489
endforeach()
490490

491-
# If we are building standalone, we add the -external suffix to all of our
492-
# cmake target names. This enables the main swift build to simple create
493-
# -external targets and forward them via AddExternalProject to the
494-
# standalone benchmark project. The reason why this is necessary is that we
495-
# want to be able to support in-tree and out-of-tree benchmark builds at the
496-
# same time implying that we need some sort of way to distinguish the
497-
# in-tree (which don't have the suffix) from the out of tree target (which
498-
# do).
499-
translate_flag(SWIFT_BENCHMARK_BUILT_STANDALONE "-external" external)
491+
# If we are building standalone as part of a subcmake build, we add the
492+
# -external suffix to all of our cmake target names. This enables the main
493+
# swift build to simple create -external targets and forward them via
494+
# AddExternalProject to the standalone benchmark project. The reason why
495+
# this is necessary is that we want to be able to support in-tree and
496+
# out-of-tree benchmark builds at the same time implying that we need some
497+
# sort of way to distinguish the in-tree (which don't have the suffix) from
498+
# the out of tree target (which do).
499+
translate_flag(SWIFT_BENCHMARK_SUBCMAKE_BUILD "-external" external)
500500
set(executable_target "swift-benchmark-${SWIFT_BENCHMARK_COMPILE_PLATFORM}-${arch}${external}")
501501

502502
add_custom_target("${executable_target}"

cmake/modules/SwiftExternalBenchmarkBuild.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function (add_external_benchmark_suite)
8484
-DSWIFT_LIBRARY_PATH=${SWIFT_BINARY_DIR}/lib/swift
8585
-DCMAKE_C_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang
8686
-DCMAKE_CXX_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang++
87+
-DSWIFT_BENCHMARK_SUBCMAKE_BUILD=TRUE
8788
PASSTHROUGH_PREFIXES SWIFT_BENCHMARK
8889
)
8990
endfunction()

0 commit comments

Comments
 (0)