Skip to content

Commit b5110c7

Browse files
authored
Merge pull request #159 from intel-innersource/cpack
CPack support for Debian and RHEL families
2 parents b0b5859 + 03def22 commit b5110c7

File tree

4 files changed

+136
-0
lines changed

4 files changed

+136
-0
lines changed

.github/workflows/ci-cpack.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CPack check
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
pull_request:
7+
branches: [ '**' ]
8+
9+
jobs:
10+
job-build1:
11+
runs-on: ci-gcc9
12+
if: ${{ github.repository != 'opcm/pcm' }}
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Preparation
17+
run: |
18+
cd ${{ github.workspace }}/src
19+
git clone https://github.com/simdjson/simdjson.git
20+
cd ..
21+
- name: Configure CMake
22+
run: |
23+
cmake --version
24+
rm -rf ${{ github.workspace }}/build
25+
cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build
26+
- name: Build and Install
27+
run: |
28+
g++ --version
29+
cd ${{ github.workspace }}/build
30+
make -j$(nproc)
31+
- name: CPack
32+
run: |
33+
cd ${{ github.workspace }}/build
34+
cpack
35+
36+
job-build2:
37+
runs-on: ci-test
38+
if: ${{ github.repository != 'opcm/pcm' }}
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Preparation
43+
run: |
44+
cd ${{ github.workspace }}/src
45+
git clone https://github.com/simdjson/simdjson.git
46+
cd ..
47+
- name: Configure CMake
48+
run: |
49+
cmake --version
50+
rm -rf ${{ github.workspace }}/build
51+
cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build
52+
- name: Build and Install
53+
run: |
54+
g++ --version
55+
cd ${{ github.workspace }}/build
56+
make -j$(nproc)
57+
- name: CPack
58+
run: |
59+
cd ${{ github.workspace }}/build
60+
cpack

CMakeLists.txt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ if(UNIX) # APPLE, LINUX, FREE_BSD
6161

6262
endif(UNIX)
6363

64+
#######################
65+
# Install
66+
#######################
67+
6468
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
6569
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
6670

@@ -75,3 +79,60 @@ add_subdirectory(examples)
7579
add_subdirectory(tests)
7680

7781
message(STATUS "Install directory: ${CMAKE_INSTALL_PREFIX}")
82+
83+
#######################
84+
# CPack (only UNIX)
85+
#######################
86+
if(UNIX)
87+
if(EXISTS "/etc/debian_version") # for Debian family
88+
set(CPACK_GENERATOR "DEB")
89+
message(STATUS "CPACK_GENERATOR is DEB")
90+
elseif(EXISTS "/etc/redhat-release") # for RHEL, Fedora, CentOs
91+
set(CPACK_GENERATOR "RPM")
92+
message(STATUS "CPACK_GENERATOR is RPM")
93+
else()
94+
if(EXISTS "/etc/os-release")
95+
file(READ "/etc/os-release" OS_PARAMS)
96+
string(REGEX MATCH "suse" OUT ${OS_PARAMS}) # for Suse-like systems
97+
if(OUT STREQUAL "suse")
98+
set(CPACK_GENERATOR "RPM")
99+
message(STATUS "CPACK_GENERATOR is RPM")
100+
else()
101+
set(CPACK_GENERATOR "TXZ")
102+
set(CPACK_SET_DESTDIR ON)
103+
message(STATUS "CPACK_GENERATOR is TXZ")
104+
endif()
105+
else()
106+
set(CPACK_GENERATOR "TXZ")
107+
set(CPACK_SET_DESTDIR ON)
108+
message(STATUS "CPACK_GENERATOR is TXZ")
109+
endif()
110+
endif()
111+
112+
set(CPACK_PACKAGE_CONTACT "intel <[email protected]>")
113+
set(CPACK_PACKAGE_NAME "pcm")
114+
set(CPACK_PACKAGE_VERSION "0000")
115+
116+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Processor Counter Monitor (PCM)")
117+
set(CPACK_PACKAGE_DESCRIPTION "\
118+
Processor Counter Monitor (PCM) is an application programming\n\
119+
interface (API) and a set of tools based on the API to monitor\n\
120+
performance and energy metrics of Intel(r) Core(tm), Xeon(r), Atom(tm)\n\
121+
and Xeon Phi(tm) processors. PCM works on Linux, Windows, Mac OS X,\n\
122+
FreeBSD and DragonFlyBSD operating systems.")
123+
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
124+
125+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
126+
set(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
127+
128+
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX})
129+
set(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
130+
131+
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
132+
set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE)
133+
134+
set(CPACK_DEB_COMPONENT_INSTALL ON)
135+
set(CPACK_RPM_COMPONENT_INSTALL ON)
136+
137+
include (CPack)
138+
endif(UNIX)

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,17 @@ Custom compilation options
109109
--------------------------------------------------------------------------------
110110
The list of custom compilation options is located [here](doc/CUSTOM-COMPILE-OPTIONS.md)
111111

112+
--------------------------------------------------------------------------------
113+
Packaging
114+
--------------------------------------------------------------------------------
115+
Packaging with CPack is supported on Debian and Redhat/SUSE system families.
116+
To create DEB of RPM package need to call cpack after building in build folder:
117+
```
118+
cd build
119+
cpack
120+
```
121+
This creates package:
122+
- "pcm-VERSION-Linux.deb" on Debian family systems;
123+
- "pcm-VERSION-Linux.rpm" on Redhat/SUSE-family systems.
124+
Packages contain pcm-\* binaries and required for usage opCode-\* files.
112125

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ file(GLOB COMMON_SOURCES msr.cpp cpucounters.cpp pci.cpp mmio.cpp bw.cpp utils.c
1717
file(GLOB UNUX_SOURCES dashboard.cpp resctrl.cpp)
1818

1919
if(UNIX) # LINUX, FREE_BSD, APPLE
20+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} -s") # --strip-unneeded for packaging
21+
2022
list(APPEND PROJECT_NAMES pcm-sensor)
2123
if(LINUX)
2224
list(APPEND PROJECT_NAMES pcm-sensor-server)

0 commit comments

Comments
 (0)