Skip to content

Commit

Permalink
set C++ version where necessary, remove checks where unnecessary
Browse files Browse the repository at this point in the history
ginkgo has the PUBLIC property cxx_std_17,
so we don't need to set it in tests.
pkg-config doesn't propagate C++ standards
  • Loading branch information
upsj committed May 1, 2024
1 parent 04daff5 commit d0a5c6a
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 9 deletions.
1 change: 0 additions & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function(ginkgo_benchmark_onemkl_linops type def)
add_library(onemkl_linops_${type} utils/dpcpp_linops.dp.cpp)
# make the dependency public to catch issues
target_compile_definitions(onemkl_linops_${type} PUBLIC ${def})
target_compile_features(onemkl_linops_${type} PRIVATE cxx_std_17)
target_link_libraries(onemkl_linops_${type} PRIVATE Ginkgo::ginkgo MKL::MKL_DPCPP)
endfunction()

Expand Down
3 changes: 0 additions & 3 deletions cmake/create_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function(ginkgo_set_test_target_properties test_target_name test_library_suffix)
else()
target_link_libraries(${test_target_name} PRIVATE ginkgo_gtest_main${test_library_suffix})
endif()
target_compile_features(${test_target_name} PUBLIC cxx_std_14)
# we set these properties regardless of the enabled backends,
# because unknown properties are ignored
set_target_properties(${test_target_name} PROPERTIES HIP_STANDARD 17)
Expand Down Expand Up @@ -129,7 +128,6 @@ endfunction(ginkgo_create_test)
function(ginkgo_create_dpcpp_test test_name)
ginkgo_build_test_name(${test_name} test_target_name)
add_executable(${test_target_name} ${test_name}.dp.cpp)
target_compile_features(${test_target_name} PUBLIC cxx_std_17)
target_compile_options(${test_target_name} PRIVATE ${GINKGO_DPCPP_FLAGS})
gko_add_sycl_to_target(TARGET ${test_target_name} SOURCES ${test_name}.dp.cpp)
target_link_options(${test_target_name} PRIVATE -fsycl-device-code-split=per_kernel)
Expand Down Expand Up @@ -260,7 +258,6 @@ function(ginkgo_create_common_device_test test_name)
ginkgo_build_test_name(${test_name} test_target_name)
if(GINKGO_BUILD_SYCL)
ginkgo_create_common_test_internal(${test_name} DpcppExecutor dpcpp ${ARGN})
target_compile_features(${test_target_name}_dpcpp PRIVATE cxx_std_17)
target_compile_options(${test_target_name}_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS})
# We need to use a new file to avoid sycl setting in other backends because add_sycl_to_target will change the source property.
configure_file(${test_name}.cpp ${test_name}.dp.cpp COPYONLY)
Expand Down
1 change: 0 additions & 1 deletion dpcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ gko_add_sycl_to_target(TARGET ginkgo_dpcpp)
# Note: add MKL as PRIVATE not PUBLIC (MKL example shows) to avoid propagating
# find_package(MKL) everywhere when linking ginkgo (see the MKL example
# https://software.intel.com/content/www/us/en/develop/documentation/onemkl-windows-developer-guide/top/getting-started/cmake-config-for-onemkl.html)
target_compile_features(ginkgo_dpcpp PUBLIC cxx_std_17)
target_link_options(ginkgo_dpcpp PRIVATE -fsycl-device-lib=all)
# When building ginkgo as a static library, we need to use dpcpp and per_kernel
# link option when the program uses a dpcpp related function.
Expand Down
1 change: 0 additions & 1 deletion test/test_exportbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ 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_link_libraries(test_exportbuild PRIVATE Ginkgo::ginkgo)
1 change: 0 additions & 1 deletion test/test_install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ 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_definitions(test_install PRIVATE HAS_REFERENCE=${HAS_REFERENCE})
target_link_libraries(test_install PRIVATE Ginkgo::ginkgo)
if(GINKGO_BUILD_MPI)
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
1 change: 0 additions & 1 deletion test/test_subdir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ 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_link_libraries(test_subdir PRIVATE Ginkgo::ginkgo)

0 comments on commit d0a5c6a

Please sign in to comment.