Skip to content

Commit

Permalink
Prefer target property to set C++ standard
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeu committed Mar 20, 2024
1 parent 6e1e18d commit 0422759
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(LIBS_DIR ${CMAKE_CURRENT_BINARY_DIR}/libs)
set(EIGEN_MATIO_URL https://raw.githubusercontent.com/tesch1/eigen-matio/master/MATio)
set(EIGEN_MATIO_DIR ${LIBS_DIR}/include)
Expand Down Expand Up @@ -48,6 +45,8 @@ find_package(Eigen3 REQUIRED)
add_library(example STATIC src/example.cpp include/example.hpp)
target_include_directories(example PRIVATE ${EIGEN_MATIO_DIR})
target_link_libraries(example PRIVATE matio::matio Eigen3::Eigen)
target_compile_features(example PUBLIC cxx_std_17)
set_target_properties(example PROPERTIES CXX_EXTENSIONS OFF)

enable_testing()

Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ foreach(file ${TEST_SOURCES})
add_executable(${test_name}_Tests ${file})
target_include_directories(${test_name}_Tests PRIVATE "${CMAKE_SOURCE_DIR}/include")
target_link_libraries(${test_name}_Tests PRIVATE example GTest::GTest)
target_compile_features(${test_name}_Tests PUBLIC cxx_std_17)
set_target_properties(${test_name}_Tests PROPERTIES CXX_EXTENSIONS OFF)
gtest_add_tests(
TARGET ${test_name}_Tests
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test")
Expand Down

0 comments on commit 0422759

Please sign in to comment.