From b376d27d7a794a09d2bfbbd363f7d525ca2e66dc Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Wed, 27 Sep 2023 17:58:50 -0500 Subject: [PATCH] Upgrade to CXX-17 gtest-1.14 and cmake-3.14 Change-Id: I3bceb90f79235a9c0616c5d7ef9e37e458ffdce6 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 871fae8b2504de345f476b39e07826a581db95ab] --- projects/amdsmi/CMakeLists.txt | 6 ++-- projects/amdsmi/example/CMakeLists.txt.in | 8 ++--- .../amdsmi/tests/amd_smi_test/CMakeLists.txt | 32 +++++++++---------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index 97fa12d871..ef5b8756d2 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -1,7 +1,7 @@ # # Minimum version of cmake required # -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.14) set(AMD_SMI "amd_smi") set(AMD_SMI_COMPONENT "lib${AMD_SMI}") @@ -49,6 +49,8 @@ set(AMD_SMI_PACKAGE CACHE STRING "") project(${AMD_SMI_LIBS_TARGET}) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) include(GNUInstallDirs) @@ -78,7 +80,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY generic_package() ## Compiler flags -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -m64 -msse -msse2 -std=c++11") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -m64 -msse -msse2") # Security options set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion -Wcast-align") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2 -fno-common -Wstrict-overflow") diff --git a/projects/amdsmi/example/CMakeLists.txt.in b/projects/amdsmi/example/CMakeLists.txt.in index c4c4c6a854..589fcd6c3e 100644 --- a/projects/amdsmi/example/CMakeLists.txt.in +++ b/projects/amdsmi/example/CMakeLists.txt.in @@ -1,13 +1,11 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.14) option(CMAKE_VERBOSE_MAKEFILE "Enable verbose output" ON) option(CMAKE_EXPORT_COMPILE_COMMANDS "Export compile commands for linters and autocompleters" ON) project(main LANGUAGES CXX) - -set(CMAKE_CXX_STANDARD - 11 - CACHE STRING "The C++ standard to use") +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(amd_smi HINTS diff --git a/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt b/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt index d87bdec4c2..865042b89b 100644 --- a/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt +++ b/projects/amdsmi/tests/amd_smi_test/CMakeLists.txt @@ -7,20 +7,13 @@ set(CMAKE_INSTALL_RPATH "\$ORIGIN:\$ORIGIN/../../../lib" CACHE STRING "RUNPATH for tests. Helps find libgtest.so and libamd_smi.so") -# Try to find googletest -find_package(GTest 1.12.0) - -# GTest_FOUND is set to TRUE if ANY version is found -# GTest_VERSION is set if 1.11.0 or newer version is found -if(NOT GTest_FOUND STREQUAL "TRUE" OR NOT DEFINED GTest_VERSION) - # Google Test wasn't found. Download and compile ourselves - include(FetchContent) - FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.12.0) - FetchContent_MakeAvailable(googletest) -endif() +# Download and compile googletest +include(FetchContent) +FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.14.0) +FetchContent_MakeAvailable(googletest) enable_testing() @@ -70,10 +63,9 @@ target_link_libraries(${TEST} stdc++ pthread) -# Install tests and gtest -# TODO: Remove GTest from here in the future and rely on INSTALL_GTEST? +# Install tests install( - TARGETS ${TEST} gtest gtest_main + TARGETS ${TEST} DESTINATION ${SHARE_INSTALL_PREFIX}/tests COMPONENT ${TESTS_COMPONENT}) @@ -81,3 +73,9 @@ install( FILES amdsmitst.exclude DESTINATION ${SHARE_INSTALL_PREFIX}/tests COMPONENT ${TESTS_COMPONENT}) + +# Install googletest libraries with tests +install(TARGETS gtest gtest_main + DESTINATION ${SHARE_INSTALL_PREFIX}/tests + COMPONENT ${TESTS_COMPONENT}) +