Skip to content

Commit

Permalink
activate c++17
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Sep 18, 2024
1 parent 4e332c0 commit a11fb2e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cmake/build_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ function(ginkgo_default_includes name)
endfunction()

function(ginkgo_compile_features name)
target_compile_features("${name}" PUBLIC cxx_std_14)
target_compile_features("${name}" PUBLIC cxx_std_17)
# we set these properties regardless of the enabled backends,
# because unknown properties are ignored
set_target_properties("${name}" PROPERTIES HIP_STANDARD 14)
set_target_properties("${name}" PROPERTIES CUDA_STANDARD 14)
set_target_properties("${name}" PROPERTIES HIP_STANDARD 17)
set_target_properties("${name}" PROPERTIES CUDA_STANDARD 17)
if(GINKGO_WITH_CLANG_TIDY AND GINKGO_CLANG_TIDY_PATH)
set_property(TARGET "${name}" PROPERTY CXX_CLANG_TIDY "${GINKGO_CLANG_TIDY_PATH};-checks=*")
endif()
Expand Down
6 changes: 3 additions & 3 deletions cmake/create_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ function(ginkgo_set_test_target_properties test_target_name test_library_suffix)
target_link_libraries(${test_target_name} PRIVATE ginkgo_gtest_main${test_library_suffix})
endif()
endif()
target_compile_features(${test_target_name} PUBLIC cxx_std_14)
target_compile_features(${test_target_name} PUBLIC cxx_std_17)
# we set these properties regardless of the enabled backends,
# because unknown properties are ignored
set_target_properties(${test_target_name} PROPERTIES HIP_STANDARD 14)
set_target_properties(${test_target_name} PROPERTIES CUDA_STANDARD 14)
set_target_properties(${test_target_name} PROPERTIES HIP_STANDARD 17)
set_target_properties(${test_target_name} PROPERTIES CUDA_STANDARD 17)
target_include_directories(${test_target_name} PRIVATE ${Ginkgo_BINARY_DIR} ${set_properties_ADDITIONAL_INCLUDES})
target_link_libraries(${test_target_name} PRIVATE ginkgo GTest::GTest ${set_properties_ADDITIONAL_LIBRARIES})
endfunction()
Expand Down
2 changes: 1 addition & 1 deletion cmake/hip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ find_package(ROCTX)
if(GINKGO_HIP_AMD_UNSAFE_ATOMIC AND GINKGO_HIP_VERSION VERSION_GREATER_EQUAL 5)
set(CMAKE_HIP_FLAGS "${CMAKE_HIP_FLAGS} -munsafe-fp-atomics -Wno-unused-command-line-argument")
endif()
set(CMAKE_HIP_STANDARD 14)
set(CMAKE_HIP_STANDARD 17)
2 changes: 1 addition & 1 deletion core/test/accessor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function(create_accessor_test test_name)
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
add_executable("${TEST_TARGET_NAME}" "${test_name}.cpp")
target_compile_features("${TEST_TARGET_NAME}" PUBLIC cxx_std_14)
target_compile_features("${TEST_TARGET_NAME}" PUBLIC cxx_std_17)
target_include_directories("${TEST_TARGET_NAME}"
PRIVATE
"${Ginkgo_SOURCE_DIR}"
Expand Down
2 changes: 1 addition & 1 deletion test/test_exportbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ find_package(Ginkgo REQUIRED
# Here, we use test install without any data. We instantiate the
# interface only.
add_executable(test_exportbuild ../test_install/test_install.cpp)
target_compile_features(test_exportbuild PUBLIC cxx_std_14)
target_compile_features(test_exportbuild PUBLIC cxx_std_17)
target_link_libraries(test_exportbuild PRIVATE Ginkgo::ginkgo)
6 changes: 3 additions & 3 deletions test/test_install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (GINKGO_BUILD_REFERENCE)
set(HAS_REFERENCE 1)
endif()
add_executable(test_install test_install.cpp)
target_compile_features(test_install PUBLIC cxx_std_14)
target_compile_features(test_install PUBLIC cxx_std_17)
target_compile_definitions(test_install PRIVATE HAS_REFERENCE=${HAS_REFERENCE})
target_link_libraries(test_install PRIVATE Ginkgo::ginkgo)
if(GINKGO_BUILD_MPI)
Expand All @@ -38,7 +38,7 @@ if(GINKGO_BUILD_CUDA)
enable_language(CUDA)
configure_file(test_install.cpp test_install.cu COPYONLY)
add_executable(test_install_cuda ${CMAKE_CURRENT_BINARY_DIR}/test_install.cu)
set_target_properties(test_install_cuda PROPERTIES CUDA_STANDARD 14)
set_target_properties(test_install_cuda PROPERTIES CUDA_STANDARD 17)
target_compile_definitions(test_install_cuda PRIVATE HAS_CUDA=1)
target_compile_definitions(test_install_cuda PRIVATE HAS_REFERENCE=${HAS_REFERENCE})
target_link_libraries(test_install_cuda PRIVATE Ginkgo::ginkgo)
Expand All @@ -49,7 +49,7 @@ if(GINKGO_BUILD_HIP)
configure_file(test_install.cpp test_install.hip.cpp COPYONLY)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/test_install.hip.cpp PROPERTIES LANGUAGE HIP)
add_executable(test_install_hip ${CMAKE_CURRENT_BINARY_DIR}/test_install.hip.cpp)
set_target_properties(test_install_hip PROPERTIES HIP_STANDARD 14)
set_target_properties(test_install_hip PROPERTIES HIP_STANDARD 17)

target_link_libraries(test_install_hip PRIVATE Ginkgo::ginkgo)
target_compile_definitions(test_install_hip PRIVATE HAS_HIP=1)
Expand Down
2 changes: 1 addition & 1 deletion test/test_pkgconfig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pkg_check_modules(GINKGO REQUIRED IMPORTED_TARGET ginkgo)
# Here, we use test install without any data. We instantiate the
# interface only.
add_executable(test_pkgconfig ../test_install/test_install.cpp)
target_compile_features(test_pkgconfig PUBLIC cxx_std_14)
target_compile_features(test_pkgconfig PUBLIC cxx_std_17)
# CMake PkgConfig only puts the -l, -L, and -framework into link_libraries and others into link_options
# When linking the target, the linking option will be before the compiled object to lead the linking error
set_property(TARGET PkgConfig::GINKGO PROPERTY INTERFACE_LINK_LIBRARIES "${GINKGO_LDFLAGS}")
Expand Down
2 changes: 1 addition & 1 deletion test/test_subdir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/../.." "${CMAKE_CURRENT_BINARY_DIR
add_subdirectory("${CMAKE_CURRENT_BINARY_DIR}/ginkgo")

add_executable(test_subdir ../test_install/test_install.cpp)
target_compile_features(test_subdir PUBLIC cxx_std_14)
target_compile_features(test_subdir PUBLIC cxx_std_17)
target_link_libraries(test_subdir PRIVATE Ginkgo::ginkgo)

0 comments on commit a11fb2e

Please sign in to comment.