File tree Expand file tree Collapse file tree
DataFormats/Detectors/Common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,6 @@ o2_add_test(CTFEntropyCoder
6060 COMPONENT_NAME DetectorsCommonDataFormats
6161 TARGETVARNAME TEST_CTF_ENTROPY_CODER
6262 LABELS detectorsbase )
63- if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" )
63+ if (BUILD_TESTING AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" )
6464 target_compile_options (${TEST_CTF_ENTROPY_CODER} PRIVATE -march=native )
6565endif ()
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ if(${ENABLE_VTUNE_PROFILER})
5151 target_link_libraries (${LIBRANS} INTERFACE PkgConfig::Vtune )
5252endif ()
5353
54+ # o2_add_test() returns early when BUILD_TESTING is off, so TARGETVARNAME is
55+ # never set and the target_compile_options() below would see an empty target.
56+ if (BUILD_TESTING)
5457o2_add_test (Utils
5558 NAME ransUtils
5659 SOURCES test /test_ransUtils.cxx
@@ -186,6 +189,7 @@ o2_add_test(Serialize
186189 TARGETVARNAME TEST_SERIALIZE
187190 LABELS utils )
188191 target_compile_options (${TEST_SERIALIZE} PRIVATE ${RANS_TEST_ARCH} )
192+ endif ()
189193
190194if (TARGET benchmark::benchmark)
191195 o2_add_header_only_library (libransBenchmark
Original file line number Diff line number Diff line change @@ -63,10 +63,6 @@ include(O2AddExecutable)
6363
6464function (o2_add_test )
6565
66- if (NOT BUILD_TESTING)
67- return ()
68- endif ()
69-
7066 cmake_parse_arguments (
7167 PARSE_ARGV
7268 1
@@ -80,6 +76,16 @@ function(o2_add_test)
8076 message (FATAL_ERROR "Unexpected unparsed arguments: ${A_UNPARSED_ARGUMENTS} " )
8177 endif ()
8278
79+ # Parsed before this check so TARGETVARNAME can be defined (empty) even when
80+ # no target is made: `if(VAR)` at the call site is then reliable, and a value
81+ # left by an earlier call cannot leak into it.
82+ if (NOT BUILD_TESTING)
83+ if (A_TARGETVARNAME)
84+ set (${A_TARGETVARNAME} "" PARENT_SCOPE )
85+ endif ()
86+ return ()
87+ endif ()
88+
8389 set (testName ${ARGV0} )
8490
8591 set (linkLibraries ${A_PUBLIC_LINK_LIBRARIES} )
You can’t perform that action at this time.
0 commit comments