-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
111 lines (103 loc) · 3.95 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#
# This file is a part of the Sharemind framework.
# Copyright (C) Cybernetica AS
#
# All rights are reserved. Reproduction in whole or part is prohibited
# without the written consent of the copyright owner. The usage of this
# code is subject to the appropriate license agreement.
#
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
PROJECT(profile-log-visualizer VERSION 1.0.3 LANGUAGES)
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/config.local" OPTIONAL)
INCLUDE("${CMAKE_CURRENT_BINARY_DIR}/config.local" OPTIONAL)
FIND_PACKAGE(SharemindCMakeHelpers 1.3 REQUIRED)
IF(DEFINED SHAREMIND_NPM_REGISTRY)
SET(NPM_REGISTRY "--registry" ${SHAREMIND_NPM_REGISTRY})
ENDIF()
FIND_PROGRAM(NPM NAMES "npm")
IF(NOT NPM)
MESSAGE(FATAL_ERROR "Required \"npm\" program not found!")
ENDIF()
# Dir where the source files are copied and npm install is run in
SET(NPM_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/tmp)
# Names of the binaries created by pkg and electron-packager
SET(PROJECT_GUI_BIN "sharemind-profile-visualizer-gui")
SET(PROJECT_CLI_BIN "sharemind-profile-visualizer-cli")
# NodeJS version packaged in the cli app binary
SET(PROJECT_NODEJS_VERSION "6")
SET(PROJECT_PLATFORM "linux")
SET(PROJECT_ARCH "x64")
SET(PROJECT_GUI_BIN_PATH
${NPM_BUILD_DIR}/${PROJECT_GUI_BIN}-${PROJECT_PLATFORM}-${PROJECT_ARCH}/${PROJECT_GUI_BIN})
# Use --ignore-scripts as we will run build anyway
# this way we only install dependencies here
SET(NPM_INSTALL_COMMAND ${NPM} install --ignore-scripts ${NPM_REGISTRY})
# Run the packaging npm scripts
SET(NPM_CLI_BUILD_COMMAND ${NPM} run-script package-cli && ${NPM} run-script package-gui )
# Create a list of project files we can use as a dependency for build command,
# if any of the files change then build is re-run.
FILE(GLOB_RECURSE PROJECT_FILES
"${NPM_BUILD_DIR}/app/*"
)
FILE(COPY "${CMAKE_CURRENT_SOURCE_DIR}/app" DESTINATION "${NPM_BUILD_DIR}")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/package.json" "${NPM_BUILD_DIR}/package.json" @ONLY)
# npm install
SET(NPM_INSTALL_STATUS ${CMAKE_CURRENT_BINARY_DIR}/tmp/npminstall.txt)
ADD_CUSTOM_COMMAND(
OUTPUT ${NPM_INSTALL_STATUS}
COMMAND ${NPM_INSTALL_COMMAND}
COMMAND ${CMAKE_COMMAND} -E touch ${NPM_INSTALL_STATUS}
WORKING_DIRECTORY ${NPM_BUILD_DIR}
COMMENT "npm install"
DEPENDS ${NPM_BUILD_DIR}/package.json
)
# build packages
ADD_CUSTOM_COMMAND(
OUTPUT "${NPM_BUILD_DIR}/${PROJECT_CLI_BIN}" ${PROJECT_GUI_BIN_PATH}
COMMAND ${NPM_CLI_BUILD_COMMAND}
WORKING_DIRECTORY ${NPM_BUILD_DIR}
COMMENT "run-script package-cli && package-gui"
DEPENDS ${NPM_INSTALL_STATUS} ${PROJECT_FILES}
)
ADD_CUSTOM_TARGET(
npm ALL
DEPENDS "${PROJECT_GUI_BIN_PATH}" "${NPM_BUILD_DIR}/${PROJECT_CLI_BIN}"
)
INSTALL(
PROGRAMS "${NPM_BUILD_DIR}/${PROJECT_CLI_BIN}"
DESTINATION bin
COMPONENT bin
)
INSTALL(
PROGRAMS ${PROJECT_GUI_BIN_PATH}
DESTINATION share/${PROJECT_GUI_BIN}-${PROJECT_PLATFORM}-${PROJECT_ARCH}
COMPONENT bin
)
INSTALL(
DIRECTORY ${NPM_BUILD_DIR}/${PROJECT_GUI_BIN}-${PROJECT_PLATFORM}-${PROJECT_ARCH}
DESTINATION share
COMPONENT bin
PATTERN ${PROJECT_GUI_BIN} EXCLUDE
)
# Generate symlink for gui app
INSTALL(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../share/${PROJECT_GUI_BIN}-${PROJECT_PLATFORM}-${PROJECT_ARCH}/${PROJECT_GUI_BIN} bin/${PROJECT_GUI_BIN} WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX})" COMPONENT bin)
# Install symlinks as FILES so that they would be included in packaging
INSTALL(
FILES ${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_GUI_BIN}
DESTINATION bin
COMPONENT bin
)
# Packaging:
SharemindSetupPackaging()
SharemindAddComponentPackage(bin
NAME "sharemind-profile-log-visualizer"
DESCRIPTION "Sharemind profile log visualizer GUI application"
DEB_SECTION "devel"
DEB_DEPENDS
"libasound2 (>= 1.1.0)"
"libgtk-3-0 (>= 3.22.0)"
"libnss3 (>= 3.26.0)"
"libx11-xcb1 (>= 1.6.0)"
"libxss1 (>= 1.2.0)"
)
SharemindPackagingFinalize()