-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
138 lines (109 loc) · 5.04 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
cmake_minimum_required(VERSION 3.15)
# Add the local cmake directory module path.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Pull information from git:
# GIT_SHA1 contains the complete git hash
#
# GIT_VERSION contains the name of the latest git tag, the number of commits
# since that tag was created and the start of the git hash if there have been
# changes since the tag was created.
# Example GIT_VERSION: 0.7-371-g12d9678
# GIT_VERSION_SHORT contains the same as GIT_VERSION but without the start of
# the last commits hash.
# Example GIT_VERSION_SHORT: 0.7-371
# GIT_VERSION_TAG contains only the tag part of the version
# Example GIT_VERSION_TAG: 0.7
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
git_describe(GIT_VERSION "--always")
string(REGEX REPLACE "^v" "" GIT_VERSION ${GIT_VERSION})
string(REGEX MATCH "^[0-9.]+(-beta[0-9]*|-rc[0-9]*)?(-[0-9]+)?" GIT_VERSION_SHORT ${GIT_VERSION})
string(REGEX MATCH "^[0-9.]+" GIT_VERSION_TAG ${GIT_VERSION})
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
message("-- GIT_VERSION=${GIT_VERSION}")
message("-- GIT_VERSION_SHORT=${GIT_VERSION_SHORT}")
message("-- GIT_VERSION_TAG=${GIT_VERSION_TAG}")
message("-- GIT_BRANCH=${GIT_BRANCH}")
project(mesydaq2 DESCRIPTION "mesytec mesydaq2 for MCPD-8_v1/v2" VERSION ${GIT_VERSION_TAG})
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
## Create binaries in the root of the build directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# Enable $ORIGIN in the rpath if supported by the target platform.
SET(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
SET(CMAKE_INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
set(CMAKE_VERBOSE_MAKEFILE ON)
add_subdirectory(src)
# Copy the default 192.168.168.121 config to the build directory for things to
# work.
if (NOT EXISTS ${CMAKE_BINARY_DIR}/mesycfg.mcfg)
FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/extras/example_configs/mesycfg.mcfg
DESTINATION ${CMAKE_BINARY_DIR})
endif()
# Also install the default config to the binary directory.
install(FILES extras/example_configs/mesycfg.mcfg TYPE BIN)
# CPack configuration used for 'make package'
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(PACKAGE_ARCH_STRING "x64")
else()
set(PACKAGE_ARCH_STRING "x32")
endif()
# Note: To produce stand-alone packages additional files need to be deployed to
# the target system: shared objects, Qt plugins, Qt configuration, shell
# scripts, etc.
#
# Under windows These files are handled using an external deploy directory
# which is added via the install() command.
#
# Under linux the `linuxdeployqt` tool and a custom cmake script for the cpack
# `External` generator are used.
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_PACKAGE_VENDOR "mesytec")
if (WIN32)
option(MESYTEC_CPACK_INSTALL_DEPLOY_FILES
"Install additional library files from a special deploy directory." OFF)
set(MESYTEC_CPACK_DEPLOY_DIR "c:/src/mvme2-deploy/windows/mvme-${PACKAGE_ARCH_STRING}-libusb-0.1-Release"
CACHE PATH "Directory containing additional files to be deployed."
)
if (MESYTEC_CPACK_INSTALL_DEPLOY_FILES)
install(DIRECTORY "${MESYTEC_CPACK_DEPLOY_DIR}/" DESTINATION . USE_SOURCE_PERMISSIONS)
endif()
set(CPACK_GENERATOR "ZIP") # FIXME: no NSIS for now. start menu entry is not created
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_NSIS_PACKAGE_NAME "mesydaq2")
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "bin\\\\mesydaq2.exe")
set(CPACK_NSIS_URL_INFO_ABOUT "http://www.mesytec.com")
set(CPACK_NSIS_CONTACT "[email protected]")
else()
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/extras/init_mesydaq2" DESTINATION bin)
option(MESYDAQ2_CPACK_USE_LINUXDEPLOYQT "Use 'linuxdeployqt' to create universal binary packages." OFF)
set(CPACK_SOURCE_GENERATOR "TBZ2")
if (MESYDAQ2_CPACK_USE_LINUXDEPLOYQT)
# Find linuxdeployqt here to error out early in case it's missing.
find_program(LINUXDEPLOYQT_EXECUTABLE linuxdeployqt REQUIRED)
set(CPACK_GENERATOR "External")
set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/CPackExternal_linuxdeployqt.cmake")
set(CPACK_EXTERNAL_ENABLE_STAGING TRUE)
else()
set(CPACK_GENERATOR "TBZ2")
endif()
endif()
# CPACK_PROJECT_CONFIG_FILE
# File included at cpack time, once per generator after setting CPACK_GENERATOR
# to the actual generator being used; allows per-generator setting of CPACK_*
# variables at cpack time.
# Default: ${PROJECT_BINARY_DIR}/CPackOptions.cmake
configure_file("CPackOptions.cmake.in" "${PROJECT_BINARY_DIR}/CPackOptions.cmake" @ONLY)
set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackOptions.cmake")
include(CPack)
# vim:tw=0