Skip to content

Commit

Permalink
Improve LIBASSERT_DESIRED_CXX_STANDARD setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed May 7, 2024
1 parent 8786768 commit 8d7c3e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
18 changes: 4 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,10 @@ target_include_directories(
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
)

# If the user has not defined a C++ standard, default to C++17
if (NOT DEFINED LIBASSERT_DESIRED_CXX_STANDARD)
target_compile_features(
${target_name}
PUBLIC cxx_std_17
)
message(STATUS "libassert: Using cxx_std_17 for target ${target_name}")
else()
target_compile_features(
${target_name}
PUBLIC ${LIBASSERT_DESIRED_CXX_STANDARD}
)
message(STATUS "libassert: Using ${LIBASSERT_DESIRED_CXX_STANDARD} for target ${target_name}")
endif()
target_compile_features(
${target_name}
PUBLIC ${LIBASSERT_DESIRED_CXX_STANDARD}
)

if(LIBASSERT_SANITIZER_BUILD)
add_compile_options(-fsanitize=address)
Expand Down
6 changes: 6 additions & 0 deletions cmake/OptionVariables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,9 @@ option(
OFF
)
option(LIBASSERT_USE_EXTERNAL_MAGIC_ENUM "Obtain magic_enum via find_package instead of FetchContent" OFF)

# -- internal --

set(LIBASSERT_DESIRED_CXX_STANDARD cxx_std_17 CACHE STRING "")

mark_as_advanced(LIBASSERT_DESIRED_CXX_STANDARD)

0 comments on commit 8d7c3e8

Please sign in to comment.