Skip to content
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
2 changes: 1 addition & 1 deletion DataFormats/Detectors/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ o2_add_test(CTFEntropyCoder
COMPONENT_NAME DetectorsCommonDataFormats
TARGETVARNAME TEST_CTF_ENTROPY_CODER
LABELS detectorsbase)
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
if(BUILD_TESTING AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
target_compile_options(${TEST_CTF_ENTROPY_CODER} PRIVATE -march=native)
endif()
4 changes: 4 additions & 0 deletions Utilities/rANS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ if(${ENABLE_VTUNE_PROFILER})
target_link_libraries(${LIBRANS} INTERFACE PkgConfig::Vtune)
endif()

# o2_add_test() returns early when BUILD_TESTING is off, so TARGETVARNAME is
# never set and the target_compile_options() below would see an empty target.
if(BUILD_TESTING)
o2_add_test(Utils
NAME ransUtils
SOURCES test/test_ransUtils.cxx
Expand Down Expand Up @@ -186,6 +189,7 @@ o2_add_test(Serialize
TARGETVARNAME TEST_SERIALIZE
LABELS utils)
target_compile_options(${TEST_SERIALIZE} PRIVATE ${RANS_TEST_ARCH})
endif()

if (TARGET benchmark::benchmark)
o2_add_header_only_library(libransBenchmark
Expand Down
14 changes: 10 additions & 4 deletions cmake/O2AddTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ include(O2AddExecutable)

function(o2_add_test)

if(NOT BUILD_TESTING)
return()
endif()

cmake_parse_arguments(
PARSE_ARGV
1
Expand All @@ -80,6 +76,16 @@ function(o2_add_test)
message(FATAL_ERROR "Unexpected unparsed arguments: ${A_UNPARSED_ARGUMENTS}")
endif()

# Parsed before this check so TARGETVARNAME can be defined (empty) even when
# no target is made: `if(VAR)` at the call site is then reliable, and a value
# left by an earlier call cannot leak into it.
if(NOT BUILD_TESTING)
if(A_TARGETVARNAME)
set(${A_TARGETVARNAME} "" PARENT_SCOPE)
endif()
return()
endif()

set(testName ${ARGV0})

set(linkLibraries ${A_PUBLIC_LINK_LIBRARIES})
Expand Down
Loading