Adapt to new versioning.
Using branch point for count since last change since we don't
have questions answered on tags yet.
Removed unused CMake files.
Restructured CMake to use the cache rather than only commandline
and be ccmake & cmake-gui friendly.
Dependency search paths are added for the Repo tree layout.
Search paths still needed for install paths.
Simplified packaging. hsa-ext-rocr-dev package and contents now
build from the package CMake rather than being 3 separate projects.
Not applying new version number or new install paths!
Change-Id: Ibea50dc8a6ab091e91857f78833f5379a4511547
[ROCm/ROCR-Runtime commit: 6c3acda664]
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
cmake_minimum_required ( VERSION 3.5.0 )
|
||||
|
||||
## Verbose output.
|
||||
set ( CMAKE_VERBOSE_MAKEFILE on )
|
||||
|
||||
## Set ext runtime module name and project name.
|
||||
# Set ext runtime module name and project name.
|
||||
set ( TOOLS_NAME "hsa-runtime-tools" )
|
||||
set ( TOOLS_TARGET "${TOOLS_NAME}64" )
|
||||
set ( TOOLS_LIBRARY "lib${TOOLS_TARGET}" )
|
||||
project ( ${TOOLS_TARGET} )
|
||||
|
||||
# Optionally, build with ccache.
|
||||
set(ROCM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
|
||||
if (ROCM_CCACHE_BUILD)
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if (CCACHE_PROGRAM)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
|
||||
else()
|
||||
message(WARNING "Unable to find ccache. Falling back to real compiler")
|
||||
endif() # if (CCACHE_PROGRAM)
|
||||
endif() # if (ROCM_CCACHE_BUILD)
|
||||
|
||||
## Include the cmake_modules utils.cmake
|
||||
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules" )
|
||||
include ( utils )
|
||||
@@ -23,57 +32,42 @@ add_definitions ( -DLITTLEENDIAN_CPU=1 )
|
||||
add_definitions ( -D HSA_DEPRECATED= )
|
||||
|
||||
## Get the package version. The defaults to 1.0.0.
|
||||
get_version ( "1.0.0" )
|
||||
get_version( "1.1.9")
|
||||
set(SO_MAJOR 1)
|
||||
set(SO_MINOR 1)
|
||||
set(SO_PATCH 9)
|
||||
|
||||
set ( BUILD_VERSION_MAJOR ${VERSION_MAJOR} )
|
||||
set ( BUILD_VERSION_MINOR ${VERSION_MINOR} )
|
||||
set ( BUILD_VERSION_PATCH ${VERSION_PATCH} )
|
||||
set ( LIB_VERSION_STRING "${BUILD_VERSION_MAJOR}.${BUILD_VERSION_MINOR}.${BUILD_VERSION_PATCH}" )
|
||||
if ( DEFINED VERSION_BUILD )
|
||||
set ( BUILD_VERSION_PATCH "${BUILD_VERSION_PATCH}-${VERSION_BUILD}" )
|
||||
endif ()
|
||||
set ( BUILD_VERSION_STRING "${BUILD_VERSION_MAJOR}.${BUILD_VERSION_MINOR}.${BUILD_VERSION_PATCH}" )
|
||||
set( SO_VERSION_STRING "${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}" )
|
||||
set( PACKAGE_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-${VERSION_JOB}-${VERSION_HASH}" )
|
||||
|
||||
## Find the hsakmt library and include files
|
||||
find_file ( HSAKMT_INC NAMES "hsakmt.h" "libhsakmt/hsakmt.h" )
|
||||
find_library ( HSAKMT_LIB libhsakmt.so )
|
||||
get_filename_component ( HSAKMT_LIB_PATH ${HSAKMT_LIB} DIRECTORY )
|
||||
get_filename_component ( HSAKMT_INC_PATH ${HSAKMT_INC} DIRECTORY )
|
||||
include_directories ( ${HSAKMT_INC_PATH} )
|
||||
link_directories (${HSAKMT_LIB_PATH})
|
||||
get_include_path( HSAKMT_INC_PATH "libhsakmt include path" NAMES "hsakmt.h" "libhsakmt/hsakmt.h" HINTS "${CMAKE_BINARY_DIR}/../../include" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../libhsakmt/include" PATHS "/opt/rocm/include")
|
||||
get_library_path( HSAKMT_LIB_PATH "libhsakmt library path" NAMES "libhsakmt.so" HINTS "${CMAKE_BINARY_DIR}/../../lib" "${CMAKE_BINARY_DIR}/../roct" PATHS "/opt/rocm/lib")
|
||||
include_directories( ${HSAKMT_INC_PATH} )
|
||||
link_directories( ${HSAKMT_LIB_PATH} )
|
||||
|
||||
## Find the hsa-runtime and include files
|
||||
find_file ( HSA_INC "hsa/hsa.h" )
|
||||
find_library ( HSA_LIB libhsa-runtime64.so )
|
||||
get_filename_component ( HSA_LIB_PATH ${HSA_LIB} DIRECTORY )
|
||||
get_filename_component ( HSA_INC_PATH ${HSA_INC} DIRECTORY )
|
||||
include_directories ( ${HSA_INC_PATH} )
|
||||
link_directories (${HSA_LIB_PATH})
|
||||
get_include_path( HSA_INC_PATH "ROCr include path" NAMES "hsa.h" "hsa/hsa.h" HINTS "${CMAKE_BINARY_DIR}/../../include" "${CMAKE_CURRENT_SOURCE_DIR}/../hsa-runtime/inc" PATHS "/opt/rocm/include")
|
||||
get_library_path( HSA_LIB_PATH "ROCr library path" NAMES "libhsa-runtime64.so" HINTS "${CMAKE_BINARY_DIR}/../../lib" "${CMAKE_BINARY_DIR}/../hsa-core" "${CMAKE_CURRENT_SOURCE_DIR}/../hsa-runtime/build" PATHS "/opt/rocm/lib")
|
||||
include_directories( ${HSA_INC_PATH} )
|
||||
link_directories( ${HSA_LIB_PATH} )
|
||||
|
||||
## External dependencies
|
||||
if ( NOT DEFINED REG_INCLUDE )
|
||||
set(REG_INCLUDE ${HSA_CLOSED_SOURCE_DIR}/drivers/inc/asic_reg)
|
||||
get_include_path( REG_INCLUDE "ASIC register directory" NAMES "si_id.h" HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../../../../p4/driver/drivers/inc/asic_reg" "${HSA_CLOSED_SOURCE_DIR}/drivers/inc/asic_reg" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../drivers/inc/asic_reg" )
|
||||
|
||||
## Find self
|
||||
if( "${TOOLS_SOURCE_DIR}" STREQUAL "" )
|
||||
get_include_path( TOOLS_SOURCE_FILE null NAMES "inc/amd_hsa_tools_interfaces.h" HINTS "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/" )
|
||||
get_filename_component( TOOLS_SOURCE_DIR "${TOOLS_SOURCE_FILE}/.." ABSOLUTE )
|
||||
unset( TOOLS_SOURCE_FILE CACHE )
|
||||
endif()
|
||||
set( TOOLS_SOURCE_DIR ${TOOLS_SOURCE_DIR} CACHE PATH "Tools lib source dir" FORCE )
|
||||
|
||||
if ( NOT EXISTS ${REG_INCLUDE}/si_id.h )
|
||||
MESSAGE ( FATAL_ERROR "Environment variable REG_INCLUDE is not set appropriately." )
|
||||
endif ()
|
||||
get_filename_component( OPEN_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE CACHE )
|
||||
set( OPEN_SOURCE_DIR ${OPEN_SOURCE_DIR} CACHE PATH "Open source root dir" FORCE )
|
||||
|
||||
if ( NOT DEFINED HSAKMT_INCLUDE )
|
||||
set(HSAKMT_INCLUDE ${HSA_CLOSED_SOURCE_DIR}/drivers/hsathk/include)
|
||||
endif()
|
||||
|
||||
if ( NOT EXISTS ${HSAKMT_INCLUDE}/hsakmt.h )
|
||||
MESSAGE ( FATAL_ERROR "Environment variable REG_INCLUDE is not set appropriately." )
|
||||
endif ()
|
||||
|
||||
if( NOT DEFINED TOOLS_SOURCE_DIR )
|
||||
set ( TOOLS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
endif()
|
||||
|
||||
if( NOT DEFINED OPEN_SOURCE_DIR )
|
||||
set ( OPEN_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." )
|
||||
endif()
|
||||
## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib")
|
||||
|
||||
## ------------------------- Linux Compiler and Linker options -------------------------
|
||||
set ( CMAKE_CXX_FLAGS "-std=c++11 ")
|
||||
@@ -92,13 +86,10 @@ endif ()
|
||||
|
||||
set ( DRVDEF "${TOOLS_SOURCE_DIR}/make/hsatools.so.def" )
|
||||
|
||||
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bdynamic -Wl,-z,noexecstack -Wl,--version-script=${DRVDEF}" )
|
||||
|
||||
set ( CMAKE_SKIP_BUILD_RPATH TRUE )
|
||||
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bdynamic -Wl,-z,noexecstack -Wl,--version-script=${DRVDEF} -Wl,--enable-new-dtags" )
|
||||
|
||||
## Library path(s).
|
||||
include_directories ( ${REG_INCLUDE} )
|
||||
include_directories ( ${HSAKMT_INCLUDE} )
|
||||
include_directories ( ${TOOLS_SOURCE_DIR} )
|
||||
include_directories ( ${TOOLS_SOURCE_DIR}/.. )
|
||||
include_directories ( ${OPEN_SOURCE_DIR}/hsa-runtime )
|
||||
@@ -213,7 +204,7 @@ set ( SP3_R1000_SRC ${TOOLS_SOURCE_DIR}/sp3/Chip/R1000/sp3-asic.c
|
||||
set ( UTIL_SRC ${OPEN_SOURCE_DIR}/hsa-runtime/core/util/timer.cpp
|
||||
${OPEN_SOURCE_DIR}/hsa-runtime/core/util/small_heap.cpp
|
||||
${OPEN_SOURCE_DIR}/hsa-runtime/core/util/lnx/os_linux.cpp )
|
||||
|
||||
|
||||
|
||||
## This is the main shared library.
|
||||
add_library ( ${TOOLS_TARGET} SHARED ${CORE_SRC}
|
||||
@@ -228,8 +219,8 @@ add_library ( ${TOOLS_TARGET} SHARED ${CORE_SRC}
|
||||
${UTIL_SRC} )
|
||||
|
||||
## Set the VERSION and SOVERSION values
|
||||
set_property ( TARGET ${TOOLS_TARGET} PROPERTY VERSION "${LIB_VERSION_STRING}" )
|
||||
set_property ( TARGET ${TOOLS_TARGET} PROPERTY SOVERSION "${BUILD_VERSION_MAJOR}" )
|
||||
set_property ( TARGET ${TOOLS_TARGET} PROPERTY VERSION "${SO_VERSION_STRING}" )
|
||||
set_property ( TARGET ${TOOLS_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" )
|
||||
|
||||
## Add the required link libraries
|
||||
target_link_libraries (
|
||||
@@ -244,6 +235,10 @@ if ( "${CMAKE_BUILD_TYPE}" STREQUAL Release )
|
||||
add_custom_command ( TARGET ${TOOLS_TARGET} POST_BUILD COMMAND ${CMAKE_STRIP} *.so )
|
||||
endif ()
|
||||
|
||||
## Create symlinks for legacy packaging and install
|
||||
add_custom_target ( hsa_tools_lib_link ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${TOOLS_LIBRARY}.so ${TOOLS_LIBRARY}-link.so )
|
||||
|
||||
## Set install information
|
||||
install ( TARGETS ${TOOLS_TARGET} LIBRARY DESTINATION hsa/lib )
|
||||
install ( DIRECTORY ${TOOLS_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa FILES_MATCHING PATTERN "*.h" )
|
||||
install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${TOOLS_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${TOOLS_LIBRARY}.so )
|
||||
|
||||
Reference in New Issue
Block a user