aboutsummaryrefslogtreecommitdiff
path: root/configuration/CMakeLists.txt
blob: e8a84075bd551d9d087b6658ca21c370222ab1d2 (plain)
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

include(CheckCXXSourceCompiles)

set(CMAKE_REQUIRED_FLAGS "${FRUIT_COMPILE_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")

CHECK_CXX_SOURCE_COMPILES("
int main() {}
"
FRUIT_TRIVIAL_SOURCE_COMPILES)

if (NOT "${FRUIT_TRIVIAL_SOURCE_COMPILES}")
    message(FATAL_ERROR "A trivial program with an empty main doesn't compile, something is wrong with your compiler and/or with your compiler flags.")
endif()

CHECK_CXX_SOURCE_COMPILES("
template <typename T, typename U>
struct Pair {};

struct Map : public Pair<int, float>, Pair<int, char> {};

template <typename Value>
Value f(Pair<int, Value>*) { return Value(); }

int main() {
  f((Map*)0);
}
"
FRUIT_HAS_CLANG_ARBITRARY_OVERLOAD_RESOLUTION_BUG)

CHECK_CXX_SOURCE_COMPILES("
int main() {
  bool b = __has_trivial_copy(int);
  (void) b;
  return 0;
}
"
FRUIT_HAS_HAS_TRIVIAL_COPY)

CHECK_CXX_SOURCE_COMPILES("
int main() {
  bool b = __is_trivially_copyable(int);
  (void) b;
  return 0;
}
"
FRUIT_HAS_IS_TRIVIALLY_COPYABLE)

CHECK_CXX_SOURCE_COMPILES("
#include <cstddef>
using X = max_align_t;
int main() {
  return 0;
}
"
FRUIT_HAS_MAX_ALIGN_T)

CHECK_CXX_SOURCE_COMPILES("
#include <type_traits>
int main() {
  bool b = std::is_trivially_copyable<int>::value;
  (void) b;
  return 0;
}
"
FRUIT_HAS_STD_IS_TRIVIALLY_COPYABLE)

CHECK_CXX_SOURCE_COMPILES("
#include <type_traits>
int main() {
  bool b = std::is_trivially_copy_constructible<int>::value;
  (void) b;
  return 0;
}
"
FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE)

CHECK_CXX_SOURCE_COMPILES("
#include <cstddef>
using X = std::max_align_t;
int main() {
  return 0;
}
"
FRUIT_HAS_STD_MAX_ALIGN_T)

CHECK_CXX_SOURCE_COMPILES("
#include <typeinfo>
int main() {
  (void) typeid(int);
  return 0;
}
"
FRUIT_HAS_TYPEID)

CHECK_CXX_SOURCE_COMPILES("
#include <typeinfo>
int main() {
  constexpr static const std::type_info& x = typeid(int);
  (void) x;
  return 0;
}
"
FRUIT_HAS_CONSTEXPR_TYPEID)

CHECK_CXX_SOURCE_COMPILES("
#include <cxxabi.h>
int main() {
  auto* p = abi::__cxa_demangle;
  (void) p;
  return 0;
}
"
FRUIT_HAS_CXA_DEMANGLE)

CHECK_CXX_SOURCE_COMPILES("
__attribute__((always_inline))
void f() {
}

int main() {
  return 0;
}
"
FRUIT_HAS_ALWAYS_INLINE_ATTRIBUTE)

CHECK_CXX_SOURCE_COMPILES("
__forceinline
void f() {
}

int main() {
  return 0;
}
"
FRUIT_HAS_FORCEINLINE)

if (NOT "${FRUIT_HAS_STD_MAX_ALIGN_T}" AND NOT "${FRUIT_HAS_MAX_ALIGN_T}")
  message(WARNING "The current C++ standard library doesn't support std::max_align_t nor ::max_align_t. Attempting to use std::max_align_t anyway, but it most likely won't work.")
endif()

if(NOT "${FRUIT_HAS_STD_IS_TRIVIALLY_COPYABLE}" AND NOT "${FRUIT_HAS_IS_TRIVIALLY_COPYABLE}"
   AND NOT "${FRUIT_HAS_HAS_TRIVIAL_COPY}")
  message(WARNING "The current standard library doesn't support std::is_trivially_copyable<T>, and the current compiler doesn't support __is_trivially_copyable(T) nor __has_trivial_copy(T). Attemping to use std::is_trivially_copyable<T> anyway, but it most likely won't work.")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fruit-config-base.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/fruit/impl/fruit-config-base.h)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../include/fruit/impl/fruit-config-base.h
  DESTINATION ${INSTALL_INCLUDE_DIR}/impl)