~ubuntu-branches/ubuntu/wily/openms/wily

« back to all changes in this revision

Viewing changes to .pc/rpath-force-shared-libs-set-soname.patch/CMakeLists.txt

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2012-11-12 15:58:12 UTC
  • Revision ID: package-import@ubuntu.com-20121112155812-e6mvctvil4ko9npv
Tags: 1.9.0-1
1.9.0 First Debian package release (Closes: #691129).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# CMake installation file
 
2
# Created 2008/10 during OpenMS retreat by CB && AB
 
3
 
 
4
PROJECT("OpenMS")
 
5
 
 
6
########################################################
 
7
### entries meant to be configured using CMake cache ###
 
8
### - do NOT hardcode them here!                     ###
 
9
### - edit them within CMakeCache.txt using ccmake       ###
 
10
########################################################
 
11
# CMAKE_FIND_ROOT_PATH
 
12
# CMAKE_BUILD_TYPE
 
13
# STL_DEBUG
 
14
# DB_TEST
 
15
# QT_DB_PLUGIN
 
16
# MT_CUDA_BUILD_TYPE
 
17
 
 
18
########################################################
 
19
###    manual entries (edit this for new release)    ###
 
20
########################################################
 
21
 
 
22
set(OPENMS_PACKAGE_VERSION_MAJOR "1")
 
23
set(OPENMS_PACKAGE_VERSION_MINOR "9")
 
24
set(OPENMS_PACKAGE_VERSION_PATCH "0")
 
25
 
 
26
########################################################
 
27
###            end manual entries                    ###
 
28
########################################################
 
29
 
 
30
## Heart of the BUILD system : only edit when you know what you're doing (we don't)
 
31
## quick manual for most commands: http://www.cmake.org/cmake/help
 
32
## useful predefined variables: http://www.paraview.org/Wiki/CMake_Useful_Variables
 
33
##
 
34
## naming conventions:
 
35
##
 
36
## prefix a variable with 'CF_' if it is used to configure a file!
 
37
## e.g., CF_LibOpenMSExport
 
38
 
 
39
 
 
40
cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR)
 
41
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
 
42
set(CF_OPENMS_PACKAGE_VERSION "${OPENMS_PACKAGE_VERSION_MAJOR}.${OPENMS_PACKAGE_VERSION_MINOR}.${OPENMS_PACKAGE_VERSION_PATCH}" CACHE INTERNAL "OpenMS VERSION" FORCE)
 
43
 
 
44
## SOME MAC OS X STUFF
 
45
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 
46
  # force cmake > 2.8.1 to avoid bugs with OSX_DEPLOYMENT_TARGET
 
47
  cmake_minimum_required(VERSION 2.8.1 FATAL_ERROR)
 
48
        # due to some awkward updates of cmake in the 2.8.x series we need to add the following
 
49
  find_library(CARBON NAMES Carbon)
 
50
  find_package(OpenGL)
 
51
  set(APPLE_EXTRA_LIBS ${CARBON} ${OPENGL_LIBRARY})
 
52
endif()
 
53
 
 
54
 
 
55
## sanity check: sometimes CMAKE_SIZEOF_VOID_P just vanishes (when updating CMake).
 
56
if (NOT CMAKE_SIZEOF_VOID_P)
 
57
        message(FATAL_ERROR "'CMAKE_SIZEOF_VOID_P' is undefined. Thus you should delete CMakeFiles (the directory) and the CMakeCache.txt and rerun CMake again! This is some weird CMake bug that seems to appear when updating the CMake version.")
 
58
endif()
 
59
 
 
60
if (CMAKE_SIZEOF_VOID_P MATCHES "8")
 
61
        set(OPENMS_64BIT_ARCHITECTURE 1 CACHE INTERNAL "Architecture-bits")
 
62
        message(STATUS "Architecture: 64 bit")
 
63
else()
 
64
        set(OPENMS_64BIT_ARCHITECTURE 0 CACHE INTERNAL "Architecture-bits")
 
65
        message(STATUS "Architecture: 32 bit")
 
66
endif()
 
67
 
 
68
# some of our own macros (OPENMS_CHECKLIB, QT4_WRAP_UI_OWN, ...)
 
69
include (cmake/OpenMSBuildSystem_macros.cmake)
 
70
 
 
71
 
 
72
## Set default build type (if not set by user on command line)
 
73
if (NOT CMAKE_BUILD_TYPE)
 
74
        set(CMAKE_BUILD_TYPE Release)
 
75
endif()
 
76
## force build type into the cache (needs to be set beforehand)
 
77
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
 
78
 
 
79
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
 
80
        set(CF_OPENMS_ASSERTIONS 1)
 
81
else()
 
82
        set(CF_OPENMS_ASSERTIONS 0)
 
83
endif()
 
84
set(CF_OPENMS_ASSERTIONS ${CF_OPENMS_ASSERTIONS} CACHE INTERNAL "Enables debug messages (precondition and postconditions are enabled, a bit slower) - this is NOT changing any compiler flags!" FORCE)
 
85
 
 
86
 
 
87
########################################################
 
88
###    compiler flags                                                                                                                            ###
 
89
########################################################
 
90
 
 
91
## Fill this with compile flags that external projects should use as well
 
92
## for OpenMS internal flags (not promoted to external compiler flags) append to CMAKE_CXX_FLAGS
 
93
set(CF_OPENMS_ADDCXX_FLAGS) ## see OpenMS/cmake/OpenMSConfig.cmake.in to see how its configured and used (i.e. as OPENMS_ADDCXX_FLAGS)
 
94
 
 
95
if (CMAKE_COMPILER_IS_GNUCXX)
 
96
 
 
97
        # determine gcc version
 
98
        execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GNUCXX_VERSION)
 
99
        string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GNUCXX_VERSION})
 
100
        list(GET GCC_VERSION_COMPONENTS 0 GNUCXX_MAJOR_VERSION)
 
101
        list(GET GCC_VERSION_COMPONENTS 1 GNUCXX_MINOR_VERSION)
 
102
 
 
103
  add_definitions(-Wall -Wextra -Wno-non-virtual-dtor -Wno-long-long -Wno-variadic-macros)
 
104
  if (NOT MT_ENABLE_CUDA)  # necessary since CUDA contains non-pedantic code
 
105
                add_definitions(--pedantic)
 
106
        endif()
 
107
 
 
108
        ## Recommended setting for eclipse, see http://www.cmake.org/Wiki/CMake:Eclipse
 
109
        if (CMAKE_GENERATOR STREQUAL "Eclipse CDT4 - Unix Makefiles")
 
110
                add_definitions(-fmessage-length=0)
 
111
        endif()
 
112
 
 
113
        if (NOT OPENMS_64BIT_ARCHITECTURE AND ${GNUCXX_MAJOR_VERSION} MATCHES "4" AND ${GNUCXX_MINOR_VERSION} MATCHES "3")
 
114
                add_definitions(-march=i486)
 
115
        endif()
 
116
 
 
117
elseif (MSVC)
 
118
        ## do not use add_definitions
 
119
        ## add definitions also lands in stuff like RC_DEFINITION which tend to fail if you use
 
120
        ## Eclipse CDT 4 - NMAKE generator
 
121
        ## use set(CF_OPENMS_ADDCXX_FLAGS "${CF_OPENMS_ADDCXX_FLAGS} ...") instead
 
122
 
 
123
        ## disable dll-interface warning
 
124
        set(CF_OPENMS_ADDCXX_FLAGS "${CF_OPENMS_ADDCXX_FLAGS} /wd4251 /wd4275")
 
125
 
 
126
        ## disable deprecated functions warning (e.g. for POSIX functions)
 
127
        set(CF_OPENMS_ADDCXX_FLAGS "${CF_OPENMS_ADDCXX_FLAGS} /wd4996")
 
128
 
 
129
        ## disable explicit template instantiation request for partially defined classes
 
130
        set(CF_OPENMS_ADDCXX_FLAGS "${CF_OPENMS_ADDCXX_FLAGS} /wd4661")
 
131
 
 
132
        ## disable warning: "decorated name length exceeded, name was truncated"
 
133
        set(CF_OPENMS_ADDCXX_FLAGS "${CF_OPENMS_ADDCXX_FLAGS} /wd4503")
 
134
        
 
135
        ## don't warn about unchecked std::copy()
 
136
        add_definitions(/D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE)
 
137
 
 
138
        ## xerces bug workaround
 
139
        add_definitions(/DOPENMS_XERCESDLL)
 
140
 
 
141
        ## FeatureFinder.obj is huge and won't compile in VS2008 debug otherwise:
 
142
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
 
143
 
 
144
        ## use multiple Cores (if available)
 
145
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
 
146
 
 
147
  if (NOT OPENMS_64BIT_ARCHITECTURE)
 
148
    ## enable SSE1 on 32bit, on 64bit the compiler flag does not exist
 
149
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE")
 
150
  endif()
 
151
elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
 
152
  set(CMAKE_COMPILER_IS_CLANG true CACHE INTERNAL "Is CLang compiler (clang++)")
 
153
else()
 
154
        set(CMAKE_COMPILER_IS_INTELCXX true CACHE INTERNAL "Is Intel C++ compiler (icpc)")
 
155
endif()
 
156
 
 
157
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CF_OPENMS_ADDCXX_FLAGS}")
 
158
 
 
159
## platform dependent compiler flags:
 
160
include(CheckCXXCompilerFlag)
 
161
if (NOT WIN32) # we only want fPIC on non-windows systems (fPIC is implicitly true there)
 
162
        CHECK_CXX_COMPILER_FLAG("-fPIC" WITH_FPIC)
 
163
        if (WITH_FPIC)
 
164
                add_definitions(-fPIC)
 
165
        endif()
 
166
endif()
 
167
 
 
168
## -Wconversion flag for GCC
 
169
set(CXX_WARN_CONVERSION OFF CACHE BOOL "Enables warnings for type conversion problems (GCC only)")
 
170
if (CXX_WARN_CONVERSION)
 
171
        if (CMAKE_COMPILER_IS_GNUCXX)
 
172
                add_definitions(-Wconversion)
 
173
        endif()
 
174
endif()
 
175
Message(STATUS "Compiler checks for conversion: ${CXX_WARN_CONVERSION}")
 
176
 
 
177
## STL-DEBUG (only for GCC and in debug mode)
 
178
set(STL_DEBUG OFF CACHE BOOL "[GCC only] Enable STL-DEBUG mode (very slow).")
 
179
if (STL_DEBUG)
 
180
  if (CMAKE_COMPILER_IS_GNUCXX)
 
181
                if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
 
182
                        # add compiler flag
 
183
        add_definitions(/D_GLIBCXX_DEBUG)
 
184
        Message(STATUS "STL debug mode: ${STL_DEBUG}")
 
185
          else()
 
186
            Message(WARNING "STL debug mode is supported for OpenMS debug mode only")
 
187
          endif()
 
188
  else()
 
189
    Message(WARNING "STL debug mode is supported for compiler GCC only")
 
190
  endif()
 
191
else()
 
192
        Message(STATUS "[GCC only] STL debug mode: ${STL_DEBUG}")
 
193
endif()
 
194
 
 
195
 
 
196
#########################################################
 
197
#                                                        Useful third party libs (optional)       #
 
198
#########################################################
 
199
 
 
200
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
 
201
 
 
202
## CUDA checking
 
203
set(MT_ENABLE_CUDA OFF CACHE BOOL "Should CUDA support be enabled (version <= 2.1 currently supported).")
 
204
set(MT_CUDA_BUILD_TYPE Device CACHE STRING "Switch between Device and Emulation mode.")
 
205
if (MT_ENABLE_CUDA)
 
206
        MESSAGE(STATUS "NVIDIA CUDA: ${MT_CUDA_BUILD_TYPE} mode")
 
207
        find_package(Cuda)
 
208
else()
 
209
  MESSAGE(STATUS "NVIDIA CUDA: ${MT_ENABLE_CUDA}")
 
210
endif()
 
211
 
 
212
if (FOUND_CUDART AND MT_ENABLE_CUDA) #CUDART and not CUDA!!!
 
213
        add_definitions(/DOPENMS_HAS_CUDA)
 
214
        MESSAGE (STATUS "Found CUDA header files in: ${FOUND_CUDA_NVCC_INCLUDE}") #Not CUDA_INCLUDE_DIR
 
215
        MESSAGE (STATUS "Found CUDA library at: ${FOUND_CUDART}")
 
216
        INCLUDE_DIRECTORIES(${FOUND_CUDA_NVCC_INCLUDE})
 
217
  set (CUDA_NVCC_INCLUDE_ARGS ${CUDA_NVCC_INCLUDE_ARGS} -I ${PROJECT_BINARY_DIR}/include/)
 
218
endif()
 
219
 
 
220
## TBB
 
221
set(MT_ENABLE_TBB OFF CACHE BOOL "Should Intel Threading Building Blocks support be enabled.")
 
222
set(MT_TBB_INCLUDE_DIR CACHE PATH "Intel Threading Building Blocks 'include' directory.")
 
223
set(MT_TBB_LIBRARY_DIR CACHE PATH "Intel Threading Building Blocks libraries directory.")
 
224
MESSAGE(STATUS "Intel TBB: ${MT_ENABLE_TBB}")
 
225
if (MT_ENABLE_TBB)
 
226
        find_package(TBB)
 
227
endif()
 
228
 
 
229
if (TBB_FOUND)
 
230
        INCLUDE_DIRECTORIES(${MT_TBB_INCLUDE_DIR})
 
231
        add_definitions(/DOPENMS_HAS_TBB)
 
232
endif()
 
233
 
 
234
## OpenMP
 
235
set(MT_ENABLE_OPENMP ON CACHE BOOL "Should OpenMP support be enabled")
 
236
if (MT_ENABLE_OPENMP)
 
237
        find_package(OpenMP)
 
238
endif()
 
239
MESSAGE(STATUS "OPENMP: ${MT_ENABLE_OPENMP}")
 
240
 
 
241
if (OPENMP_FOUND)
 
242
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") ## do NOT use add_definitions() here, because RC.exe on windows will fail
 
243
        if (NOT MSVC)
 
244
                set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
 
245
        endif()
 
246
endif()
 
247
 
 
248
########################################################
 
249
###    external libs (contrib or system)                                                 ###
 
250
########################################################
 
251
 
 
252
include(cmake/OpenMSBuildSystem_externalLibs.cmake)
 
253
 
 
254
 
 
255
########################################################
 
256
###    useful programms                                                                                                                  ###
 
257
########################################################
 
258
 
 
259
find_program(SVNVERSION_EXECUTABLE
 
260
             svnversion
 
261
             PATHS "c:/programme/subversion/bin" "c:/program files/subversion/bin"   ### additional search paths (along with $PATH)
 
262
             DOC "svnversion executable which helps in determining the svn revision when building TOPP tools")
 
263
 
 
264
if ("${SVNVERSION_EXECUTABLE}" STREQUAL "SVNVERSION_EXECUTABLE-NOTFOUND")
 
265
        message(STATUS "Info: The programm svnversion could not be found. SVN-revision information will not be available! Add the location of svnversion(.exe) to your PATH environment variable if you require SVN-revision.")
 
266
        set(OPENMS_HAS_SVNVERSION OFF CACHE INTERNAL "SVNVersion(.exe) present?")
 
267
else()
 
268
        set(OPENMS_HAS_SVNVERSION ON CACHE INTERNAL "SVNVersion(.exe) present?")
 
269
endif()
 
270
 
 
271
set(SVN_REVISION_FILE "${PROJECT_BINARY_DIR}/include/OpenMS/openms_svn_revision.h")
 
272
 
 
273
 
 
274
 
 
275
########################################################
 
276
###    configure config.h                                                                                                                ###
 
277
########################################################
 
278
 
 
279
## this need to be set before config.h is configured!
 
280
set(CMAKE_INSTALL_PREFIX "" CACHE INTERNAL "This must be equal to INSTALL_PREFIX!" FORCE)
 
281
set(INSTALL_PREFIX "." CACHE PATH "Installation prefix for OpenMS and TOPP")
 
282
## are we building a shared or static lib?! (BOTH within the same BUILD-tree is NOT possible with OpenMS!!)
 
283
set(BUILD_SHARED_LIBS true)
 
284
 
 
285
include(cmake/OpenMSBuildSystem_configh.cmake)
 
286
 
 
287
## add configured files (used in 'cmake/includes.cmake')
 
288
set (OPENMS_CONFIGURED_FILES ${SVN_REVISION_FILE} ${CONFIGURED_CONFIG_H} ${CONFIGURED_OPENMS_PACKAGE_VERSION_H})
 
289
 
 
290
## Configures what is tested (DB-test, MS2-search engines)
 
291
include(cmake/OpenMSBuildSystem_testConfig.cmake)
 
292
 
 
293
 
 
294
# At this point make a summary:
 
295
 
 
296
message(STATUS "Info: CF_OPENMS_DATA_PATH: ${CF_OPENMS_DATA_PATH}")
 
297
message(STATUS "Info: CF_OPENMS_DOC_PATH: ${CF_OPENMS_DOC_PATH}")
 
298
 
 
299
 
 
300
########################################################
 
301
###    Documentation                                 ###
 
302
########################################################
 
303
 
 
304
include(cmake/OpenMSBuildSystem_doc.cmake)
 
305
 
 
306
 
 
307
 
 
308
########################################################
 
309
###    BUILD the lib                                 ###
 
310
########################################################
 
311
 
 
312
#package type
 
313
set(VALID_PACKAGE_TYPES "none" "rpm" "deb" "dmg")
 
314
set(PACKAGE_TYPE "none" CACHE STRING "Package type (internal): ${VALID_PACKAGE_TYPES}")
 
315
# check build type
 
316
list(FIND VALID_PACKAGE_TYPES ${PACKAGE_TYPE} list_pos)
 
317
if( ${list_pos} EQUAL -1 )
 
318
        message(STATUS "The PACKAGE_TYPE ${PACKAGE_TYPE} is invalid")
 
319
        message(STATUS "Valid PACKAGE_TYPEs are:")
 
320
        foreach( BT ${VALID_PACKAGE_TYPES} )
 
321
                message(STATUS " * ${BT}")
 
322
        endforeach()
 
323
        message(FATAL_ERROR "Aborting ...")
 
324
endif()
 
325
 
 
326
 
 
327
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
 
328
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
 
329
set(OPENMS_BINARY_DIR "${PROJECT_BINARY_DIR}/bin")
 
330
set(OPENMS_WIN32_DLL_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
331
 
 
332
## big include file for headers and C files, which fills the OpenMS_sources variable
 
333
include (cmake/includes.cmake)
 
334
 
 
335
if (MSVC)
 
336
        ## use OpenMSd.dll in debug mode
 
337
        SET(CMAKE_DEBUG_POSTFIX d)
 
338
endif()
 
339
 
 
340
## add library target
 
341
## warning: set BUILD_SHARED_LIBS to decide if library is shared or static (see above)! We need the BUILD_SHARED_LIBS flag to set declspec flags for MSVC!
 
342
if (FOUND_CUDART AND MT_ENABLE_CUDA) # we need both conditions due to possible present cached entries
 
343
        CUDA_ADD_LIBRARY(OpenMS ${OpenMS_sources} ${Cuda_sources})
 
344
else()
 
345
        ADD_LIBRARY(OpenMS ${OpenMS_sources})
 
346
endif()
 
347
 
 
348
### OpenMS_GUI lib
 
349
ADD_LIBRARY(OpenMS_GUI ${OpenMSVisual_sources})
 
350
if (MSVC)
 
351
        set (GUI_lnk_flags "/FORCE:MULTIPLE /INCREMENTAL:NO /ignore:4006 /ignore:4088")
 
352
        set_target_properties(OpenMS_GUI PROPERTIES LINK_FLAGS ${GUI_lnk_flags}) ## allow multiple definitions of symbols (e.g. from template instanciations or STL-derived classes)
 
353
endif() 
 
354
 
 
355
## update the openms_svn_revision.h file before compiling OpenMS
 
356
add_custom_target(svn_revision_update ALL
 
357
            COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DSVN_REVISION_FILE=${SVN_REVISION_FILE} -DOPENMS_HAS_SVNVERSION=${OPENMS_HAS_SVNVERSION} -DSVNVERSION_EXECUTABLE=${SVNVERSION_EXECUTABLE}
 
358
                                     -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/svnversion.cmake)
 
359
add_dependencies(OpenMS svn_revision_update)
 
360
set_source_files_properties(${SVN_REVISION_FILE} PROPERTIES GENERATED TRUE HEADER_FILE_ONLY TRUE)
 
361
 
 
362
## all the dependency libraries are linked into libOpenMS.so, except Qt and CUDA which are still dynamic
 
363
set(OPENMS_DEP_LIBRARIES ${CONTRIB_CBC} ${CONTRIB_GSL} ${CONTRIB_GSLCBLAS} ${DEP_LIBSVM_LIBRARY} ${CONTRIB_XERCESC} ${Boost_LIBRARIES} ${CONTRIB_BZIP2} ${CONTRIB_ZLIB} ${CONTRIB_GLPK})
 
364
if (TBB_FOUND)
 
365
        list(APPEND OPENMS_DEP_LIBRARIES ${TBB_LIBRARIES})
 
366
endif()
 
367
if (MSVC)
 
368
        list(APPEND OPENMS_DEP_LIBRARIES opengl32.lib)
 
369
endif()
 
370
 
 
371
target_link_libraries(OpenMS ${APPLE_EXTRA_LIBS} ${QT_LIBRARIES} ${OPENMS_DEP_LIBRARIES})
 
372
target_link_libraries(OpenMS_GUI OpenMS ${QT_LIBRARIES})
 
373
 
 
374
## OPENMS_LIBRARIES defines the libraries used by OpenMS; this should be used to link against executables
 
375
## somehow the link dependencies of cmake are broken such that when using POSTFIX names for libs the dependencies are not forwarded...
 
376
## we fix this by adding the dependencies of OpenMS directly to the executables as well.
 
377
set(OPENMS_LIBRARIES optimized OpenMS${CMAKE_RELEASE_POSTFIX} debug OpenMS${CMAKE_DEBUG_POSTFIX} ${QT_LIBRARIES})
 
378
if (MSVC) ## Windows
 
379
        list(APPEND OPENMS_LIBRARIES ${OPENMS_DEP_LIBRARIES})
 
380
endif()
 
381
 
 
382
## link libraries for GUI Tools
 
383
set(OPENMS_GUI_LIBRARIES optimized OpenMS_GUI${CMAKE_RELEASE_POSTFIX} debug OpenMS_GUI${CMAKE_DEBUG_POSTFIX} OpenMS ${QT_LIBRARIES})
 
384
 
 
385
## directory for OpenMS(d).lib (required for linking executables)
 
386
if (MSVC)
 
387
        link_directories(${PROJECT_BINARY_DIR})
 
388
endif()
 
389
 
 
390
####### TOPP #########
 
391
set(TOPP_DIR source/APPLICATIONS/TOPP)
 
392
include(${TOPP_DIR}/executables.cmake)
 
393
foreach(i ${TOPP_executables})
 
394
        add_executable(${i} ${TOPP_DIR}/${i}.C)
 
395
        target_link_libraries(${i} ${OPENMS_LIBRARIES})
 
396
        if (OPENMP_FOUND AND NOT MSVC)
 
397
                set_target_properties(${i} PROPERTIES LINK_FLAGS ${OpenMP_CXX_FLAGS})
 
398
        endif()
 
399
endforeach(i)
 
400
add_custom_target(TOPP)
 
401
add_dependencies(TOPP ${TOPP_executables})
 
402
 
 
403
##### UTILS ########
 
404
set(UTILS_DIR source/APPLICATIONS/UTILS)
 
405
set(UTILS_executables)
 
406
include(${UTILS_DIR}/executables.cmake)
 
407
foreach(i ${UTILS_executables})
 
408
        add_executable(${i} ${UTILS_DIR}/${i}.C)
 
409
        target_link_libraries(${i} ${OPENMS_LIBRARIES})
 
410
endforeach(i)
 
411
add_custom_target(UTILS)
 
412
add_dependencies(UTILS ${UTILS_executables})
 
413
 
 
414
##### GUI tools ########
 
415
set(GUI_DIR source/VISUAL/APPLICATIONS/GUITOOLS)
 
416
include(${GUI_DIR}/executables.cmake)
 
417
foreach(i ${GUI_executables})
 
418
        set(resource_file ${CMAKE_SOURCE_DIR}/${GUI_DIR}/${i}.rc)
 
419
        set(resource_dir ${CMAKE_SOURCE_DIR}/${GUI_DIR}/${i}-resources/)
 
420
        ## add icons to TOPPView and INIFileEditor
 
421
        if (MSVC AND EXISTS ${resource_file})
 
422
                Message(STATUS "Setting resource file ${resource_file} for ${i}")
 
423
                add_executable(${i} ${GUI_DIR}/${i}.C ${resource_file})
 
424
        elseif(APPLE AND EXISTS ${resource_dir})
 
425
                add_executable(${i} ${GUI_DIR}/${i}.C)
 
426
                # extra work for pseudo-mac-bundle
 
427
                # move prepared package to RUNTIME_OUTPUT
 
428
                file(COPY "${PROJECT_SOURCE_DIR}/cmake/MacOSX/${i}-resources/${i}.app"
 
429
                DESTINATION "${PROJECT_BINARY_DIR}/bin"
 
430
                PATTERN ".svn" EXCLUDE
 
431
                PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
 
432
        else()
 
433
                add_executable(${i} ${GUI_DIR}/${i}.C)
 
434
        endif()
 
435
 
 
436
        ## append visual lib as dependency for GUI tools
 
437
        target_link_libraries(${i} ${OPENMS_GUI_LIBRARIES})
 
438
        if (OPENMP_FOUND AND NOT MSVC)
 
439
                set_target_properties(${i} PROPERTIES LINK_FLAGS ${OpenMP_CXX_FLAGS})
 
440
        endif()
 
441
endforeach(i)
 
442
add_custom_target(GUI)
 
443
add_dependencies(GUI ${GUI_executables})
 
444
 
 
445
## some regular TOPP/UTILS need the GUI lib
 
446
set(executables_withGUIlibDep ${TOPP_executables_with_GUIlib} ${UTILS_executables_with_GUIlib})
 
447
foreach(i ${executables_withGUIlibDep}) 
 
448
        target_link_libraries(${i} ${OPENMS_GUI_LIBRARIES})
 
449
endforeach(i)
 
450
 
 
451
        
 
452
##### Doc progs ####
 
453
set(OpenMS_doc_executables)
 
454
include(doc/doxygen/parameters/executables.cmake)
 
455
foreach(i ${OpenMS_doc_executables})
 
456
        set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "doc/doxygen/parameters")
 
457
        add_executable(${i} EXCLUDE_FROM_ALL doc/doxygen/parameters/${i}.C)
 
458
        target_link_libraries(${i} ${OPENMS_GUI_LIBRARIES})
 
459
        set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
 
460
endforeach(i)
 
461
add_custom_target(doc_progs)
 
462
add_dependencies(doc_progs ${OpenMS_doc_executables} TOPP UTILS GUI)
 
463
 
 
464
##### Examples #####
 
465
if ("${PACKAGE_TYPE}" STREQUAL "none")
 
466
        set(EXAMPLES_executables)
 
467
        set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
 
468
        include(source/EXAMPLES/executables.cmake)
 
469
        foreach(i ${EXAMPLES_executables})
 
470
          add_executable(${i} source/EXAMPLES/${i}.C)
 
471
          target_link_libraries(${i} ${OPENMS_GUI_LIBRARIES})
 
472
        endforeach(i)
 
473
        add_custom_target(Tutorials_build)
 
474
        add_dependencies(Tutorials_build ${EXAMPLES_executables})
 
475
 
 
476
        if (MSVC_IDE)
 
477
                set(EXAMPLES_EXE_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir))
 
478
        else()
 
479
                set(EXAMPLES_EXE_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
480
        endif()
 
481
 
 
482
 
 
483
        ## Create single target for each example, add it as a dependency to the main target
 
484
        foreach(i ${EXAMPLES_executables})
 
485
                list(APPEND EX_LIST COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}/source/EXAMPLES ${EXAMPLES_EXE_DIR}/${i})
 
486
        endforeach(i)
 
487
        list(APPEND EX_LIST "echo all done")
 
488
        add_custom_target(Tutorials_exec
 
489
                COMMENT "Executes the examples"
 
490
        )
 
491
        separate_arguments(EX_LIST)
 
492
        add_custom_command(TARGET Tutorials_exec
 
493
                    POST_BUILD
 
494
                                                                                ${EX_LIST}
 
495
                                                                                )
 
496
 
 
497
endif()
 
498
 
 
499
########################################################
 
500
###                      Tests                       ###
 
501
########################################################
 
502
if("${PACKAGE_TYPE}" STREQUAL "none")
 
503
        INCLUDE(Dart) ## for Nighlty Build log
 
504
        add_subdirectory(source/TEST EXCLUDE_FROM_ALL) ## configure the Test project (but do not add it to OpenMS itself)
 
505
 
 
506
  ## CppCheck testing
 
507
  if(NOT CMAKE_COMPILER_IS_CLANG) ## cppcheck does not support clang output
 
508
    find_package(cppcheck)
 
509
    if( CPPCHECK_FOUND )
 
510
      include( cmake/cppcheck.cmake )
 
511
    endif()
 
512
  endif()
 
513
endif()
 
514
 
 
515
########################################################
 
516
###    verbose Post-build messages and help targets  ###
 
517
########################################################
 
518
 
 
519
include(cmake/OpenMSBuildSystem_messages.cmake)
 
520
 
 
521
######################################################
 
522
#### build settings and configs for external code ####
 
523
######################################################
 
524
if ("${PACKAGE_TYPE}" STREQUAL "none")
 
525
        ## grep definitions (-D<XXX>) that were set using 'add_definitions()'
 
526
        get_property(OPENMS_CMP_DEFS DIRECTORY . PROPERTY COMPILE_DEFINITIONS)
 
527
        ## convert to CXX flags
 
528
        foreach(i ${OPENMS_CMP_DEFS})
 
529
                set(CF_OPENMS_ADDCXX_FLAGS "${CF_OPENMS_ADDCXX_FLAGS} -D${i}")
 
530
        endforeach(i)
 
531
        ## for add_definition commands (currently empty, but who knows...)
 
532
        set(CF_OPENMS_ADD_DEFINITIONS)
 
533
        ## the filename for library settings (this file will be included in OpenMSConfig.cmake)
 
534
        set(CF_LibOpenMSExport ${PROJECT_BINARY_DIR}/cmake/OpenMSLibraryExport.cmake)
 
535
 
 
536
        ## create code that allows to call find_package()
 
537
        ## (must come after the above code that sets the variables!)
 
538
        get_directory_property(OPENMS_INCLUDE_DIRS  INCLUDE_DIRECTORIES)
 
539
        configure_file(
 
540
                "${PROJECT_SOURCE_DIR}/cmake/OpenMSConfig.cmake.in"
 
541
                "${PROJECT_BINARY_DIR}/cmake/OpenMSConfig.cmake"
 
542
                @ONLY
 
543
        )
 
544
 
 
545
        ## Create OpenMSLibraryExport.cmake:
 
546
        ## Note: export_build_settings and
 
547
        ##       export_library_dependencies are deprecated and should not be used
 
548
        if ("${INSTALL_PREFIX}" STREQUAL ".")
 
549
                set(CVERSION "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
 
550
                if (CVERSION VERSION_LESS "2.8.0")
 
551
                        message(STATUS "Info: Cannot register OpenMS with CMake! For external code, set the path to OpenMS during find_package() manually.")
 
552
                else()
 
553
                        ## register OpenMS with CMake so that it can be found easily
 
554
                        export(PACKAGE OpenMS)
 
555
                endif()
 
556
                ## export our lib
 
557
                export(TARGETS OpenMS FILE ${CF_LibOpenMSExport})
 
558
        else()
 
559
                include(cmake/OpenMSBuildSystem_install.cmake)
 
560
        endif()
 
561
 
 
562
else()
 
563
######################################################
 
564
####          install/copy (cpack mainly)         ####
 
565
######################################################
 
566
        ## general definitions
 
567
        set(CPACK_PACKAGE_NAME "OpenMS")
 
568
        set(CPACK_PACKAGE_VENDOR "OpenMS.de")
 
569
        set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenMS - A framework for mass spectrometry")
 
570
        set(CPACK_PACKAGE_VERSION "${OPENMS_PACKAGE_VERSION_MAJOR}.${OPENMS_PACKAGE_VERSION_MINOR}.${OPENMS_PACKAGE_VERSION_PATCH}")
 
571
        set(CPACK_PACKAGE_VERSION_MAJOR "${OPENMS_PACKAGE_VERSION_MAJOR}")
 
572
        set(CPACK_PACKAGE_VERSION_MINOR "${OPENMS_PACKAGE_VERSION_MINOR}")
 
573
        set(CPACK_PACKAGE_VERSION_PATCH "${OPENMS_PACKAGE_VERSION_PATCH}")
 
574
        set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenMS-${CPACK_PACKAGE_VERSION}")
 
575
        set(CPACK_PACKAGE_DESCRIPTION_FILE ${PROJECT_SOURCE_DIR}/cmake/OpenMSPackageDescriptionFile.cmake)
 
576
        set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/License.txt)
 
577
        set(CPACK_RESOURCE_FILE_WELCOME ${PROJECT_SOURCE_DIR}/cmake/OpenMSPackageResourceWelcomeFile.txt)
 
578
        set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/cmake/OpenMSPackageResourceReadme.txt)
 
579
 
 
580
        # install routines for MacOSX
 
581
        if("${PACKAGE_TYPE}" STREQUAL "dmg")
 
582
                include(cmake/package_dragndrop_dmg.cmake)
 
583
        endif()
 
584
 
 
585
        if("${PACKAGE_TYPE}" STREQUAL "rpm")
 
586
                include(cmake/package_rpm.cmake)
 
587
        endif()
 
588
 
 
589
        if("${PACKAGE_TYPE}" STREQUAL "deb")
 
590
                include(cmake/package_deb.cmake)
 
591
        endif()
 
592
 
 
593
endif()
 
594