forked from danse-inelastic/histogram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
148 lines (132 loc) · 4.88 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
139
140
141
142
143
144
145
146
147
148
# To improve
# * dependency items are declared at different places
# - This file two places DEP_DANSE_PKGS, CPACK_DEBIAN_PACKAGE_DEPENDS
# - File rpm.spec.in
# * rpm and deb releases are treated differently:
# - rpm: source rpm
# - deb: binary deb
# * upload-<> should also upload to github release site
cmake_minimum_required (VERSION 2.6)
project (histogram)
set(VERSION "0.3.9")
set(AUTHOR "Jiao Lin")
set(AUTHOR_EMAILE "[email protected]")
set(VENDOR "DANSE")
set(SUMMARY "histogram")
set(LICENSE "BSD")
set(RPM_APP_GROUP "Development/Tools")
set(GITHUB_URL "https://github.com/neutrons/histogram-dev") # this repo
set (HOMEPAGE ${GITHUB_URL})
# this is released with danse.ins packages
set(DEP_DANSE_PKGS "danse.ins")
# package repository at packagecloud
set (PKGCLOUD_USERNAME "danse")
set (PKGCLOUD_REPO "ins")
# debian
# set(DOCKER_PKGING_DEB_DIST_NAME "ubuntu")
# set(DOCKER_PKGING_DEB_DIST_VERSION "12.04")
# dependencies
set (DOCKER_PKGING_DEPS_DEB "python-numpy danse.ins pyre")
set (DOCKER_PKGING_DEPS_RPM "numpy danse.ins pyre")
set (DOCKER_PKGING_TEST_SRPM ". /opt/danse/bin/setup-danse.sh && python -c 'import histogram as p; print p'")
set (DOCKER_PKGING_TEST_RPM ${DOCKER_PKGING_TEST_SRPM})
set (DOCKER_PKGING_TEST_DEB ${DOCKER_PKGING_TEST_SRPM})
set (CONDA_PKGING_BUILD_DEPS "python numpy")
set (CONDA_PKGING_RUN_DEPS "python numpy danse.ins pyre h5py")
# variables
set (PYBINDING_NAME "${PROJECT_NAME}module")
set (LIB_NAME "${PROJECT_NAME}")
set (PKG_NAME "${PROJECT_NAME}")
# get cmake_utils
IF(EXISTS "cmake_utils/")
execute_process(
COMMAND git pull
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/cmake_utils
)
ELSE(EXISTS "cmake_utils/")
execute_process(
COMMAND git clone https://github.com/danse-inelastic/cmake_utils
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
ENDIF(EXISTS "cmake_utils/")
set(CMAKE_MODULE_PATH ${PROJECT_BINARY_DIR}/cmake_utils)
# lib64
include(System)
# ABI
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
# needs python
find_package ( PythonLibs REQUIRED )
find_package ( PythonInterp REQUIRED )
# python installation path
set(INSTALL_PY_PATH "${INSTALL_LIB_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
#
enable_testing()
# subdirs
add_subdirectory(lib)
# add_subdirectory(pyext)
add_subdirectory(src)
add_subdirectory(bin)
# add_subdirectory(etc)
add_subdirectory(tests)
# packaging
# CPACK
set(CPACK_PACKAGE_VERSION ${VERSION})
# set(CPACK_GENERATOR "RPM")
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME ${PKG_NAME})
set(CPACK_PACKAGE_SUMMARY ${SUMMARY})
set(CPACK_PACKAGE_LICENSE ${LICENSE})
set(CPACK_PACKAGE_RELEASE 0)
set(CPACK_PACKAGE_APP_GROUP ${RPM_APP_GROUP})
set(CPACK_PACKAGE_CONTACT ${AUTHOR})
set(CPACK_PACKAGE_VENDOR ${VENDOR})
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_RPM_PACKAGE_REQUIRES "cmake")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python, danse.ins")
include(CPack)
# source tar ball
add_custom_command(
OUTPUT ${PKG_NAME}-${CPACK_PACKAGE_VERSION}.tar.gz
COMMAND git archive --format=tar --prefix=${PKG_NAME}-${CPACK_PACKAGE_VERSION}/ HEAD | gzip -c > ${CMAKE_CURRENT_BINARY_DIR}/${PKG_NAME}-${CPACK_PACKAGE_VERSION}.tar.gz
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(
src_tgz
DEPENDS ${PKG_NAME}-${CPACK_PACKAGE_VERSION}.tar.gz
)
# CPack does not have a rule for source rpm
# the following is a way to do that
#
set(RPM_BUILD_DIR rpm_build)
# rpm spec file
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rpm.spec.in
${CMAKE_CURRENT_BINARY_DIR}/${RPM_BUILD_DIR}/SPECS/${PKG_NAME}.spec )
# rules to build src rpm
set(SRC_RPM ${PKG_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.src.rpm)
add_custom_command(
OUTPUT ${SRC_RPM}
COMMAND ${CMAKE_COMMAND} -E make_directory ${RPM_BUILD_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${RPM_BUILD_DIR}/BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${RPM_BUILD_DIR}/BUILDROOT
COMMAND ${CMAKE_COMMAND} -E make_directory ${RPM_BUILD_DIR}/RPMS
COMMAND ${CMAKE_COMMAND} -E make_directory ${RPM_BUILD_DIR}/SOURCES
COMMAND ${CMAKE_COMMAND} -E make_directory ${RPM_BUILD_DIR}/SPECS
COMMAND ${CMAKE_COMMAND} -E make_directory ${RPM_BUILD_DIR}/SRPMS
COMMAND ${CMAKE_COMMAND} -E make_directory ${RPM_BUILD_DIR}/tmp
COMMAND ${CMAKE_COMMAND} -E copy ${PKG_NAME}-${CPACK_PACKAGE_VERSION}.tar.gz ${RPM_BUILD_DIR}/SOURCES
COMMAND rpmbuild -bs --define=\"_topdir ${RPM_BUILD_DIR}\" --buildroot=${RPM_BUILD_DIR}/tmp ${RPM_BUILD_DIR}/SPECS/${PKG_NAME}.spec
COMMAND ${CMAKE_COMMAND} -E copy ${RPM_BUILD_DIR}/SRPMS/${SRC_RPM} ${SRC_RPM}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS src_tgz
)
add_custom_target(
srpm
DEPENDS ${SRC_RPM}
)
# folders for build and test packaging artifacts
# deb/rpm
include(docker)
# conda
include(conda)