Skip to content

Commit

Permalink
cmake: Fix BUILD_SHARED_LIBS option and README for it
Browse files Browse the repository at this point in the history
BUILD_SHARED_LIBS is a global flag so we don't need to set a default
option for it in both libhsakmt and hsa-runtime, only the top level
CMakeLists file. Also updated README to reflect that libhsakmt is
always built statically and gets linked to libhsa-runtime.

Change-Id: I1511f68a268032bec9758bc731d8074f33ec980f
  • Loading branch information
sohaibnd committed Jan 30, 2025
1 parent f24d789 commit ff01f62
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ project("rocr")

set(CMAKE_VERBOSE_MAKEFILE ON)

## Expose static library option
if ( NOT DEFINED BUILD_SHARED_LIBS )
set ( BUILD_SHARED_LIBS ON )
endif()
set ( BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS} CACHE BOOL "Build shared library (.so) or not.")

if (NOT DEFINED BUILD_ROCR)
set(BUILD_ROCR ON)
endif()
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ Ensure you have the following installed:
```

- *Control whether libhsakmt and libhsa-runtime are shared or static*
The default (when `BUILD_SHARED_LIBS` is unset) is for libhsakmt to be static and libhsa-runtime to be shared. Setting `BUILD_SHARED_LIBS` to `OFF` will make both static and setting it to `ON` will make them both shared.
libhsakmt is always built as a static library that gets linked into libhsa-runtime, so there is a single library generated called libhsa-runtime64{.so/.a}. If `BUILD_SHARED_LIBS` is not set, this is a shared library by default. Setting `BUILD_SHARED_LIBS` to `OFF` will make it static.
```sh
-DBUILD_SHARED_LIBS=OFF # or ON for both libs shared
-DBUILD_SHARED_LIBS=ON # or OFF for static lib
```
### Building the tests
#### rocrtst
Expand Down
6 changes: 0 additions & 6 deletions libhsakmt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ set(HSAKMT_STATIC_DRM_TARGET "${HSAKMT_TARGET}-staticdrm")

project ( ${HSAKMT_TARGET} VERSION 1.9.0)

# Build thunk as static by default
if ( NOT DEFINED BUILD_SHARED_LIBS )
set ( BUILD_SHARED_LIBS "off" )
endif()
set ( BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS} CACHE BOOL "Build shared library (.so) or not.")

# Optionally, build HSAKMT with ccache.
set(ROCM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
if (ROCM_CCACHE_BUILD)
Expand Down
6 changes: 0 additions & 6 deletions runtime/hsa-runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ include ( utils )
include ( hsa_common )
include ( GNUInstallDirs )

## Expose static library option
if ( NOT DEFINED BUILD_SHARED_LIBS )
set ( BUILD_SHARED_LIBS ON )
endif()
set ( BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS} CACHE BOOL "Build shared library (.so) or not.")

## Adjust target name for static builds
## Original name will be an interface target that adds --whole-archive linker options around the target.
if( NOT ${BUILD_SHARED_LIBS} )
Expand Down

0 comments on commit ff01f62

Please sign in to comment.