File: CMakeLists.txt

package info (click to toggle)
gatb-core 1.4.2%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 18,340 kB
  • sloc: cpp: 49,096; sh: 2,218; xml: 1,333; makefile: 41; python: 32
file content (288 lines) | stat: -rw-r--r-- 12,499 bytes parent folder | download | duplicates (2)
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
project(gatb-core)

# We set the required version
cmake_minimum_required (VERSION 3.10.0)

################################################################################
# The version number.
################################################################################
# The default version number is the latest official build
SET (gatb-core_VERSION_MAJOR 1)
SET (gatb-core_VERSION_MINOR 4)
SET (gatb-core_VERSION_PATCH 2)

# But, it is possible to define another release number during a local build
IF (DEFINED MAJOR)
    SET (gatb-core_VERSION_MAJOR ${MAJOR})
ENDIF()
IF (DEFINED MINOR)
    SET (gatb-core_VERSION_MINOR ${MINOR})
ENDIF()
IF (DEFINED PATCH)
    SET (gatb-core_VERSION_PATCH ${PATCH})
ENDIF()

set (gatb-core-version ${gatb-core_VERSION_MAJOR}.${gatb-core_VERSION_MINOR}.${gatb-core_VERSION_PATCH})

# However, continuous integration has priority over local compilation
IF (DEFINED JENKINS_TAG)
    SET (gatb-core-version ${JENKINS_TAG})
ENDIF()

# User login to upload doc-api; Jenkins has priority over local user
IF (DEFINED JENKINS_GFORGE_USER)
    SET (gatb-doc-user-login ${JENKINS_GFORGE_USER})
ELSE()
    SET (gatb-doc-user-login $ENV{USER})
ENDIF()

set (gatb-core-date "xxxx-xx-xx")

################################################################################
# Define cmake modules directory
################################################################################
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

################################################################################
# Include external cmake files
################################################################################
include (DefineInteger)
include (CppUnit)

# We check whether we have native 128 bits integers
DefineInteger (k)

# We get the current date
string (TIMESTAMP gatb-core-date "%Y-%m-%d/%H:%M:%S")

################################################################################
# COMPILER DEFINITIONS
################################################################################
# We try to find the best compiler config, in particular for C++ extension usage
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

    IF(NOT CMAKE_CXX_COMPILER_VERSION) #for old cmakes
        include(CheckCompiler)
    ENDIF()
    if (CMAKE_CXX_COMPILER_VERSION  VERSION_LESS 4.7) 
        message(FATAL_ERROR "Insufficient gcc version (gcc>=4.7 needed)")
    endif()

elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

        if ("${CMAKE_CXX_COMPILER_VERSION}" STREQUAL "")
        # travis-cl has a clang that shows no version, so trying this http://stackoverflow.com/questions/16150888/cmake-branch-on-clang-version
            EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
            string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
            set(CMAKE_CXX_COMPILER_VERSION ${CLANG_VERSION_STRING})
        endif()

    IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)") # different clang versions number between linux and mac
        if (CMAKE_CXX_COMPILER_VERSION  VERSION_LESS 4.3)
            message(FATAL_ERROR "Insufficient clang version (clang>=4.5 needed)")
        endif()

    else()
        if (CMAKE_CXX_COMPILER_VERSION  VERSION_LESS 3.2) 
            message(FATAL_ERROR "Insufficient clang version (clang>=3.2 needed)")
        endif()

    endif()
else()
        message ("-------------------------------------------------------------------------------------")
        message ("-- WARNING !!! YOU USE AN UNKNOWN COMPILER...")
        message ("-------------------------------------------------------------------------------------")
endif()


################################################################################
# GENERAL DEFINITIONS
################################################################################
set (LIBRARY_COMPILE_DEFINITIONS "-std=c++11")
set (LIB_COMPILE_WARNINGS "-Wall -Wno-unused-function -Wno-unknown-pragmas") # last one is exclusively for BooPHF

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set (debug 1)
endif()

if (debug)
    #set (LIBRARY_COMPILE_DEFINITIONS  "${LIBRARY_COMPILE_DEFINITIONS} -g -p -pg")
    set (LIBRARY_COMPILE_DEFINITIONS  "${LIBRARY_COMPILE_DEFINITIONS} -g -p ${LIB_COMPILE_WARNINGS}")
    set (CMAKE_BUILD_TYPE Debug) # else CMake adds DNDEBUG
    message("-- COMPILATION IN DEBUG MODE")
endif()

if (INT128_FOUND)
     set (LIBRARY_COMPILE_DEFINITIONS  "${LIBRARY_COMPILE_DEFINITIONS}  -DINT128_FOUND")
endif()

if (NONCANONICAL)
    MESSAGE("--- Compiling with non-canonical (direct strand only) k-mer counting")
    set (LIBRARY_COMPILE_DEFINITIONS  "${LIBRARY_COMPILE_DEFINITIONS}  -DNONCANONICAL=1")
endif()

set(SSE2_FOUND false CACHE BOOL "SSE2 not available")
set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 not available")

# WARNING !!! For the moment, we need to remove some warnings (on Macos) due to use of offsetof macro on non Plain Old Data
set (LIBRARY_COMPILE_DEFINITIONS "${LIBRARY_COMPILE_DEFINITIONS} -Wno-invalid-offsetof") 

# We may have some custom compilation flags.
if (use_allocator)
    set (LIBRARY_COMPILE_DEFINITIONS "${LIBRARY_COMPILE_DEFINITIONS} -DGATB_USE_CUSTOM_ALLOCATOR") 
endif()

message("-- Options: ${LIBRARY_COMPILE_DEFINITIONS}")

################################################################################
#  DIRECTORIES MANAGEMENT 
################################################################################

set (LIBRARY_OUTPUT_PATH       ${PROJECT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})
set (EXECUTABLE_OUTPUT_PATH    ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE})

################################################################################
#  EXPORT FOR THIRD PARTIES 
################################################################################

# In case you need to use external libraries, you can use the following variables:
#   EXTRALIBS      : names of the libraries to be used
#   EXTRALIBS_PATH : directory where the libraries are
#   EXTRALIBS_INC  : directory of the include files for the libraries 
# For instance, you can do the following:
#       cmake -DEXTRALIBS="somelib"  -DEXTRALIBS_PATH="/somewhere/libs"  -DEXTRALIBS_INC="/somewhere/inc" ..

IF (DEFINED EXTRALIBS)
    set (gatb-core-extra-libraries ${EXTRALIBS})
    set (gatb-core-extra-libraries ${gatb-core-extra-libraries} PARENT_SCOPE)
ENDIF()
IF (DEFINED EXTRALIBS_PATH)
    set (gatb-core-extra-libraries-path ${EXTRALIBS_PATH})
    set (gatb-core-extra-libraries-path ${gatb-core-extra-libraries-path} PARENT_SCOPE)
ENDIF()
IF (DEFINED EXTRALIBS_INC)
    set (gatb-core-extra-libraries-inc ${EXTRALIBS_INC})
    set (gatb-core-extra-libraries-inc ${gatb-core-extra-libraries-inc} PARENT_SCOPE)
ENDIF()

# We define the compilation flags used for compiling binary based on gatb core
set (gatb-core-flags ${LIBRARY_COMPILE_DEFINITIONS})

# We define the include directories used for linking binary based on gatb core
# Note that we need to add boost include dependency (not working otherwise with clang)
set (gatb-core-includes ${PROJECT_BINARY_DIR}/include  ${PROJECT_BINARY_DIR}/include/${CMAKE_BUILD_TYPE} ${PROJECT_SOURCE_DIR}/src  ${PROJECT_SOURCE_DIR}/thirdparty ${gatb-core-extra-libraries-inc})

# We define the libraries used for linking binary based on gatb core
set (gatb-core-libraries   gatbcore-static  dl  pthread  z ${gatb-core-extra-libraries})

# We define the directory where to find cmake helpers
set (gatb-core-cmake  ${CMAKE_MODULE_PATH})

################################################################################
#  DEPENDENCIES 
################################################################################
# we must be sure that hdf5 is built and installed before building gatb-core
find_package(HDF5 REQUIRED)
include_directories(${HDF5_INCLUDE_DIRS})
# Not sure what exact programs will need these libraries
#  see https://lists.debian.org/debian-mentors/2017/11/msg00227.html
# target_link_libraries(name_of_program_or_library ${HDF5_LIBRARIES})
set (gatb-core-libraries  ${gatb-core-libraries} ${HDF5_LIBRARIES})
MESSAGE(STATUS HDF5_LIBRARIES="${HDF5_LIBRARIES}")

################################################################################
#  LIBRARY GENERATION 
################################################################################
ADD_SUBDIRECTORY(src)

# NOTE... we have to duplicate the variables for the other scopes (in particular for sub directories)
set (gatb-core-klist   ${gatb-core-klist}  PARENT_SCOPE)

################################################################################
#  UNIT TESTS GENERATION 
################################################################################
IF (DEFINED CPPUNIT_FOUND)
    IF (EXISTS "${PROJECT_SOURCE_DIR}/test")
        IF (NOT DEFINED GATB_CORE_EXCLUDE_TESTS)
            ADD_SUBDIRECTORY (test)
        ENDIF()
    ENDIF()
ENDIF()

################################################################################
#  TOOLS GENERATION 
################################################################################
IF (NOT DEFINED GATB_CORE_EXCLUDE_TOOLS)
    ADD_SUBDIRECTORY(tools)
ENDIF()

################################################################################
#  THIRD PARTY GENERATION (
################################################################################
ADD_SUBDIRECTORY(thirdparty)

# NOTE... we have to duplicate the variables for the other scopes (in particular for sub directories)
set (gatb-core-flags          ${gatb-core-flags}          PARENT_SCOPE)
set (gatb-core-includes       ${gatb-core-includes}       PARENT_SCOPE)
set (gatb-core-libraries      ${gatb-core-libraries}      PARENT_SCOPE)
set (gatb-core-cmake          ${gatb-core-cmake}          PARENT_SCOPE)

################################################################################
#  DOCUMENTATION GENERATION 
################################################################################
IF (EXISTS "${PROJECT_SOURCE_DIR}/doc")
    ADD_SUBDIRECTORY(doc EXCLUDE_FROM_ALL)
ENDIF()

################################################################################
#  EXAMPLES GENERATION 
################################################################################
IF (EXISTS "${PROJECT_SOURCE_DIR}/examples")
    IF (GATB_CORE_INCLUDE_EXAMPLES)
        ADD_SUBDIRECTORY(examples)
    ENDIF()
ENDIF()

IF (NOT DEFINED GATB_CORE_EXCLUDE_EXAMPLES)
    # add example snippets into binary archive (use by CPack directive)
    INSTALL(DIRECTORY "${PROJECT_SOURCE_DIR}/examples/" DESTINATION "share/doc/gatb-core/examples")
ENDIF()

################################################################################
#  INSTALL 
################################################################################

IF (NOT DEFINED GATB_CORE_INSTALL_EXCLUDE)
    INSTALL (FILES ${PROJECT_SOURCE_DIR}/doc/misc/README.txt   DESTINATION . OPTIONAL)
## does not work :-( ##    INSTALL (FILES ${PROJECT_SOURCE_DIR}/doc/misc/README.txt  "share/doc/gatb-core" . OPTIONAL)
#    INSTALL (FILES ${PROJECT_SOURCE_DIR}/LICENCE              DESTINATION . OPTIONAL)
#    INSTALL (FILES ${PROJECT_SOURCE_DIR}/THIRDPARTIES.md      DESTINATION . OPTIONAL)
#    INSTALL (DIRECTORY ${PROJECT_SOURCE_DIR}/thirdparty/boost DESTINATION ./include)
ENDIF()

################################################################################
#  DELIVERY 
################################################################################
SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY  "gatb-core project")
SET (CPACK_PACKAGE_VENDOR               "Genscale team (INRIA)")
SET (CPACK_PACKAGE_VERSION_MAJOR        "${gatb-core_VERSION_MAJOR}")
SET (CPACK_PACKAGE_VERSION_MINOR        "${gatb-core_VERSION_MINOR}")
SET (CPACK_PACKAGE_VERSION_PATCH        "${gatb-core_VERSION_PATCH}")
SET (CPACK_PACKAGE_VERSION              "${gatb-core-version}")  
SET (CPACK_PACKAGE_FILE_NAME            "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-bin-${CMAKE_SYSTEM_NAME}")
SET (CPACK_GENERATOR                    "TGZ")
SET (CPACK_SOURCE_GENERATOR             "TGZ")
SET (CPACK_SOURCE_IGNORE_FILES          
    "^${PROJECT_SOURCE_DIR}/build/"  
    "^${PROJECT_SOURCE_DIR}/.project"
    "^${PROJECT_SOURCE_DIR}/.gitignore"
    "^${PROJECT_SOURCE_DIR}/doc/design"
    "^${PROJECT_SOURCE_DIR}/DELIVERY.md"
)



IF (NOT DEFINED GATB_CORE_INSTALL_EXCLUDE)
    # We include the module and get all the delivery targets
    include (Delivery)
ENDIF ()