-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from kknox/linux-packaging
Linux packaging enhancememnts
- Loading branch information
Showing
12 changed files
with
180 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# ######################################################################## | ||
# A helper function to generate packaging scripts to register libraries with system | ||
# ######################################################################## | ||
function( write_rocm_package_script_files scripts_write_dir library_name library_link_name ) | ||
|
||
set( ld_conf_file "/etc/ld.so.conf.d/${library_name}-dev.conf" ) | ||
|
||
file( WRITE ${scripts_write_dir}/postinst | ||
"#!/bin/bash | ||
set -e | ||
do_ldconfig() { | ||
echo ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR} > ${ld_conf_file} && ldconfig | ||
} | ||
do_softlinks() { | ||
ln -sr ${CPACK_PACKAGING_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR} ${CPACK_PACKAGING_INSTALL_PREFIX}/../include/${library_name} | ||
ln -sr ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${library_link_name}.1 ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/${library_link_name} | ||
ln -sr ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/cmake/${library_name} ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/cmake/${library_name} | ||
} | ||
case \"\$1\" in | ||
configure) | ||
do_ldconfig | ||
do_softlinks | ||
;; | ||
abort-upgrade|abort-remove|abort-deconfigure) | ||
echo \"\$1\" | ||
;; | ||
*) | ||
exit 0 | ||
;; | ||
esac | ||
" ) | ||
|
||
file( WRITE ${scripts_write_dir}/prerm | ||
"#!/bin/bash | ||
set -e | ||
rm_ldconfig() { | ||
rm -f ${ld_conf_file} && ldconfig | ||
} | ||
rm_softlinks() { | ||
rm -f ${CPACK_PACKAGING_INSTALL_PREFIX}/../include/${library_name} | ||
rm -f ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/${library_link_name} | ||
rm -f ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/cmake/${library_name} | ||
} | ||
case \"\$1\" in | ||
remove|purge) | ||
rm_ldconfig | ||
rm_softlinks | ||
;; | ||
*) | ||
exit 0 | ||
;; | ||
esac | ||
" ) | ||
|
||
endfunction( ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ cmake_minimum_required( VERSION 2.8.12 ) | |
|
||
# MACOSX_RPATH is enabled by default policy | ||
if( POLICY CMP0042 ) | ||
cmake_policy( SET CMP0042 NEW ) | ||
cmake_policy( SET CMP0042 NEW ) | ||
endif( ) | ||
|
||
# CMP0063: Honor visibility properties for all target types [cmake 3.3] | ||
|
@@ -17,12 +17,12 @@ if( POLICY CMP0063 ) | |
endif( ) | ||
|
||
if( CMAKE_GENERATOR MATCHES "NMake" ) | ||
option( NMAKE_COMPILE_VERBOSE "Print VERBOSE compile/link msgs to the console" OFF ) | ||
if( NMAKE_COMPILE_VERBOSE ) | ||
set( CMAKE_START_TEMP_FILE "" ) | ||
set( CMAKE_END_TEMP_FILE "" ) | ||
set( CMAKE_VERBOSE_MAKEFILE 1 ) | ||
endif( ) | ||
option( NMAKE_COMPILE_VERBOSE "Print VERBOSE compile/link msgs to the console" OFF ) | ||
if( NMAKE_COMPILE_VERBOSE ) | ||
set( CMAKE_START_TEMP_FILE "" ) | ||
set( CMAKE_END_TEMP_FILE "" ) | ||
set( CMAKE_VERBOSE_MAKEFILE 1 ) | ||
endif( ) | ||
endif( ) | ||
|
||
# This has to be initialized before the project() command appears | ||
|
@@ -49,18 +49,18 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) | |
# On windows, it's convenient to change the default install prefix such that it does NOT point to 'program files' | ||
# Need to check out CMAKE_RUNTIME_OUTPUT_DIRECTORY variable, and see if that eliminates the need to modify install path | ||
if( WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) | ||
set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories" FORCE ) | ||
set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories" FORCE ) | ||
endif( ) | ||
|
||
# Set common compile and link options | ||
if( MSVC ) | ||
# Following options for nMake | ||
message( STATUS "Detected MSVS Ver: " ${MSVC_VERSION} ) | ||
# Following options for nMake | ||
message( STATUS "Detected MSVS Ver: " ${MSVC_VERSION} ) | ||
|
||
# CMake uses huge stack frames for windows, we would like to remove. | ||
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" ) | ||
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" ) | ||
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}" ) | ||
# CMake uses huge stack frames for windows, we would like to remove. | ||
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" ) | ||
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" ) | ||
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}" ) | ||
endif( ) | ||
|
||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic") | ||
|
@@ -74,50 +74,40 @@ message( STATUS "CMAKE_CXX_COMPILER release flags: " ${CMAKE_CXX_FLAGS_RELEASE} | |
message( STATUS "CMAKE_CXX_COMPILER relwithdebinfo flags: " ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ) | ||
message( STATUS "CMAKE_EXE_LINKER link flags: " ${CMAKE_EXE_LINKER_FLAGS} ) | ||
|
||
include( GNUInstallDirs ) | ||
|
||
# configure a header file to pass the CMake version settings to the source, and package the header files in the output archive | ||
configure_file( "${PROJECT_SOURCE_DIR}/include/rocblas-version.h.in" "${PROJECT_BINARY_DIR}/include/rocblas-version.h" ) | ||
|
||
set( rocblas_headers_public | ||
include/rocblas.h | ||
# include/rocblas.hpp | ||
include/rocblas_types.h | ||
include/rocblas_auxiliary.h | ||
include/rocblas_functions.h | ||
include/rocblas-types.h | ||
include/rocblas-auxiliary.h | ||
include/rocblas-functions.h | ||
${PROJECT_BINARY_DIR}/include/rocblas-version.h | ||
) | ||
|
||
source_group( "Header Files\\Public" FILES ${rocblas_headers_public} ) | ||
|
||
# Build into subdirectories | ||
add_subdirectory( src ) | ||
include( GNUInstallDirs ) | ||
|
||
install( FILES | ||
${rocblas_headers_public} | ||
DESTINATION | ||
${CMAKE_INSTALL_INCLUDEDIR} ) | ||
set( BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} ) | ||
set( LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} ) | ||
set( INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} ) | ||
|
||
# Depending on whether we are building for 64 or 32 bit, construct common paths and names that subdirectories can reference for their use | ||
if( BUILD_64 ) | ||
set( CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}-amd64" ) | ||
else( ) | ||
set( CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}-i686" ) | ||
endif( ) | ||
# Build into subdirectories | ||
add_subdirectory( src ) | ||
|
||
# The following code is setting variables to control the behavior of CPack to generate our | ||
if( WIN32 ) | ||
set( CPACK_SOURCE_GENERATOR "ZIP" ) | ||
set( CPACK_GENERATOR "ZIP" ) | ||
set( CPACK_SOURCE_GENERATOR "ZIP" ) | ||
set( CPACK_GENERATOR "ZIP" ) | ||
else( ) | ||
set( CPACK_SOURCE_GENERATOR "TGZ" ) | ||
|
||
set( CPACK_GENERATOR "DEB" ) | ||
set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64" ) | ||
set( CPACK_DEBIAN_COMPRESSION_TYPE "xz" ) | ||
# set( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON ) | ||
set( CPACK_SOURCE_GENERATOR "TGZ" ) | ||
set( CPACK_GENERATOR "DEB;RPM" CACHE STRING "cpack list: 7Z, DEB, IFW, NSIS, NSIS64, RPM, STGZ, TBZ2, TGZ, TXZ, TZ, ZIP" ) | ||
# set( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON ) | ||
endif( ) | ||
|
||
# Package agnostic CPACK vars | ||
set( CPACK_PACKAGE_CONTACT "Kent Knox <[email protected]>" ) | ||
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Radeon Open Compute BLAS library") | ||
set( CPACK_PACKAGE_VERSION_MAJOR ${rocblas_VERSION_MAJOR} ) | ||
|
@@ -126,7 +116,21 @@ set( CPACK_PACKAGE_VERSION_PATCH ${rocblas_VERSION_PATCH} ) | |
set( CPACK_PACKAGE_VERSION_TWEAK ${rocblas_VERSION_TWEAK} ) | ||
set( CPACK_PACKAGE_VERSION ${rocblas_VERSION} ) | ||
set( CPACK_PACKAGE_VENDOR "AMD") | ||
set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/../LICENSE.md" ) | ||
set( CPACK_SOURCE_IGNORE_FILES "/\\\\.git/" ) | ||
|
||
# Package specific CPACK vars | ||
set( CPACK_DEBIAN_PACKAGE_DEPENDS "hip_hcc (>= 1.0.17174)" ) | ||
set( CPACK_RPM_PACKAGE_REQUIRES "hip_hcc >= 1.0.17174" ) | ||
|
||
if( "${CPACK_PACKAGING_INSTALL_PREFIX}" MATCHES "^/opt/rocm.*$") | ||
include( package-functions ) | ||
write_rocm_package_script_files( ${PROJECT_BINARY_DIR} "rocblas" "librocblas-hcc.so" ) | ||
|
||
set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") | ||
set( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst" ) | ||
set( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm" ) | ||
endif( ) | ||
|
||
# Define all variables that influence CPack before including CPack, such as install targets | ||
include( CPack ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.