Skip to content

Commit

Permalink
Fix CMake code.
Browse files Browse the repository at this point in the history
Includes changes:
  * an inconsistency in `HIGHFIVE_MAX_ERRORS`,
  * less deeply nest `if-if` statements,
  * removes debug output.
  • Loading branch information
1uc committed Jun 9, 2024
1 parent 5f3ded6 commit 37650df
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ option(HIGHFIVE_TEST_HALF_FLOAT "Enable half-precision floats" OFF)
# TODO remove entirely.
option(HIGHFIVE_HAS_CONCEPTS "Print readable compiler errors w/ C++20 concepts" OFF)

set(HIGHFIVE_MAX_ERROR 0 "Maximum number of compiler errors.")
set(HIGHFIVE_MAX_ERRORS 0 CACHE STRING "Maximum number of compiler errors.")
option(HIGHFIVE_HAS_WERROR "Convert warnings to errors." OFF)
option(HIGHFIVE_GLIBCXX_ASSERTIONS "Enable bounds check for STL." OFF)
# TODO these some magic to get a drop down menu in ccmake
Expand Down
44 changes: 23 additions & 21 deletions cmake/HighFiveWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,35 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang"
-Wconversion
-Wsign-conversion
)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(HighFiveWarnings
INTERFACE
-Wpedantic
-Wcast-align
-Wdouble-promotion
)

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

if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel")
if(HIGHFIVE_HAS_WERROR)
target_compile_options(HighFiveWarnings
INTERFACE
-Wpedantic
-Wcast-align
-Wdouble-promotion
-Werror
-Wno-error=deprecated-declarations
)
endif()
endif()

target_compile_options(HighFiveWarnings
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(HIGHFIVE_MAX_ERRORS)
target_compile_options(HighFiveFlags
INTERFACE
-ftemplate-backtrace-limit=0
-fmax-errors=${HIGHFIVE_MAX_ERRORS}
)

if(HIGHFIVE_MAX_ERRORS)
target_compile_options(HighFiveFlags
INTERFACE
-fmax-errors=${HIGHFIVE_MAX_ERRORS}
)
endif()

if(HIGHFIVE_HAS_WERROR)
target_compile_options(HighFiveWarnings
INTERFACE
-Werror
-Wno-error=deprecated-declarations
)
endif()
endif()
endif()
2 changes: 1 addition & 1 deletion doc/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ctest --test-dir build

You might want to add:
* `-DHIGHFIVE_TEST_BOOST=On` or other optional dependencies on,
* `-DHIGHFIVE_MAX_ERROR=3` to only show the first three errors.
* `-DHIGHFIVE_MAX_ERRORS=3` to only show the first three errors.

Generic CMake reminders:
* `-DCMAKE_INSTALL_PREFIX` defines where HighFive will be installed,
Expand Down
1 change: 0 additions & 1 deletion src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ set(half_float_examples
function(compile_example example_source)
get_filename_component(example_filename ${example_source} NAME)
string(REPLACE ".cpp" "_bin" example_name ${example_filename})
message("example_name: ${example_name}")

add_executable(${example_name} ${example_source})
target_link_libraries(${example_name} PUBLIC HighFive HighFiveWarnings HighFiveFlags)
Expand Down

0 comments on commit 37650df

Please sign in to comment.