Skip to content

Commit

Permalink
Improve information content of GCC error messages.
Browse files Browse the repository at this point in the history
Frequently, GCC prints error messages, but, ironically, they're too
short, it'll include the inner most context, somewhere deep inside the
STL or some other external libary, then skip all the HighFive context
and continue printing the outer most layers which typically happen to be
in Catch2.
  • Loading branch information
1uc committed Apr 19, 2024
1 parent 5ab4752 commit 5f7c051
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions cmake/HighFiveWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if(TARGET HighFiveWarnings)
endif()

add_library(HighFiveWarnings INTERFACE)
add_library(HighFiveFlags INTERFACE)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang"
OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
Expand All @@ -32,6 +33,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang"
-Wdouble-promotion
)

target_compile_options(HighFiveWarnings
INTERFACE
-ftemplate-backtrace-limit=0
)

if(HIGHFIVE_MAX_ERRORS)
target_compile_options(HighFiveWarnings
INTERFACE
Expand Down
2 changes: 1 addition & 1 deletion src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function(compile_example example_source)
message("example_name: ${example_name}")

add_executable(${example_name} ${example_source})
target_link_libraries(${example_name} PUBLIC HighFive HighFiveWarnings)
target_link_libraries(${example_name} PUBLIC HighFive HighFiveWarnings HighFiveFlags)
if(${ARGC} EQUAL 2)
target_link_libraries(${example_name} PUBLIC ${ARGV1})
endif()
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif()
## Base tests
foreach(test_name tests_high_five_base tests_high_five_multi_dims tests_high_five_easy test_all_types test_high_five_selection tests_high_five_data_type test_legacy)
add_executable(${test_name} "${test_name}.cpp")
target_link_libraries(${test_name} HighFive HighFiveWarnings Catch2::Catch2WithMain)
target_link_libraries(${test_name} HighFive HighFiveWarnings HighFiveFlags Catch2::Catch2WithMain)
target_link_libraries(${test_name} HighFiveOptionalDependencies)

catch_discover_tests(${test_name})
Expand All @@ -19,7 +19,7 @@ if(HIGHFIVE_PARALLEL_HDF5)

## parallel MPI tests
add_executable(tests_parallel_bin ${tests_parallel_src})
target_link_libraries(tests_parallel_bin HighFive HighFiveWarnings Catch2::Catch2)
target_link_libraries(tests_parallel_bin HighFive HighFiveWarnings HighFiveFlags Catch2::Catch2)
target_link_libraries(tests_parallel_bin HighFiveOptionalDependencies)

# We need to patch in a call to `mpirun` or equivalent when using
Expand Down Expand Up @@ -62,6 +62,6 @@ if(HIGHFIVE_TEST_SINGLE_INCLUDES)
get_filename_component(CLASS_NAME ${PUBLIC_HEADER} NAME_WE)
configure_file(tests_import_public_headers.cpp "tests_${CLASS_NAME}.cpp" @ONLY)
add_executable("tests_include_${CLASS_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/tests_${CLASS_NAME}.cpp")
target_link_libraries("tests_include_${CLASS_NAME}" HighFive HighFiveWarnings)
target_link_libraries("tests_include_${CLASS_NAME}" HighFive HighFiveWarnings HighFiveFlags)
endforeach()
endif()

0 comments on commit 5f7c051

Please sign in to comment.