-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
204 lines (176 loc) · 9.73 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12)
PROJECT (OpenICC)
SET( ${PROJECT_NAME}_MAJOR_VERSION 0)
SET( ${PROJECT_NAME}_MINOR_VERSION 1)
SET( ${PROJECT_NAME}_MICRO_VERSION 1)
SET( ${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_MICRO_VERSION} )
SET (PROJECT_UP_NAME "OPENICC" )
SET (PROJECT_DOWN_NAME "openicc" )
SET (PACKAGE_NAME "${PROJECT_DOWN_NAME}" )
SET (PACKAGE_DESCRIPTION "The OpenICC configuration data base allows to store, share and manipulate
color management informations.")
SET( OI_CMMSUBPATH "color/modules" )
SET( OI_METASUBPATH "${PACKAGE_NAME}" )
SET( ${PROJECT_UP_NAME}_MAJOR_VERSION ${${PROJECT_NAME}_MAJOR_VERSION} )
SET( ${PROJECT_UP_NAME}_MINOR_VERSION ${${PROJECT_NAME}_MINOR_VERSION} )
SET( ${PROJECT_UP_NAME}_MICRO_VERSION ${${PROJECT_NAME}_MICRO_VERSION} )
SET( ${PROJECT_UP_NAME}_VERSION ${${PROJECT_NAME}_VERSION} )
#additional cmake modules for loading libraries
SET (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF (NOT CMAKE_BUILD_TYPE)
# some basic and important variables
SET( DOMAIN openicc.org ) #needed by doxygen
SET( REVERSE_DOMAIN org.openicc )
SET( ${PROJECT_NAME}_VERSION_MAJORMINOR "${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}" )
include(GNUInstallDirs)
option(ENABLE_TESTS_${PROJECT_UP_NAME} "Build tests (requires static libs)" ON)
option(ENABLE_TOOLS_${PROJECT_UP_NAME} "Build tools (currently openicc-device)" ON)
OPTION(ENABLE_SHARED_LIBS_${PROJECT_UP_NAME} "Build dynamic link libs" ON)
option(ENABLE_STATIC_LIBS_${PROJECT_UP_NAME} "Build static libs" ON)
OPTION(ENABLE_DOCU_${PROJECT_UP_NAME} "Build HTML documentation out of sources" ON)
IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} AND NOT CMAKE_CROSSCOMPILING)
OPTION(ENABLE_INSTALL_${PROJECT_UP_NAME} "Install files" ON)
ELSE()
IF(CMAKE_CROSSCOMPILING)
OPTION(ENABLE_INSTALL_${PROJECT_UP_NAME} "Install files" ON)
ELSE()
MESSAGE( "-- Oyjl: compile as subproject - skip install (ENABLE_INSTALL_${PROJECT_UP_NAME}=OFF)" )
# disable install and build of shared libs for fallback subproject
IF(NOT ENABLE_INSTALL_${PROJECT_UP_NAME})
SET(ENABLE_INSTALL_${PROJECT_UP_NAME} OFF)
ENDIF(NOT ENABLE_INSTALL_${PROJECT_UP_NAME})
ENDIF()
SET(ENABLE_STATIC_LIBS_${PROJECT_UP_NAME} ON)
SET(ENABLE_SHARED_LIBS_${PROJECT_UP_NAME} OFF)
SET(ENABLE_TESTS_${PROJECT_UP_NAME} OFF)
SET(ENABLE_TOOLS_${PROJECT_UP_NAME} OFF)
SET(ENABLE_DOCU_${PROJECT_UP_NAME} OFF)
MESSAGE( "-- ENABLE_STATIC_LIBS_${PROJECT_UP_NAME}: ${ENABLE_STATIC_LIBS_${PROJECT_UP_NAME}}" )
MESSAGE( "-- ENABLE_SHARED_LIBS_${PROJECT_UP_NAME}: ${ENABLE_SHARED_LIBS_${PROJECT_UP_NAME}}" )
MESSAGE( "-- ENABLE_TESTS_${PROJECT_UP_NAME}: ${ENABLE_TESTS_${PROJECT_UP_NAME}}" )
MESSAGE( "-- ENABLE_TOOLS_${PROJECT_UP_NAME}: ${ENABLE_TOOLS_${PROJECT_UP_NAME}}" )
MESSAGE( "-- ENABLE_DOCU_${PROJECT_UP_NAME}: ${ENABLE_DOCU_${PROJECT_UP_NAME}}" )
ENDIF()
IF( ENABLE_TESTS_${PROJECT_UP_NAME} )
SET(ENABLE_STATIC_LIBS_${PROJECT_UP_NAME}:BOOL=ON)
ENDIF()
# if our static code lands inside a shared lib, we need -fPIC
IF(ENABLE_SHARED_LIBS_${PROJECT_UP_NAME})
SET( CMAKE_POSITION_INDEPENDENT_CODE ON)
ENDIF()
IF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(PLATFORM "OSX")
ELSEIF( ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(PLATFORM "Linux")
ELSE( ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(PLATFORM "${CMAKE_SYSTEM_NAME}")
ENDIF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
MESSAGE( "-- Found PLATFORM: ${PLATFORM}" )
IF( CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" )
SET( DEBUG 1 )
ENDIF()
MESSAGE( "-- CMAKE_BUILD_TYPE: \"${CMAKE_BUILD_TYPE}\"" )
FIND_PROGRAM(CMAKE_AR_TMP NAMES ar)
IF( NOT DOC_PATH )
SET( DOC_PATH "${CMAKE_SOURCE_DIR}/docs" )
ENDIF( NOT DOC_PATH )
# detect top level projects
IF(USE_SYSTEM_OYJL)
FIND_PACKAGE(Oyjl REQUIRED)
ELSE()
FIND_PACKAGE(Oyjl)
ENDIF()
IF( HAVE_OYJL )
INCLUDE_DIRECTORIES( ${OYJL_INCLUDE_DIR} )
LINK_DIRECTORIES( ${OYJL_LIBRARY_DIRS} )
INCLUDE( CheckIncludeFiles )
CHECK_INCLUDE_FILES( oyjl/oyjl_version.h HAVE_OYJL_VERSION_H )
IF( NOT HAVE_OYJL_VERSION_H )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/oyjl/ )
ENDIF( NOT HAVE_OYJL_VERSION_H )
ELSE( HAVE_OYJL )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/src/include )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/oyjl )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}/oyjl )
LINK_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}/oyjl )
SET( CMAKE_POSITION_INDEPENDENT_CODE ON)
ADD_SUBDIRECTORY( oyjl )
SET( OYJL_LIBRARIES oyjl-static )
SET( OYJL_CORE_LIBRARY oyjl-core-static )
ENDIF( HAVE_OYJL )
SET( EXTRA_LIBS_CORE ${EXTRA_LIBS_CORE} ${OYJL_CORE_LIBRARY} )
SET( EXTRA_LIBS ${EXTRA_LIBS} ${OYJL_LIBRARIES} )
IF(NOT HAVE_YAJL)
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/oyjl/yajl )
ENDIF(NOT HAVE_YAJL)
#now add all directories
ADD_SUBDIRECTORY( src )
ADD_SUBDIRECTORY( cmake )
ADD_SUBDIRECTORY( extras )
#ADD_SUBDIRECTORY( settings )
IF(ENABLE_DOCU_${PROJECT_UP_NAME})
ADD_SUBDIRECTORY( docs )
ENDIF(ENABLE_DOCU_${PROJECT_UP_NAME})
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/OpenIccUninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/OpenIccUninstall.cmake"
IMMEDIATE @ONLY)
IF(ENABLE_INSTALL_${PROJECT_UP_NAME})
ADD_CUSTOM_TARGET( uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/OpenIccUninstall.cmake")
ADD_CUSTOM_TARGET( dist
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/ && git archive --prefix=${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}/ --format=tar HEAD > ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar
COMMAND echo "git: git clone git://guthub.com/openicc-cms/${PACKAGE_NAME}.git" > ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND echo "git sha1: " | tr -d "\\n" >> ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/ && git rev-parse HEAD >> ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND rm -rf ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION} && tar xf ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar
COMMAND tar cf - ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION} | bzip2 > ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2
COMMAND echo "package: http://sourceforge.net/projects/openicc/files/OpenICC/${PACKAGE_NAME}%20${${PROJECT_NAME}_VERSION_MAJORMINOR}/${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2" >> ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND echo "size: " | tr -d "\\n" >> ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND du -b ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2 | sed s/[[:space:]][[:print:]]*// >> ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND echo "md5sum: " | tr -d "\\n" >> ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND cd ${CMAKE_CURRENT_BINARY_DIR}/ && md5sum ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2 >> ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND echo "sha1sum: " | tr -d "\\n" >> ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND sha1sum ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2 >> ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND echo "sha256sum: " | tr -d "\\n" >> ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMAND sha256sum ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2 >> ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2.hashsum
COMMENT Make a ${PACKAGE_NAME} source package by using git
VERBATIM
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
EXECUTE_PROCESS(COMMAND rpmbuild --showrc
COMMAND awk '/^build arch/ {print $$4}'
OUTPUT_VARIABLE RPMARCH
ERROR_VARIABLE RPMBUILD_ERROR
)
ADD_CUSTOM_TARGET( rpm
COMMAND test -d ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}/ && rm -rf ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}/
COMMAND tar xjf ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2
COMMAND mkdir -p rpmdir/BUILD rpmdir/SPECS rpmdir/SOURCES rpmdir/SRPMS rpmdir/RPMS/${RPMARCH}
COMMAND cp -f ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2 rpmdir/SOURCES
COMMAND rpmbuild --clean -ba extras/${PACKAGE_NAME}.spec --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}/rpmdir"
DEPENDS dist
COMMENT Make a ${PACKAGE_NAME} RPM package
VERBATIM
)
ADD_CUSTOM_TARGET( debsrc
COMMAND test -d ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}/ && rm -rf ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}/
COMMAND tar xjf ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2
COMMAND mv ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}.tar.bz2 ${PACKAGE_NAME}_${${PROJECT_NAME}_VERSION}.orig.tar.bz2
COMMAND cp -R ${CMAKE_SOURCE_DIR}/extras/debian ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}/
COMMAND dpkg-source -b ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}/
DEPENDS dist
COMMENT Make a ${PACKAGE_NAME}# DEB source package
VERBATIM
)
ADD_CUSTOM_TARGET( debian
COMMAND cd ${PACKAGE_NAME}-${${PROJECT_NAME}_VERSION}/ && debuild
DEPENDS debsrc
COMMENT Make a ${PACKAGE_NAME} DEB package
VERBATIM
)
ENDIF(ENABLE_INSTALL_${PROJECT_UP_NAME})
INCLUDE(FeatureSummary)
FEATURE_SUMMARY(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)