diff --git a/catch/CMakeLists.txt b/catch/CMakeLists.txt index 0f08c3416b..ecd12b3608 100644 --- a/catch/CMakeLists.txt +++ b/catch/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_CXX_COMPILER_WORKS 1) project(hiptests) option(ENABLE_ADDRESS_SANITIZER "Option to enable ASAN build" OFF) - +option(BUILD_SHARED_LIBS "Option for testing shared libraries" ON) # flag to generate standalone exe per src file. message(STATUS "STANDALONE_TESTS : ${STANDALONE_TESTS}") @@ -67,6 +67,17 @@ execute_process(COMMAND ${HIP_PATH}/bin/${HIPCONFIG_EXEC} --version OUTPUT_VARIABLE HIP_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT WIN32) + if(NOT BUILD_SHARED_LIBS) + list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH} ${ROCM_PATH}/llvm) + find_package(amd_comgr) + find_package(hsa-runtime64) + link_libraries(hsa-runtime64::hsa-runtime64) + link_libraries(amd_comgr) + link_libraries(hiprtc-builtins) + endif() # end BUILD_SHARED_LIBS +endif() # end win32 + # enforce c++17 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++17") diff --git a/catch/packaging/CMakeLists.txt b/catch/packaging/CMakeLists.txt index 1b124bb847..638a0f6c76 100644 --- a/catch/packaging/CMakeLists.txt +++ b/catch/packaging/CMakeLists.txt @@ -34,8 +34,11 @@ set(CPACK_SET_DESTDIR TRUE) if(NOT DEFINED CPACK_INSTALL_PREFIX) set(CPACK_INSTALL_PREFIX "/opt/rocm/") endif() - -set(PKG_NAME hip-catch-${HIP_PLATFORM}) +if(BUILD_SHARED_LIBS) + set(PKG_NAME hip-catch-${HIP_PLATFORM}) +else() + set(PKG_NAME hip-catch-${HIP_PLATFORM}-static) +endif() set(CPACK_PACKAGE_NAME ${PKG_NAME}) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HIP: Heterogenous-computing Interface for Portability [CATCH TESTS]") set(CPACK_PACKAGE_DESCRIPTION "HIP: @@ -49,8 +52,14 @@ set(CPACK_RPM_SPEC_MORE_DEFINE "%global __os_install_post %{nil}") set (CPACK_RPM_PACKAGE_AUTOREQ 0) # to remove hip-catch-* package during uninstallation of rocm -set (CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-core, hip-runtime-amd") -set (CPACK_RPM_PACKAGE_REQUIRES "rocm-core, hip-runtime-amd") + +if(BUILD_SHARED_LIBS) + set (CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-core, hip-runtime-amd") + set (CPACK_RPM_PACKAGE_REQUIRES "rocm-core, hip-runtime-amd") +else() + set (CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-core, hip-static-dev") + set (CPACK_RPM_PACKAGE_REQUIRES "rocm-core, hip-static-devel") +endif() if(NOT WIN32) install(DIRECTORY ${PROJECT_BINARY_DIR}/${CATCH_BUILD_DIR} diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index f8192082a0..19604b9d12 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -22,6 +22,7 @@ cmake_minimum_required(VERSION 3.16.8) project(hip-samples) option(ENABLE_ADDRESS_SANITIZER "Option to enable ASAN build" OFF) +option(BUILD_SHARED_LIBS "Use this option to link with shared hip runtime libraries" ON) # Read -DROCM_Path and env{ROCM_PATH} if(NOT DEFINED ROCM_PATH) diff --git a/samples/packaging/CMakeLists.txt b/samples/packaging/CMakeLists.txt index 51638b1362..d631ed6254 100644 --- a/samples/packaging/CMakeLists.txt +++ b/samples/packaging/CMakeLists.txt @@ -37,7 +37,11 @@ if(NOT DEFINED CPACK_INSTALL_PREFIX) set(CPACK_INSTALL_PREFIX "/opt/rocm/") endif() -set(PKG_NAME hip-samples) +if(BUILD_SHARED_LIBS) + set(PKG_NAME hip-samples) +else() + set(PKG_NAME hip-samples-static) +endif() set(CPACK_PACKAGE_NAME ${PKG_NAME}) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HIP: Heterogenous-computing Interface for Portability [HIP SAMPLES]") set(CPACK_PACKAGE_DESCRIPTION "HIP: @@ -52,8 +56,13 @@ set(CPACK_RPM_SPEC_MORE_DEFINE "%global __os_install_post %{nil}") set (CPACK_RPM_PACKAGE_AUTOREQ 0) # to remove hip-samples-* package during uninstallation of rocm -set (CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-core, hip-runtime-amd") -set (CPACK_RPM_PACKAGE_REQUIRES "rocm-core, hip-runtime-amd") +if(BUILD_SHARED_LIBS) + set (CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-core, hip-runtime-amd") + set (CPACK_RPM_PACKAGE_REQUIRES "rocm-core, hip-runtime-amd") +else() + set (CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-core, hip-static-dev") + set (CPACK_RPM_PACKAGE_REQUIRES "rocm-core, hip-static-devel") +endif() if(NOT WIN32) install(DIRECTORY ${SAMPLES_SRC}