forked from percolator/percolator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommonCMake.txt
169 lines (145 loc) · 6.65 KB
/
CommonCMake.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
macro(my_set variable default options)
if(NOT DEFINED ${variable})
set(${variable} ${default} CACHE STRING ${options} FORCE)
endif(NOT DEFINED ${variable})
endmacro(my_set)
# STORE NEWLY SET VARIABLES IN *.h.cmake FILES
macro(load_config_files location)
file(GLOB_RECURSE configurefiles RELATIVE ${location} ${location}/*.cmake )
foreach(i ${configurefiles})
string(REPLACE ".cmake" "" myReplFile "${i}")
configure_file(${location}/${myReplFile}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${myReplFile} @ONLY)
endforeach()
endmacro()
# useful macro
macro(my_find_program progname)
find_program(${progname}_EXECUTABLE ${progname})
if(NOT ${progname}_EXECUTABLE)
message(FATAL_ERROR "${progname} not found" )
endif(NOT ${progname}_EXECUTABLE)
endmacro(my_find_program)
function(get_arch TARGET_ARCH)
# Detect machine architecture, on UNIX:
if(UNIX AND NOT APPLE AND NOT DEFINED ${TARGET_ARCH})
execute_process(COMMAND dpkg --print-architecture
OUTPUT_VARIABLE TARGET_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Architecture: ${TARGET_ARCH}")
endif(UNIX AND NOT APPLE AND NOT DEFINED ${TARGET_ARCH})
if(APPLE AND NOT DEFINED ${TARGET_ARCH})
execute_process(COMMAND uname -m
OUTPUT_VARIABLE TARGET_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Architecture: ${TARGET_ARCH}")
endif(APPLE AND NOT DEFINED ${TARGET_ARCH})
endfunction()
###############################################################################
# SET LOCATION OF MODULE FINDERS
###############################################################################
set(CMAKE_MODULE_PATH ${PERCOLATOR_SOURCE_DIR}/cmake)
###############################################################################
# SET GLOBAL VARIABLES
###############################################################################
# VERSION AND NAMESPACES
set(CPACK_PACKAGE_VERSION_MAJOR "3")
set(CPACK_PACKAGE_VERSION_MINOR "07")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(PIN_VERSION_MAJOR "1")
set(PIN_VERSION_MINOR "3")
set(POUT_VERSION_MAJOR "1")
set(POUT_VERSION_MINOR "5")
set(MZIDENTML_VERSION_MAJOR "1")
set(MZIDENTML_VERSION_MINOR "1")
set(GAML_TANDEM_VERSION_MAJOR "1")
set(GAML_TANDEM_VERSION_MINOR "0")
set(TANDEM_VERSION "2011.12.01.1")
# UPDATE PATCH VERSION FOR INTERMEDIATE BUILDS
INCLUDE(VersionGen)
NIGHTLY_VERSION_GEN(CPACK_PACKAGE_VERSION_PATCH ${CPACK_PACKAGE_VERSION_MAJOR} ${CPACK_PACKAGE_VERSION_MINOR} ${CPACK_PACKAGE_VERSION_PATCH})
#MESSAGE(STATUS "NIGHTLY_VERSION ${CPACK_PACKAGE_VERSION_PATCH}")
IF(MSVC)
set(XML_REL_PATH "share/xml\\\\percolator/")
ELSE(MSVC)
set(XML_REL_PATH "share/xml/percolator/")
ENDIF(MSVC)
IF(MINGW OR WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll" ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/lib/include)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${CMAKE_SOURCE_DIR}/lib/lib)
set(WRITABLE_DIR ${XML_REL_PATH})
add_definitions(-D_WIN32)
ELSE(MINGW OR WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_INCLUDE_PATH /usr/include ${CMAKE_INCLUDE_PATH})
set(CMAKE_LIBRARY_PATH /usr/lib /usr/lib64 ${CMAKE_LIBRARY_PATH})
set(WRITABLE_DIR ${CMAKE_INSTALL_PREFIX}/${XML_REL_PATH})
ENDIF(MINGW OR WIN32)
set(PIN_SCHEMA_LOCATION "xml-pin-${PIN_VERSION_MAJOR}-${PIN_VERSION_MINOR}/")
set(POUT_SCHEMA_LOCATION "xml-pout-${POUT_VERSION_MAJOR}-${POUT_VERSION_MINOR}/")
IF(MINGW)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(MINGW64 1)
SET(MINGW_PATH /usr/x86_64-w64-mingw32/sys-root/mingw/)
SET(MINGW_PACK_NAME win64)
ELSE()
SET(MINGW32 1)
SET(MINGW_PATH /usr/i686-w64-mingw32/sys-root/mingw/)
SET(MINGW_PACK_NAME win32)
ENDIF()
ENDIF(MINGW)
set(PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(percolator-in-namespace http://per-colator.com/percolator_in/${PIN_VERSION_MAJOR}${PIN_VERSION_MINOR})
set(percolator-out-namespace http://per-colator.com/percolator_out/${POUT_VERSION_MAJOR}${POUT_VERSION_MINOR})
set(mzIdentML-namespace "http://psidev.info/psi/pi/mzIdentML/${MZIDENTML_VERSION_MAJOR}.${MZIDENTML_VERSION_MINOR}")
set(gaxml_tandem-namespace "http://www.bioml.com/gaml/")
set(tandem-namespace "http://www.thegpm.org/TANDEM/${TANDEM_VERSION}")
#STATIC/DYNAMIC LIBRARY INCLUSION
if(APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
if(MINGW OR WIN32 OR APPLE)
OPTION(BUILD_SHARED_LIBS "build static binaries." OFF)
OPTION(STATIC "build static binaries. This is mainly intended for the win32-package and the MACOSX-bundle." ON )
else(MINGW OR WIN32 OR APPLE)
OPTION(STATIC "build static binaries. This is mainly intended for the win32-package and the MACOSX-bundle." OFF )
endif()
# Link Boost static and single threaded
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED OFF)
set(BOOST_MIN_VERSION "1.46.0")
set(Boost_ADDITIONAL_VERSIONS "1.46" "1.47.0" "1.47"
"1.48" "1.48.0" "1.49" "1.49.0" "1.50.0" "1.50" "1.51.0" "1.51")
###############################################################################
# SET COMPILER OPTIONS
###############################################################################
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED YES)
set (CMAKE_CXX_EXTENSIONS OFF)
IF(APPLE)
add_definitions(-Dxdr_uint16_t=xdr_u_int16_t -Dxdr_uint32_t=xdr_u_int32_t -Dxdr_uint64_t=xdr_u_int64_t)
set(Boost_USE_MULTITHREADED ON) # macports can currently not install single threaded boost libraries
ENDIF(APPLE)
if(UNIX OR APPLE OR MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -D_GLIBCXX_PARALLEL")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations -D_GLIBCXX_PARALLEL")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g")
endif()
if(PROFILING AND UNIX)
set(PROFILING_COMMON_FLAGS -Wno-unused-result -Wno-overflow -Wall -g -pg -fprofile-arcs -ftest-coverage)
endif()
if(MSVC)
add_definitions (/MP /D _CRT_SECURE_NO_WARNINGS /D _CRT_NONSTDC_NO_DEPRECATE)
# CMake automatically configures VS to use multi threading,
# if boost would use single threading, the auto-linking process of boost would fail.
set(Boost_USE_MULTITHREADED ON)
endif(MSVC)
if((NOT APPLE) OR (NOT CRUX AND APPLE AND ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 3.8))
find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif(OPENMP_FOUND)
endif()