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
This commit is contained in:
Sean Keely
2019-08-13 02:50:45 -05:00
parent 53228ad819
commit 6c3acda664
22 changed files with 474 additions and 1284 deletions
+114 -23
View File
@@ -40,6 +40,59 @@
##
################################################################################
function( get_path LIB CACHED_PATH HELP )
set( options "")
set( oneValueArgs RESULT )
set( multiValueArgs HINTS NAMES )
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
# Search for canary file.
if( ${LIB} )
find_library( FULLPATH NAMES ${ARGS_NAMES} HINTS ${${CACHED_PATH}} ${ARGS_HINTS} )
else()
find_file( FULLPATH NAMES ${ARGS_NAMES} HINTS ${${CACHED_PATH}} ${ARGS_HINTS} )
endif()
set( RESULT (NOT ${FULLPATH} MATCHES NOTFOUND) )
# Extract path
get_filename_component ( DIRPATH ${FULLPATH} DIRECTORY )
# Check path against cache
if( NOT "${${CACHED_PATH}}" STREQUAL "" )
if ( NOT "${${CACHED_PATH}}" STREQUAL "${DIRPATH}" )
message(WARNING "${CACHED_PATH} may be incorrect." )
set( DIRPATH ${${CACHED_PATH}} )
endif()
elseif(NOT ${RESULT})
message(WARNING "${CACHED_PATH} not located during path search.")
endif()
# Set cache variable and help text
set( ${CACHED_PATH} ${DIRPATH} CACHE PATH ${HELP} FORCE )
unset( FULLPATH CACHE )
# Return success flag
if( NOT ${ARGS_RESULT} STREQUAL "" )
set( ${ARGS_RESULT} ${RESULT} PARENT_SCOPE)
endif()
endfunction()
## Searches for a file using include paths and stores the path to that file in the cache
## using the cached value if set. Search paths are optional. Returns success in RESULT.
## get_include_path(<VAR> NAMES name1 [name2...] [HINTS path1 [path2 ... ENV var]] [RESULT <var>]
macro( get_include_path CACHED_PATH HELP )
get_path( 0 ${ARGV} )
endmacro()
## Searches for a file using library paths and stores the path to that file in the cache
## using the cached value if set. Search paths are optional. Returns success in RESULT.
## get_library_path(<VAR> NAMES name1 [name2...] [HINTS path1 [path2 ... ENV var]] [RESULT <var>]
macro( get_library_path CACHED_PATH HELP )
get_path( 1 ${ARGV} )
endmacro()
## Parses the VERSION_STRING variable and places
## the first, second and third number values in
## the major, minor and patch variables.
@@ -58,27 +111,18 @@ function( parse_version VERSION_STRING )
if ( ${VERSION_COUNT} GREATER 0)
list ( GET VERSIONS 0 MAJOR )
set ( VERSION_MAJOR ${MAJOR} PARENT_SCOPE )
set ( TEMP_VERSION_STRING "${MAJOR}" )
endif ()
if ( ${VERSION_COUNT} GREATER 1 )
list ( GET VERSIONS 1 MINOR )
set ( VERSION_MINOR ${MINOR} PARENT_SCOPE )
set ( TEMP_VERSION_STRING "${TEMP_VERSION_STRING}.${MINOR}" )
endif ()
if ( ${VERSION_COUNT} GREATER 2 )
list ( GET VERSIONS 2 PATCH )
set ( VERSION_PATCH ${PATCH} PARENT_SCOPE )
set ( TEMP_VERSION_STRING "${TEMP_VERSION_STRING}.${PATCH}" )
endif ()
if ( DEFINED VERSION_BUILD )
set ( VERSION_BUILD "${VERSION_BUILD}" PARENT_SCOPE )
endif ()
set ( VERSION_STRING "${TEMP_VERSION_STRING}" PARENT_SCOPE )
endfunction ()
## Gets the current version of the repository
@@ -87,30 +131,77 @@ endfunction ()
## and a library version string.
function ( get_version DEFAULT_VERSION_STRING )
parse_version ( ${DEFAULT_VERSION_STRING} )
set( VERSION_JOB "local-build" )
set( VERSION_COMMIT_COUNT 0 )
set( VERSION_HASH "unknown" )
find_program ( GIT NAMES git )
find_program( GIT NAMES git )
if ( GIT )
if( GIT )
execute_process ( COMMAND git describe --dirty --long --match [0-9]*
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE RESULT )
#execute_process ( COMMAND git describe --tags --dirty --long
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# OUTPUT_VARIABLE GIT_TAG_STRING
# OUTPUT_STRIP_TRAILING_WHITESPACE
# RESULT_VARIABLE RESULT )
if ( ${RESULT} EQUAL 0 )
# Get branch commit (common ancestor) of current branch and master branch.
execute_process(COMMAND git merge-base HEAD origin/HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_MERGE_BASE
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE RESULT )
parse_version ( ${GIT_TAG_STRING} )
if( ${RESULT} EQUAL 0 )
# Count commits from branch point.
execute_process(COMMAND git rev-list --count ${GIT_MERGE_BASE}..HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_COMMIT_COUNT
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE RESULT )
if(NOT ${RESULT} EQUAL 0 )
set( VERSION_COMMIT_COUNT 0 )
endif()
endif()
endif ()
# Get current short hash.
execute_process(COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE RESULT )
if( ${RESULT} EQUAL 0 )
# Check for dirty workspace.
execute_process(COMMAND git diff --quiet
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE RESULT )
if(${RESULT} EQUAL 1)
set(VERSION_HASH "${VERSION_HASH}-dirty")
endif()
else()
set( VERSION_HASH "unknown" )
endif()
endif()
endif ()
# Build automation IDs
if(DEFINED ENV{ROCM_BUILD_ID})
set( VERSION_JOB $ENV{ROCM_BUILD_ID} )
endif()
parse_version(${DEFAULT_VERSION_STRING})
set( VERSION_STRING "${VERSION_STRING}" PARENT_SCOPE )
set( VERSION_MAJOR "${VERSION_MAJOR}" PARENT_SCOPE )
set( VERSION_MINOR "${VERSION_MINOR}" PARENT_SCOPE )
set( VERSION_PATCH "${VERSION_PATCH}" PARENT_SCOPE )
set( VERSION_BUILD "${VERSION_BUILD}" PARENT_SCOPE )
set( VERSION_COMMIT_COUNT "${VERSION_COMMIT_COUNT}" PARENT_SCOPE )
set( VERSION_HASH "${VERSION_HASH}" PARENT_SCOPE )
set( VERSION_JOB "${VERSION_JOB}" PARENT_SCOPE )
#message("${VERSION_MAJOR}" )
#message("${VERSION_MINOR}" )
#message("${VERSION_PATCH}" )
#message("${VERSION_COMMIT_COUNT}")
#message("${VERSION_HASH}")
#message("${VERSION_JOB}")
endfunction()