CMakeLists.txt 10.4 KB
Newer Older
Olivier Langella's avatar
Olivier Langella committed
1
2
3
4
5
# CMake script for C++ X!TandemPipeline
# Author: Olivier Langella
# Created: 05/06/2015

# Global parameters
6
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
Olivier Langella's avatar
Olivier Langella committed
7
PROJECT(xtpcpp CXX)
Langella Olivier's avatar
Langella Olivier committed
8

Filippo Rusconi's avatar
Filippo Rusconi committed
9
10
set(XTPCPP_VERSION_MAJOR "0")
set(XTPCPP_VERSION_MINOR "4")
11
set(XTPCPP_VERSION_PATCH "32")
Filippo Rusconi's avatar
Filippo Rusconi committed
12
set(XTPCPP_VERSION "${XTPCPP_VERSION_MAJOR}.${XTPCPP_VERSION_MINOR}.${XTPCPP_VERSION_PATCH}")
13
set(VERSION 0.4.32)
Langella Olivier's avatar
Langella Olivier committed
14

15
16
# Set additional project information
set(COMPANY "pappso.org")
17
set(COPYRIGHT "Copyright (c) 2021 PAPPSO. Licensed under GPLv3+")
18
19
20
set(IDENTIFIER "org.pappso")


21
#depending on libpappsomspp version :
22
set(LIBPAPPSOMSPP_VERSION "0.8.29")
Filippo Rusconi's avatar
Filippo Rusconi committed
23
set(LIBRDATA_VERSION "0~20210223+git-85757dc6")
Langella Olivier's avatar
Langella Olivier committed
24

25
26
27
28
29
30
31
32
33
34
35
36
# Add folder where are supportive functions
set(CMAKE_UTILS_PATH ${CMAKE_SOURCE_DIR}/CMakeStuff)
set(CMAKE_TOOLCHAINS_PATH ${CMAKE_UTILS_PATH}/toolchains)
set(CMAKE_MODULE_PATH ${CMAKE_UTILS_PATH}/modules)

# Include the system's uname that fills in SYSTEM_UNAME_S.
# Sets WIN64 if SYSTEM_UNAME_S is "^.*MING64.*"
include(${CMAKE_UTILS_PATH}/systemUname.cmake)

# Include the various colors we want to use in the output
include(${CMAKE_UTILS_PATH}/outputColors.cmake)

37
38
39
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_VERBOSE_MAKEFILE ON)

40
message("\n${BoldRed}Configuring build for project ${PROJECT}${ColourReset}\n")
41

Langella Olivier's avatar
Langella Olivier committed
42
43
44
45
46
47
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# We want C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(STATUS "${BoldGreen}CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}${ColourReset}")

#############################################################
# We do not want warnings for unknown pragmas:
message(STATUS "Setting definition -Wno-unknown-pragmas.${ColourReset}")
add_definitions(-Wno-unknown-pragmas)
# Enable warnings and possibly treat them as errors
message(STATUS "${BoldGreen}Setting definition -Wall.${ColourReset}")
add_definitions(-Wall)
message(STATUS "${BoldGreen}Setting definition -Wextra.${ColourReset}")
add_definitions(-Wextra)

if(WARN_AS_ERROR)
Filippo Rusconi's avatar
Filippo Rusconi committed
64
65
  message(STATUS "${BoldYellow}Setting definition -Werror.${ColourReset}")
  add_definitions(-Werror)
66
67
68
69
70
71
72
73
74
endif()

message(STATUS "${BoldRed}CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}${ColourReset}")


#############################################################
#############################################################
# Platform-specific CMake configuration
if(MXE)
Filippo Rusconi's avatar
Filippo Rusconi committed
75
76
77
78
  # Run the following cmake command line:
  # x86_64-w64-mingw32.shared-cmake -DCMAKE_BUILD_TYPE=Release -DMXE=1 ../development
  #include(${CMAKE_TOOLCHAINS_PATH}/mxe-toolchain.cmake)
  include(${CMAKE_TOOLCHAINS_PATH}/mxe-toolchain-olivier.cmake)
79

Filippo Rusconi's avatar
Filippo Rusconi committed
80
81
82
  # Set the name to the systemUname variable because in this situation that name
  # is not found, it it passed as a flag in the command line.
  set(systemUname "mxe")
83
84

elseif(UNIX AND NOT APPLE)
Filippo Rusconi's avatar
Filippo Rusconi committed
85
86
  # Run the following cmake command line:
  # cmake -DBUILD_USER_MANUAL=1 -DCMAKE_BUILD_TYPE=Debug
87

Filippo Rusconi's avatar
Filippo Rusconi committed
88
89
90
  include(${CMAKE_TOOLCHAINS_PATH}/unix-toolchain.cmake)
  #include(${CMAKE_TOOLCHAINS_PATH}/unix-toolchain-olivier.cmake)
  #include(${CMAKE_TOOLCHAINS_PATH}/unix-toolchain-pappsomsppdev.cmake)
91
92

elseif(WIN64)
Filippo Rusconi's avatar
Filippo Rusconi committed
93
94
  # Run the following cmake command line:
  # cmake -DBUILD_USER_MANUAL=0 -DCMAKE_BUILD_TYPE=Release ../development
95

Filippo Rusconi's avatar
Filippo Rusconi committed
96
  include(${CMAKE_TOOLCHAINS_PATH}/win10-mingw64-toolchain.cmake)
97
98

elseif(APPLE)
Filippo Rusconi's avatar
Filippo Rusconi committed
99
100
  # Run the following cmake command line:
  # cmake -DBUILD_USER_MANUAL=0 -DCMAKE_BUILD_TYPE=Release ../development
101

Filippo Rusconi's avatar
Filippo Rusconi committed
102
  include(${CMAKE_TOOLCHAINS_PATH}/apple-macport-toolchain.cmake)
103

104
105
106
107
108
109
110
endif()

message("")
message(STATUS "${BoldGreen}Starting configuration of ${PROJECT}${ColourReset}")
message("")
message(STATUS "${BoldYellow}The build toolchain is: ${SystemUname}${ColourReset}")
message("")
Olivier Langella's avatar
Olivier Langella committed
111

Langella Olivier's avatar
Langella Olivier committed
112
113


114
115
116
117
118
119
120
121
122
#############################################################
#############################################################
# Essential software configuration
message(STATUS "CMAKE_CURRENT_BINARY_DIR: " ${CMAKE_CURRENT_BINARY_DIR})

# Gee, do not set that to default!
# set(MAKE_TEST 1)

if(NOT CMAKE_BUILD_TYPE)
Filippo Rusconi's avatar
Filippo Rusconi committed
123
124
125
  set(CMAKE_BUILD_TYPE Release CACHE STRING
    "Type of build, options are: None, Debug, Release, RelWithDebInfo, MinSizeRel."
    FORCE)
126
127
128
endif(NOT CMAKE_BUILD_TYPE)

if(CMAKE_BUILD_TYPE MATCHES "Release")
Filippo Rusconi's avatar
Filippo Rusconi committed
129
130
  message(STATUS "Compiling in release mode.")
  add_definitions("-DQT_NO_DEBUG_OUTPUT")
Langella Olivier's avatar
Langella Olivier committed
131
endif()
132
133

if(CMAKE_BUILD_TYPE MATCHES "Debug")
Filippo Rusconi's avatar
Filippo Rusconi committed
134
135
136
  message(STATUS "Compiling in debug mode with MAKE_TEST: ${MAKE_TEST}.")
  message(STATUS "Add definition -ggdb3 to format debug output for GDB.")
  add_definitions(-ggdb3)
137
138
139
endif()

if(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
Filippo Rusconi's avatar
Filippo Rusconi committed
140
  message(STATUS "Compiling in release with debug info mode.")
141
142
143
endif( CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo" )

message(STATUS "${BoldYellow}CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}.${ColourReset}")
Langella Olivier's avatar
Langella Olivier committed
144

Filippo Rusconi's avatar
Filippo Rusconi committed
145
146
# Automate the production of correctly-versioned d/control file.
configure_file (${CMAKE_SOURCE_DIR}/debian/control.cmake.in ${CMAKE_SOURCE_DIR}/debian/control @ONLY)
Olivier Langella's avatar
Olivier Langella committed
147

Olivier Langella's avatar
Olivier Langella committed
148

149
set(SOFTWARE_NAME "X!TandemPipeline")
Olivier Langella's avatar
Olivier Langella committed
150

151
set(BUILD_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
152

Olivier Langella's avatar
Olivier Langella committed
153
154
# Set the CMAKE_PREFIX_PATH for the find_library fonction when using non
# standard install location
155
156
157
if(CMAKE_INSTALL_PREFIX)
  set(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" ${CMAKE_PREFIX_PATH})
endif(CMAKE_INSTALL_PREFIX)
Olivier Langella's avatar
Olivier Langella committed
158
159

# Subdirectories
160
add_subdirectory(src)
161
add_subdirectory(doc)
Olivier Langella's avatar
Olivier Langella committed
162

Langella Olivier's avatar
Langella Olivier committed
163
if(UNIX)
Filippo Rusconi's avatar
Filippo Rusconi committed
164
165
166
  # Doxygen
  find_package(Doxygen)
  if(DOXYGEN_FOUND)
Langella Olivier's avatar
Langella Olivier committed
167
    add_custom_target(apidoc cp Doxyfile ${CMAKE_BINARY_DIR}/Doxyfile-build
Filippo Rusconi's avatar
Filippo Rusconi committed
168
169
170
      COMMAND echo "OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}" >> ${CMAKE_BINARY_DIR}/Doxyfile-build
      COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile-build
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
Langella Olivier's avatar
Langella Olivier committed
171
    add_custom_target(apidoc-stable cp Doxyfile ${CMAKE_BINARY_DIR}/Doxyfile-stable
Filippo Rusconi's avatar
Filippo Rusconi committed
172
173
174
175
176
      COMMAND echo "OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}" >> ${CMAKE_BINARY_DIR}/Doxyfile-stable
      COMMAND echo "HTML_HEADER=header.html" >> ${CMAKE_BINARY_DIR}/Doxyfile-stable
      COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile-stable
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
  endif(DOXYGEN_FOUND)
Langella Olivier's avatar
Langella Olivier committed
177
endif(UNIX)
Olivier Langella's avatar
Olivier Langella committed
178
# Packager
179
180
181
182
183
184
185
186
187
188
189
190
set(CPACK_PACKAGE_NAME "xtpcpp")
set(CPACK_PACKAGE_VENDOR "PAPPSO Development Team")
set(CPACK_PACKAGE_VERSION "${XTPCPP_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${XTPCPP_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${XTPCPP_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${XTPCPP_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "protein inference tool")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_RESOURCE_FILE_AUTHORS "${CMAKE_SOURCE_DIR}/AUTHORS")
set(CPACK_RESOURCE_FILE_INSTALL "${CMAKE_SOURCE_DIR}/INSTALL")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES
Filippo Rusconi's avatar
Filippo Rusconi committed
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
  "CMakeFiles"
  "Makefile"
  "_CPack_Packages"
  "CMakeCache.txt"
  ".*\\\\.git"
  ".*\\\\.gz"
  ".*\\\\.deb"
  ".*\\\\.rpm"
  ".*\\\\.dmg"
  ".*\\\\.xpip"
  ".*\\\\..*\\\\.swp"
  "src/\\\\..*"
  "src/libbpp*"
  "debian/tmp"
  "debian/libbpp.*/"
  "debian/libbpp.*\\\\.so.*"
  "debian/libbpp.*\\\\.a"
  "debian/libbpp.*\\\\.substvars"
  "debian/libbpp.*\\\\.debhelper"
  "debian/debhelper\\\\.log"
  "build/"
  "cbuild/"
  "wbuild/"
  "Core.tag"
  "Testing"
  "build-stamp"
  "install_manifest.txt"
  "DartConfiguration.tcl"
  ${CPACK_SOURCE_IGNORE_FILES}
  )
Olivier Langella's avatar
Olivier Langella committed
221
222
223
224
225
226



#dch -Djessie "message"
#cmake ..
#make deb
Olivier Langella's avatar
Olivier Langella committed
227
# scp xtpcpp* proteus.moulon.inra.fr:/var/www/apt/incoming
Olivier Langella's avatar
Olivier Langella committed
228
229
230
231
232
# reprepro -Vb /var/www/apt processincoming default
#
#  debuild -S -sa
# dput -f olivier-langella *changes

233
if(MACOS)
Olivier Langella's avatar
Olivier Langella committed
234
  SET(CPACK_GENERATOR "Bundle")
235
endif()
Olivier Langella's avatar
Olivier Langella committed
236

237
238
239
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_DEBSOURCE_PACKAGE_FILE_NAME "lib${CMAKE_PROJECT_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.orig")
iNCLUDE(CPack)
Olivier Langella's avatar
Olivier Langella committed
240
241

#This adds the 'dist' target
242
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
Olivier Langella's avatar
Olivier Langella committed
243
# 'clean' is not (yet) a first class target. However, we need to clean the directories before building the sources:
244
245
if("${CMAKE_GENERATOR}" MATCHES "Make")
  add_custom_target(make_clean
Filippo Rusconi's avatar
Filippo Rusconi committed
246
247
248
    COMMAND ${CMAKE_MAKE_PROGRAM} clean
    WORKING_DIRECTORY ${CMAKE_CURRENT_DIR}
    )
249
250
  Add_dependencies(dist make_clean)
endif()
Olivier Langella's avatar
Olivier Langella committed
251

252
if(UNIX)
Filippo Rusconi's avatar
Filippo Rusconi committed
253
  #This creates deb packages:
Olivier Langella's avatar
Olivier Langella committed
254

Filippo Rusconi's avatar
Filippo Rusconi committed
255
256
257
258
259
  add_custom_target(targz
    cpack -G TGZ --config CPackSourceConfig.cmake && tar xvfz ${CPACK_PACKAGE_NAME}-${XTPCPP_VERSION}.tar.gz && ln -s ${CPACK_PACKAGE_NAME}-${XTPCPP_VERSION}.tar.gz ${CPACK_PACKAGE_NAME}_${XTPCPP_VERSION}.orig.tar.gz
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
    COMMENT "Creating .tar.gz" VERBATIM
    )
Olivier Langella's avatar
Olivier Langella committed
260
261


Filippo Rusconi's avatar
Filippo Rusconi committed
262
263
264
265
266
267
  add_custom_target(deb
    cd ${CPACK_PACKAGE_NAME}-${XTPCPP_VERSION} && dpkg-buildpackage -B
    DEPENDS targz
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
    COMMENT "Creating Debian package" VERBATIM
    )
Olivier Langella's avatar
Olivier Langella committed
268

Filippo Rusconi's avatar
Filippo Rusconi committed
269
  file(GLOB changesdebs "${CMAKE_BINARY_DIR}/${CPACK_PACKAGE_NAME}_*.dsc")
Olivier Langella's avatar
Olivier Langella committed
270

Filippo Rusconi's avatar
Filippo Rusconi committed
271
272
273
  foreach(libfile ${changesdebs})
    SET(changesdeb "${libfile}")
  endforeach(libfile)
Olivier Langella's avatar
Olivier Langella committed
274

Filippo Rusconi's avatar
Filippo Rusconi committed
275
276
277
278
279
280
281
282
  message ("changes debian file : ${changesdeb}")
  #lintian -IEi --pedantic tandem-mass_2013.06.15-1_amd64.changes
  add_custom_target(lintian
    lintian -IEi --pedantic ${changesdeb}
    DEPENDS deb
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
    COMMENT "lintian check" VERBATIM
    )
Olivier Langella's avatar
Olivier Langella committed
283

284
endif()
Olivier Langella's avatar
Olivier Langella committed
285

286
287
288
set(ctest_update_type GIT)
set(update_command "GIT")
set(UPDATE_OPTIONS "")
Olivier Langella's avatar
Olivier Langella committed
289

290
291
292
293
294
#Enable_testing()
#include(CTest)
#if(BUILD_TESTING)
#  add_subdirectory(test)
#endif(BUILD_TESTING)
Olivier Langella's avatar
Olivier Langella committed
295

Olivier Langella's avatar
Olivier Langella committed
296
configure_file (${CMAKE_SOURCE_DIR}/templates/share/applications/xtpcpp.desktop.cmake ${CMAKE_BINARY_DIR}/templates/share/applications/xtpcpp.desktop)
Filippo Rusconi's avatar
Filippo Rusconi committed
297

298
configure_file (${CMAKE_SOURCE_DIR}/win64/xtpcpp-mingw64-win7+.iss.cmake ${CMAKE_SOURCE_DIR}/win64/xtpcpp-mingw64-win7+.iss)
Filippo Rusconi's avatar
Filippo Rusconi committed
299

300
configure_file (${CMAKE_SOURCE_DIR}/win64/xtpcpp-mxe.iss.cmake ${CMAKE_SOURCE_DIR}/win64/xtpcpp-mxe.iss)
301

302
install(FILES ${CMAKE_BINARY_DIR}/templates/share/applications/xtpcpp.desktop DESTINATION share/applications)
Langella Olivier's avatar
Langella Olivier committed
303

Filippo Rusconi's avatar
Filippo Rusconi committed
304
305
306
307
308
309
310
311
312
313
314
315
316

if(NOT APPLE)

  # We want to install the binary arch-dependent target in
  # specific situations. To have proper control, we define the arch
  # component.
  install(TARGETS ${TARGET}
    RUNTIME
    COMPONENT arch
    DESTINATION ${BIN_DIR})

endif()

Olivier Langella's avatar
Olivier Langella committed
317
configure_file(${CMAKE_SOURCE_DIR}/src/resources/xtandempipeline_icon.svg ${CMAKE_BINARY_DIR}/src/resources/xtpcpp.svg COPYONLY)
Filippo Rusconi's avatar
Filippo Rusconi committed
318

319
install(FILES ${CMAKE_BINARY_DIR}/src/resources/xtpcpp.svg DESTINATION share/icons/hicolor/scalable/apps)