Skip to content

Commit d0d2e9d

Browse files
committed
Truly optional CMake function
1 parent 83cc36f commit d0d2e9d

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,20 @@ endfunction(add_spec)
7272
function(discover_specs spec_folder)
7373
file(GLOB_RECURSE specs ${spec_folder}/*_spec.cpp)
7474

75-
foreach(spec IN LISTS specs)
76-
add_spec(${spec} "")
77-
endforeach()
78-
endfunction(discover_specs)
79-
80-
function(discover_specs_output_junit spec_folder)
81-
file(GLOB_RECURSE specs ${spec_folder}/*_spec.cpp)
75+
if (${ARGC} GREATER 1)
76+
set(output_junit ${ARGV1})
77+
else()
78+
set(output_junit FALSE)
79+
endif()
8280

8381
foreach(spec IN LISTS specs)
84-
cmake_path(GET spec STEM spec_name)
85-
add_spec(${spec} "--output-junit;${CMAKE_CURRENT_BINARY_DIR}/results/${spec_name}.xml")
82+
if (${output_junit})
83+
add_spec(${spec} "--output-junit;${CMAKE_CURRENT_BINARY_DIR}/results/${spec_name}.xml")
84+
else()
85+
add_spec(${spec} "")
86+
endif()
8687
endforeach()
87-
endfunction(discover_specs_output_junit)
88+
endfunction()
8889

8990
# OPTIONS
9091
option(CPPSPEC_BUILD_TESTS "Build C++Spec tests")

include/formatters/formatters_base.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class BaseFormatter {
9292
case Result::Status::Skipped:
9393
return YELLOW;
9494
}
95+
return ""; // Default to no color
9596
}
9697

9798
const char* reset_color() { return color_output ? RESET : ""; }

spec/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
22
add_compile_options(-Wno-unused-parameter -Wno-missing-template-arg-list-after-template-kw -Wno-missing-template-keyword -Wno-unknown-warning-option)
33
endif()
44

5-
discover_specs_output_junit(${CMAKE_CURRENT_SOURCE_DIR})
5+
discover_specs(${CMAKE_CURRENT_SOURCE_DIR} TRUE)

0 commit comments

Comments
 (0)