Skip to content

Commit

Permalink
馃敡 Update compile flags for default building
Browse files Browse the repository at this point in the history
This updates the compile flags to test correctness when building
cross-platform.
  • Loading branch information
bitwizeshift committed Mar 12, 2021
1 parent 84801f2 commit 2f4f12e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,23 @@ target_include_directories(${PROJECT_NAME}
INTERFACE $<INSTALL_INTERFACE:include>
)

if ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND
"${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
# clang-cl does not appear to implement '-pedantic' or 'pedantic-errors',
# so this case needs to be handled specifically
add_compile_options(-Wall -Werror -Wextra)

# Disable the ridiculous compatibility warnings, since it fails on files not
# ending in newlines
add_compile_options(-Wno-c++98-compat -Wno-c++98-compat-pedantic)

# This gives an unbelievable amount of false-positives spuriously. Ignore it.
add_compile_options(-Wno-unneeded-member-function)
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
add_compile_options(-Wall -Werror -Wextra -pedantic -pedantic-errors)
elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" )
# TODO: Determine MSVC necessary compiler flags
add_compile_options(/W4 /WX)
endif ()

# Header Self-Containment Tests
Expand Down Expand Up @@ -127,4 +139,4 @@ install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION "${BPSTD_CMAKE_CONFIG_DESTINATION}"
)
)
10 changes: 0 additions & 10 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ target_link_libraries(unit_tests
PRIVATE Catch2::Catch2
)

if ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
target_compile_options(unit_tests
PRIVATE -Wall -Werror -Wextra -pedantic -pendantic-errors
)
elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" )
# TODO: Determine MSVC necessary compiler flags
endif ()


set_target_properties(${UNITTEST_TARGET_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
Expand Down

0 comments on commit 2f4f12e

Please sign in to comment.