Skip to content

[benchmark] Only add -external suffix to targets in standalone builds where SWIFT_BENCHMARK_SUBCMAKE_BUILD is set. #12208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ cmake_minimum_required(VERSION 2.8.12)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

# Load utility modules.
include(SwiftBenchmarkUtils)

set(SWIFT_BENCHMARK_BUILT_STANDALONE FALSE)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
set(SWIFT_BENCHMARK_BUILT_STANDALONE TRUE)
endif()

if(SWIFT_BENCHMARK_SUBCMAKE_BUILD)
precondition(SWIFT_BENCHMARK_BUILD_STANDALONE
MESSAGE "If we are a subcmake build, we must be built standalone")
endif()

include(AddSwiftBenchmarkSuite)

set(SWIFT_BENCH_MODULES
Expand Down
18 changes: 9 additions & 9 deletions benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -488,15 +488,15 @@ function(swift_benchmark_compile)
list(APPEND platform_executables ${new_output_exec})
endforeach()

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

add_custom_target("${executable_target}"
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/SwiftExternalBenchmarkBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function (add_external_benchmark_suite)
-DSWIFT_LIBRARY_PATH=${SWIFT_BINARY_DIR}/lib/swift
-DCMAKE_C_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang
-DCMAKE_CXX_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang++
-DSWIFT_BENCHMARK_SUBCMAKE_BUILD=TRUE
PASSTHROUGH_PREFIXES SWIFT_BENCHMARK
)
endfunction()