From 41432ee6cac0137ea5d17209fb47bae6f5a45348 Mon Sep 17 00:00:00 2001 From: James Edwards Date: Thu, 29 Sep 2016 18:41:54 -0500 Subject: [PATCH] Fix Teamcity build break, part 1. Change-Id: I2019b502700e5fda2175b258dcfd3681ab93bc77 --- runtime/hsa-runtime/CMakeLists.txt | 101 +++++++++++++++++++++++++++-- 1 file changed, 97 insertions(+), 4 deletions(-) diff --git a/runtime/hsa-runtime/CMakeLists.txt b/runtime/hsa-runtime/CMakeLists.txt index d2c033340e..852a5d23a3 100644 --- a/runtime/hsa-runtime/CMakeLists.txt +++ b/runtime/hsa-runtime/CMakeLists.txt @@ -40,8 +40,15 @@ ## ################################################################################ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required ( VERSION 2.8.0 ) +## GCC 4.8 or higher compiler required. +if ( WIN32 ) + MESSAGE ( FATAL_ERROR "Windows build is not supported." ) +endif () + +## Verbose output. +set ( CMAKE_VERBOSE_MAKEFILE on ) ## Set core runtime module name and project name. set ( CORE_RUNTIME_NAME "hsa-runtime" ) set ( CORE_RUNTIME_COMPONENT "lib${CORE_RUNTIME_NAME}" ) @@ -50,6 +57,14 @@ project( ${CORE_RUNTIME_TARGET} ) list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) +## Find LibElf +find_package(LibElf REQUIRED) + +## Compiler preproc definitions. +add_definitions ( -D__linux__ ) +add_definitions ( -DHSA_EXPORT=1 ) +add_definitions ( -DHSA_EXPORT_FINALIZER=1 ) +add_definitions ( -DHSA_EXPORT_IMAGES=1 ) add_definitions ( -D HSA_DEPRECATED= ) include ( utils ) @@ -85,11 +100,89 @@ include_directories ( ${HSAKMT_BUILD_INC_PATH}) link_directories ( ${HSAKMT_BUILD_LIB_PATH} ) -add_subdirectory ( libamdhsacode ) -add_subdirectory ( loader ) -add_subdirectory ( core ) +if ( DEFINED BUILDID ) + add_definitions ( -DROCR_BUILD_ID=${BUILDID} ) +else ( NOT DEFINED BUILDID ) + ## get date information based on UTC - full date + execute_process(COMMAND date --utc +%F WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE ) + ## get commit information + execute_process(COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_BUILD_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE ) + ## check dirty tree status + execute_process(COMMAND git diff --shortstat COMMAND wc -l WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_DIRTY_TREE OUTPUT_STRIP_TRAILING_WHITESPACE ) + set ( BUILD_ID "${ROCR_BUILD_COMMIT}.${ROCR_BUILD_TIME}.${ROCR_DIRTY_TREE}" ) + add_definitions ( -DROCR_BUILD_ID=${BUILD_ID} ) +endif () + +## ------------------------- Linux Compiler and Linker options ------------------------- +set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=unused-function" ) + +set ( DRVDEF "${CMAKE_CURRENT_SOURCE_DIR}/core/hsacore.so.def" ) + +set ( LNKSCR "${CMAKE_CURRENT_SOURCE_DIR}/core/hsacore.so.link" ) + +set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bdynamic -Wl,-z,noexecstack -Wl,${LNKSCR} -Wl,--version-script=${DRVDEF}" ) + +set ( CMAKE_SKIP_BUILD_RPATH TRUE ) + +## ------------------------- End Compiler and Linker options ---------------------------- + +## Source files. +set ( SRCS "core/util/lnx/os_linux.cpp" + "core/util/small_heap.cpp" + "core/util/timer.cpp" + "core/runtime/amd_blit_kernel.cpp" + "core/runtime/amd_blit_sdma.cpp" + "core/runtime/amd_cpu_agent.cpp" + "core/runtime/amd_gpu_agent.cpp" + "core/runtime/amd_aql_queue.cpp" + "core/runtime/amd_loader_context.cpp" + "core/runtime/hsa_ven_amd_loader.cpp" + "core/runtime/amd_memory_region.cpp" + "core/runtime/amd_topology.cpp" + "core/runtime/default_signal.cpp" + "core/runtime/host_queue.cpp" + "core/runtime/hsa.cpp" + "core/runtime/hsa_api_trace.cpp" + "core/runtime/hsa_ext_amd.cpp" + "core/runtime/hsa_ext_interface.cpp" + "core/runtime/interrupt_signal.cpp" + "core/runtime/isa.cpp" + "core/runtime/runtime.cpp" + "core/runtime/signal.cpp" + "core/runtime/cache.cpp" + "core/common/shared.cpp" + "core/common/hsa_table_interface.cpp" + "loader/executable.cpp" + "loader/loaders.cpp" + "libamdhsacode/amd_elf_image.cpp" + "libamdhsacode/amd_hsa_code_util.cpp" + "libamdhsacode/amd_hsa_locks.cpp" + "libamdhsacode/amd_options.cpp" + "libamdhsacode/amd_hsa_code.cpp" +) + +add_library( ${CORE_RUNTIME_TARGET} SHARED ${SRCS} ) +link_directories ( ${HSAKMT_BUILD_LIB_PATH} ) + +## Set the VERSION and SOVERSION values +if ( DEFINED VERSION_STRING ) + set_property ( TARGET ${CORE_RUNTIME_TARGET} PROPERTY VERSION "${RUNTIME_VERSION_STRING}" ) +endif () + +set_property ( TARGET ${CORE_RUNTIME_TARGET} PROPERTY SOVERSION "${RUNTIME_VERSION_MAJOR}" ) + +target_link_libraries ( ${CORE_RUNTIME_TARGET} + PRIVATE hsakmt + elf dl pthread rt +) + +## If the build is Release, strip the target library +if ( "${CMAKE_BUILD_TYPE}" STREQUAL Release ) + add_custom_command ( TARGET ${CORE_RUNTIME_TARGET} POST_BUILD COMMAND ${CMAKE_STRIP} *.so ) +endif () ## Set install information +install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION lib COMPONENT ${CORE_RUNTIME_COMPONENT} ) install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa ) ## Packaging directives