diff --git a/projects/rocm-smi-lib/CMakeLists.txt b/projects/rocm-smi-lib/CMakeLists.txt index dd4c5d53f2..a16e48ba7f 100755 --- a/projects/rocm-smi-lib/CMakeLists.txt +++ b/projects/rocm-smi-lib/CMakeLists.txt @@ -1,11 +1,11 @@ # -# Minimum version of cmake required +# Minimum version of cmake and C++ required # -cmake_minimum_required(VERSION 3.6.3) +cmake_minimum_required(VERSION 3.14) -set(AMD_SMI_LIBS_TARGET "amd_smi_libraries") +set(ROCM_SMI_LIBS_TARGET "rocm_smi_libraries") -set ( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library (.so) or not.") +set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library (.so) or not.") ## Set default module path if not already set if(NOT DEFINED CMAKE_MODULE_PATH) @@ -37,10 +37,10 @@ find_program (GIT NAMES git) set(PKG_VERSION_GIT_TAG_PREFIX "rsmi_pkg_ver") get_package_version_number("5.0.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT) message("Package version: ${PKG_VERSION_STR}") -set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${VERSION_MAJOR}") -set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${VERSION_MINOR}") -set(${AMD_SMI_LIBS_TARGET}_VERSION_PATCH "0") -set(${AMD_SMI_LIBS_TARGET}_VERSION_BUILD "0") +set(${ROCM_SMI_LIBS_TARGET}_VERSION_MAJOR "${VERSION_MAJOR}") +set(${ROCM_SMI_LIBS_TARGET}_VERSION_MINOR "${VERSION_MINOR}") +set(${ROCM_SMI_LIBS_TARGET}_VERSION_PATCH "0") +set(${ROCM_SMI_LIBS_TARGET}_VERSION_BUILD "0") # The following default version values should be updated as appropriate for # ABI breaks (update MAJOR and MINOR), and ABI/API additions (update MINOR). @@ -57,7 +57,9 @@ set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE STRING "Default installation director set(COMMON_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Location source code common root.") set(ROCM_SMI_PACKAGE rocm-smi-lib) -project(${AMD_SMI_LIBS_TARGET}) +project(${ROCM_SMI_LIBS_TARGET}) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) include(GNUInstallDirs) set(COMMON_PROJ_ROOT ${PROJECT_SOURCE_DIR}) @@ -70,7 +72,7 @@ endif() ## Compiler flags set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -m64 -msse -msse2 -std=c++11 ") + "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -m64 -msse -msse2 ") # Security options set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion -Wcast-align ") @@ -78,7 +80,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2 -fno-common -Wstrict-overflow ") # Intentionally leave out -Wsign-promo. It causes spurious warnings. set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wreorder ") + "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wreorder ") # Clang does not set the build-id if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") diff --git a/projects/rocm-smi-lib/tests/rocm_smi_test/CMakeLists.txt b/projects/rocm-smi-lib/tests/rocm_smi_test/CMakeLists.txt index efdbe96469..2253327813 100755 --- a/projects/rocm-smi-lib/tests/rocm_smi_test/CMakeLists.txt +++ b/projects/rocm-smi-lib/tests/rocm_smi_test/CMakeLists.txt @@ -36,24 +36,13 @@ set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${RSMITST_RPATH}) -# TODO: Try to find googletest -# DISABLED because we want to install gtest with rocm_smi_lib ourselves -#find_package(GTest 1.12.0) - -# GTest_FOUND is set to TRUE if ANY version is found -# GTest_VERSION is set if 1.12.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) - install(TARGETS gtest gtest_main - DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests - COMPONENT ${TESTS_COMPONENT}) -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) # Other source directories aux_source_directory(${SRC_DIR}/functional functionalSources) @@ -70,13 +59,13 @@ target_include_directories(${RSMITST} PUBLIC ${SRC_DIR}/..) target_link_libraries( ${RSMITST} PUBLIC ${ROCM_SMI_TARGET} - PUBLIC gtest - PUBLIC gtest_main + PUBLIC GTest::gtest_main PUBLIC c PUBLIC stdc++ PUBLIC pthread PUBLIC dl) +# install tests install(TARGETS ${RSMITST} DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests COMPONENT ${TESTS_COMPONENT}) @@ -84,3 +73,9 @@ install(TARGETS ${RSMITST} install(FILES rsmitst.exclude DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests COMPONENT ${TESTS_COMPONENT}) + +# install googletest libraries with tests +install(TARGETS gtest gtest_main + DESTINATION ${SHARE_INSTALL_PREFIX}/rsmitst_tests + COMPONENT ${TESTS_COMPONENT}) +