Skip to content

Commit a5f2391

Browse files
committed
GmmLib shared/static library packaging
- Add make install for shared and static library - package public interface headers - Add support for pkg-config via igdgmm.pc config file Change-Id: I80f23dac0511b456de6d8e41827436be8587ee28
1 parent 72c92c0 commit a5f2391

File tree

7 files changed

+353
-12
lines changed

7 files changed

+353
-12
lines changed

Source/GmmLib/CMakeLists.txt

+126-2
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,10 @@ endforeach()
409409
###################################################################################
410410
add_library( ${GMM_LIB_DLL_NAME} SHARED igdgmm.rc ${UMD_SOURCES} ${UMD_HEADERS})
411411

412-
set_target_properties(${GMM_LIB_DLL_NAME} PROPERTIES OUTPUT_NAME "igdgmm${GMMLIB_ARCH}")
413-
414412
if(MSVC)
415413

414+
set_target_properties(${GMM_LIB_DLL_NAME} PROPERTIES OUTPUT_NAME "igdgmm${GMMLIB_ARCH}")
415+
416416
bs_set_wdk(${GMM_LIB_DLL_NAME})
417417
GmmLibSetTargetConfig( ${GMM_LIB_DLL_NAME} )
418418

@@ -423,6 +423,9 @@ windows_umd_props_universal(${GMM_LIB_DLL_NAME})
423423
target_link_libraries( ${GMM_LIB_DLL_NAME}
424424
onecoreuap.lib
425425
)
426+
else()
427+
set_target_properties(${GMM_LIB_DLL_NAME} PROPERTIES OUTPUT_NAME "igdgmm")
428+
426429
endif()
427430

428431
###################################################################################
@@ -516,6 +519,7 @@ bs_set_extra_target_properties(${GMM_LIB_DLL_NAME}
516519
UNUSED_ISTDLIB_MT
517520
GMM_UNIFIED_LIB
518521
GMM_LIB_DLL
522+
GMM_LIB_DLL_EXPORTS
519523
)
520524

521525
if("${GMMLIB_ARCH}" MATCHES "64")
@@ -534,3 +538,123 @@ endif()
534538
if(NOT DEFINED RUN_TEST_SUITE OR RUN_TEST_SUITE)
535539
add_subdirectory(ULT)
536540
endif()
541+
542+
set (GMMLIB_INSTALL_TIME_ROOT_DIR "/usr")
543+
set (IGDGMM_LIBRARY_NAME "igdgmm")
544+
545+
include(os_release_info.cmake)
546+
547+
get_os_release_info(os_name os_version)
548+
549+
if("${os_name}" STREQUAL "clear-linux-os")
550+
# clear-linux-os distribution avoids /etc for distribution defaults.
551+
# Set this variable explicitly before including GNUInstallDirs.
552+
set(CMAKE_INSTALL_SYSCONFDIR "usr/share/defaults/etc")
553+
endif()
554+
555+
if(UNIX)
556+
if(NOT DEFINED MAJOR_VERSION)
557+
set(MAJOR_VERSION 0)
558+
endif()
559+
560+
if(NOT DEFINED MINOR_VERSION)
561+
set(MINOR_VERSION 1)
562+
endif()
563+
564+
if(NOT DEFINED PATCH_VERSION)
565+
set(PATCH_VERSION 0)
566+
endif()
567+
568+
configure_file(${BS_DIR_GMMLIB}/igdgmm.h.in ${CMAKE_BINARY_DIR}/igdgmm.h)
569+
configure_file(${BS_DIR_GMMLIB}/igdgmm.pc.in ${CMAKE_BINARY_DIR}/igdgmm.pc @ONLY)
570+
571+
install(TARGETS ${GMM_LIB_DLL_NAME} DESTINATION ${GMMLIB_INSTALL_TIME_ROOT_DIR}/lib COMPONENT gmmlib)
572+
install(TARGETS gmm_umd DESTINATION ${GMMLIB_INSTALL_TIME_ROOT_DIR}/lib COMPONENT gmmlib)
573+
574+
install(DIRECTORY ${BS_DIR_GMMLIB} DESTINATION ${GMMLIB_INSTALL_TIME_ROOT_DIR}/include/igdgmm COMPONENT gmmlib-devel
575+
FILES_MATCHING PATTERN "*.h"
576+
PATTERN "*.hpp"
577+
PATTERN "Internal" EXCLUDE
578+
PATTERN "ULT" EXCLUDE)
579+
580+
install (DIRECTORY ${BS_DIR_INC} DESTINATION ${GMMLIB_INSTALL_TIME_ROOT_DIR}/include/igdgmm COMPONENT gmmlib-devel
581+
FILES_MATCHING PATTERN "*.h"
582+
PATTERN "*.hpp")
583+
584+
install (DIRECTORY ${BS_DIR_UTIL} DESTINATION ${GMMLIB_INSTALL_TIME_ROOT_DIR}/include/igdgmm COMPONENT gmmlib-devel
585+
FILES_MATCHING PATTERN "*.h"
586+
PATTERN "*.hpp")
587+
588+
install (FILES ${BS_DIR_GMMLIB}/Utility/CpuSwizzleBlt/CpuSwizzleBlt.c
589+
DESTINATION ${GMMLIB_INSTALL_TIME_ROOT_DIR}/include/igdgmm/GmmLib/Utility/CpuSwizzleBlt/ COMPONENT gmmlib-devel)
590+
591+
install(FILES ${CMAKE_BINARY_DIR}/igdgmm.pc DESTINATION ${GMMLIB_INSTALL_TIME_ROOT_DIR}/lib/pkgconfig COMPONENT gmmlib-devel)
592+
install(FILES ${CMAKE_BINARY_DIR}/igdgmm.h DESTINATION ${GMMLIB_INSTALL_TIME_ROOT_DIR}/include/igdgmm COMPONENT gmmlib-devel)
593+
594+
if(GMMLIB_CPACK_GENERATOR)
595+
set(CPACK_GENERATOR "${GMMLIB_CPACK_GENERATOR}")
596+
else()
597+
# If generators list was not define build native package for current distro
598+
if(EXISTS "/etc/debian_version")
599+
set(CPACK_GENERATOR "DEB")
600+
elseif(EXISTS "/etc/redhat-release")
601+
set(CPACK_GENERATOR "RPM")
602+
else()
603+
set(CPACK_GENERATOR "TXZ")
604+
endif()
605+
endif()
606+
607+
set(CPACK_PACKAGE_NAME "intel-gmm")
608+
set(CPACK_PACKAGE_VENDOR "Intel Corporation")
609+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Intel(R) Graphics Memory Management Library Package")
610+
611+
set(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
612+
set(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
613+
set(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION})
614+
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
615+
616+
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${GMMLIB_INSTALL_TIME_ROOT_DIR})
617+
set(CPACK_COMPONENT_INSTALL ON)
618+
set(CPACK_DEB_COMPONENT_INSTALL ON)
619+
set(CPACK_RPM_COMPONENT_INSTALL ON)
620+
set(CPACK_SET_DESTDIR TRUE)
621+
set(CPACK_PACKAGE_RELOCATABLE FALSE)
622+
623+
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
624+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel")
625+
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
626+
627+
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
628+
set(CPACK_RPM_COMPRESSION_TYPE "xz")
629+
630+
# Create Distro OS initial based on 1st-2nd letter of string
631+
# or label "generic" for unsupported/unknown distros for CPACK_PACKAGE_FILE_NAME
632+
if("${os_name}" STREQUAL "ubuntu")
633+
set(DISTRO_INFO "u${os_version}")
634+
elseif("${os_name}" STREQUAL "fedora")
635+
set(DISTRO_INFO "f${os_version}")
636+
elseif("${os_name}" STREQUAL "clear-linux-os")
637+
set(DISTRO_INFO "cl${os_version}")
638+
elseif("${os_name}" STREQUAL "centos")
639+
set(DISTRO_INFO "ce${os_version}")
640+
else()
641+
set(DISTRO_INFO "generic")
642+
endif()
643+
644+
string(TOLOWER "${BUILD_TYPE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}" PACKAGE_TYPE)
645+
646+
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${DISTRO_INFO}-${PACKAGE_TYPE}")
647+
648+
set(CPACK_DEBIAN_GMMLIB_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${DISTRO_INFO}-${PACKAGE_TYPE}")
649+
650+
set(CPACK_DEBIAN_GMMLIB-DEVEL_PACKAGE_DEPENDS "intel-gmm-gmmlib")
651+
652+
set(CPACK_RPM_GMMLIB_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${DISTRO_INFO}-${PACKAGE_TYPE}.rpm")
653+
654+
set(CPACK_RPM_GMMLIB-DEVEL_PACKAGE_DEPENDS "intel-gmm-gmmlib")
655+
656+
SET(CPACK_COMPONENTS_ALL gmmlib gmmlib-devel)
657+
658+
include (CPack)
659+
660+
endif()

Source/GmmLib/igdgmm.h.in

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#ifndef IGDGMM_H
24+
#define IGDGMM_H
25+
26+
#cmakedefine IGDGMM_LIBRARY_NAME "${CMAKE_SHARED_LIBRARY_PREFIX}${IGDGMM_LIBRARY_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}"
27+
28+
#endif /* IGDGMM_H */

Source/GmmLib/igdgmm.pc.in

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
prefix=@GMMLIB_INSTALL_TIME_ROOT_DIR@
2+
exec_prefix=${prefix}
3+
includedir=${prefix}/include/igdgmm
4+
libdir=${exec_prefix}/lib
5+
6+
Name: igdgmm
7+
Description: Intel(R) Graphics Memory Management Library
8+
Version: @MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@
9+
Cflags: -I${includedir} -I${includedir}/GmmLib -I${includedir}/GmmLib/inc -I${includedir}/inc -I${includedir}/inc/common -I${includedir}/util
10+
Libs:
11+

Source/GmmLib/inc/External/Common/GmmCommonExt.h

+12-8
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ OTHER DEALINGS IN THE SOFTWARE.
3333

3434
#ifdef _WIN32
3535

36-
#ifdef GMM_LIB_DLL_EXPORTS /* To be defined for WIN32 only*/
37-
#define GMM_LIB_API __declspec(dllexport) /* Macro to define GMM Lib DLL exports */
38-
#else
39-
#define GMM_LIB_API __declspec(dllimport) /* Macro to define GMM Lib DLL imports */
40-
#endif /* GMM_LIB_DLL_EXPORTS */
41-
42-
#else // Linux doesnt need declspec macro
43-
#define GMM_LIB_API
36+
#ifdef GMM_LIB_DLL_EXPORTS
37+
#define GMM_LIB_API __declspec(dllexport) /* Macro to define GMM Lib DLL exports */
38+
#else
39+
#define GMM_LIB_API __declspec(dllimport) /* Macro to define GMM Lib DLL imports */
40+
#endif /* GMM_LIB_DLL_EXPORTS */
41+
42+
#else // Linux
43+
#ifdef GMM_LIB_DLL_EXPORTS
44+
#define GMM_LIB_API __attribute__ ((visibility ("default")))
45+
#else
46+
#define GMM_LIB_API
47+
#endif
4448
#endif
4549

4650
#else // !GMM_LIB_DLL

Source/GmmLib/inc/External/Linux/GmmResourceInfoLin.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ OTHER DEALINGS IN THE SOFTWARE.
3333
/////////////////////////////////////////////////////////////////////////////////////
3434
namespace GmmLib
3535
{
36-
class NON_PAGED_SECTION GmmResourceInfoLin:
36+
class GMM_LIB_API NON_PAGED_SECTION GmmResourceInfoLin:
3737
public GmmResourceInfoCommon
3838
{
3939
public:
@@ -59,4 +59,4 @@ namespace GmmLib
5959
} // namespace GmmLib
6060
#else
6161
typedef struct GmmResourceInfo GmmResourceInfo;
62-
#endif // #ifdef __cplusplus
62+
#endif // #ifdef __cplusplus

0 commit comments

Comments
 (0)