SeqAn3
platform.hpp
Go to the documentation of this file.
1 // ============================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ============================================================================
4 //
5 // Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin
6 // Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // * Neither the name of Knut Reinert or the FU Berlin nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
25 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 // DAMAGE.
32 //
33 // ============================================================================
34 
35 #pragma once
36 
37 #include <cinttypes>
38 #include <ciso646> // makes _LIBCPP_VERSION available
39 #include <cstddef> // makes __GLIBCXX__ available
40 
46 // macro cruft
48 #define STR_HELPER(x) #x
49 #define STR(x) STR_HELPER(x)
50 
52 // C++ standard [required]
53 #ifdef __cplusplus
54  static_assert(__cplusplus >= 201703, "SeqAn3 requires C++17, make sure that you have set -std=c++17.");
55 #else
56 # error "This is not a C++ compiler."
57 #endif
58 
59 // Concepts TS [required]
60 #ifdef __cpp_concepts
61 # if __cpp_concepts == 201507 // GCC and Concepts TS
62 # define concept concept bool
63 # else
64  static_assert(__cpp_concepts >= 201507, "Your compiler supports Concepts, but the support is not recent enough.");
65 # endif
66 #else
67 # error "SeqAn3 requires the Concepts TS, make sure that you have set -fconcepts (not all compilers support this)."
68 #endif
69 
70 // SeqAn [required]
71 #if !__has_include(<seqan3/version.hpp>)
72 # error SeqAn3 include directory not set correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?
73 #endif
74 
75 // Ranges [required]
76 #if __has_include(<range/v3/version.hpp>)
77 # define RANGE_V3_MINVERSION 400
78 # define RANGE_V3_MAXVERSION 499
79 // TODO the following doesn't actually show the current version, only its formula. How'd you do it?
80 # define MSG "Your version: " STR(RANGE_V3_VERSION) \
81  "; minimum version: " STR(RANGE_V3_MINVERSION) \
82  "; expected maximum version: " STR(RANGE_V3_MAXVERSION)
83 # include <range/v3/version.hpp>
84 # if RANGE_V3_VERSION < RANGE_V3_MINVERSION
85 # error Your range-v3 library is too old.
86 # pragma message(MSG)
87 # elif RANGE_V3_VERSION > RANGE_V3_MAXVERSION
88 # pragma GCC warning "Your range-v3 library is possibly too new. Some features might not work correctly."
89 # pragma message(MSG)
90 # endif
91 # undef MSG
92 #else
93 # error The range-v3 library was not included correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?
94 #endif
95 
96 // filesystem [required]
97 #if !__has_include(<filesystem>)
98 # if !__has_include(<experimental/filesystem>)
99 # error SeqAn3 requires C++17 filesystem support, but it was not found.
100 # endif
101 #endif
102 
103 // SDSL [required]
104 #if __has_include(<sdsl/version.hpp>)
105 # include <sdsl/version.hpp>
106  static_assert(sdsl::sdsl_version_major == 3, "Only version 3 of the SDSL is supported by SeqAn3.");
107 #else
108 # error The sdsl library was not included correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?
109 #endif
110 
111 // Cereal [optional]
116 #ifndef SEQAN3_WITH_CEREAL
117 # if __has_include(<cereal/cereal.hpp>)
118 # define SEQAN3_WITH_CEREAL 1
119 # else
120 # define SEQAN3_WITH_CEREAL 0
121 # endif
122 #elif SEQAN3_WITH_CEREAL != 0
123 # if ! __has_include(<cereal/cereal.hpp>)
124 # error Cereal was marked as required, but not found!
125 # endif
126 #endif
127 
128 #if !SEQAN3_WITH_CEREAL
129 
135 # define CEREAL_SERIALIZE_FUNCTION_NAME serialize
136 # define CEREAL_LOAD_FUNCTION_NAME load
137 # define CEREAL_SAVE_FUNCTION_NAME save
138 # define CEREAL_LOAD_MINIMAL_FUNCTION_NAME load_minimal
139 # define CEREAL_SAVE_MINIMAL_FUNCTION_NAME save_minimal
140 
143 #endif
144 
145 // Lemon [optional]
150 #ifndef SEQAN3_WITH_LEMON
151 # if __has_include(<lemon/config.h>)
152 # define SEQAN3_WITH_LEMON 1
153 # else
154 # define SEQAN3_WITH_LEMON 0
155 # endif
156 #elif SEQAN3_WITH_LEMON != 0
157 # if !__has_include(<lemon/config.h>)
158 # error Lemon was marked as required, but not found!
159 # endif
160 #endif
161 #if SEQAN3_WITH_LEMON == 1
162 # define LEMON_HAVE_LONG_LONG 1
163 # define LEMON_CXX11 1
164 # if defined(__unix__) || defined(__APPLE__)
165 # define LEMON_USE_PTHREAD 1
166 # define LEMON_USE_WIN32_THREADS 0
167 # define LEMON_WIN32 0
168 # else
169 # define LEMON_USE_PTHREAD 0
170 # define LEMON_USE_WIN32_THREADS 1
171 # define LEMON_WIN32 1
172 # endif
173 #endif
174 
175 // TODO (doesn't have a version.hpp, yet)
176 
177 // Doxygen related
178 // this macro is a NO-OP unless doxygen parses it, in which case it resolves to the argument
179 #ifndef SEQAN3_DOXYGEN_ONLY
180 # define SEQAN3_DOXYGEN_ONLY(x)
181 #endif
182 
183 // macro cruft undefine
184 #undef STR
185 #undef STR_HELPER