forked from DavidPH/GDCC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
218 lines (176 loc) · 5.35 KB
/
CMakeLists.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
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
##-----------------------------------------------------------------------------
##
## Copyright (C) 2013-2016 David Hill
##
## See COPYING for license information.
##
##-----------------------------------------------------------------------------
##
## Root CMake file.
##
##-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.6)
project(gdcc)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR})
include(CheckCXXCompilerFlag)
##----------------------------------------------------------------------------|
## Functions |
##
##
## GDCC_INSTALL_PART
##
function(GDCC_INSTALL_PART name wantExe wantLib)
if(wantExe AND GDCC_INSTALL_EXE)
install(TARGETS gdcc-${name}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif()
if(wantLib AND GDCC_INSTALL_LIB)
if(GDCC_INSTALL_API)
install(TARGETS gdcc-${name}-lib
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
elseif(GDCC_SHARED)
install(TARGETS gdcc-${name}-lib
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
endif()
endif()
endfunction()
##
## GDCC_TRY_CXX_FLAG
##
function(GDCC_TRY_CXX_FLAG flag name)
CHECK_CXX_COMPILER_FLAG(${flag} GDCC_FLAG_CXX_${name})
if(GDCC_FLAG_CXX_${name})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif()
endfunction()
##----------------------------------------------------------------------------|
## Environment Detection |
##
set(GDCC_SHARED_DEFAULT ON)
if(NOT GDCC_NOFLAGS)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
GDCC_TRY_CXX_FLAG(-Wall Wall)
GDCC_TRY_CXX_FLAG(-Wextra Wextra)
GDCC_TRY_CXX_FLAG(-Wshadow Wshadow)
GDCC_TRY_CXX_FLAG(-Wno-misleading-indentation Wno_misleading_indentation)
GDCC_TRY_CXX_FLAG(-Wno-implicit-fallthrough Wno_implicit_fallthrough)
GDCC_TRY_CXX_FLAG(-std=c++1z STD_CXX)
endif()
if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(/wd4146) # Unary minus applied to unsigned.
add_definitions(/wd4244) # Possible loss of data by conversion.
add_definitions(/wd4800) # Forcing value to boolean. (All my hate.)
add_definitions(/wd4996) # Deprecated declaration.
endif()
endif()
if(MSVC)
# Disable shared by default, as the source does not contain the needed
# declaration annotations to make that work under MSVC.
set(GDCC_SHARED_DEFAULT OFF)
endif()
find_package(GMP)
##----------------------------------------------------------------------------|
## Variables |
##
##
## GDCC_BC_DGE
##
if(NOT DEFINED GDCC_BC_DGE)
if(EXISTS "${CMAKE_SOURCE_DIR}/src/BC/DGE")
set(GDCC_BC_DGE ON CACHE BOOL "Enable bytecode module: DGE")
else()
set(GDCC_BC_DGE OFF CACHE BOOL "Enable bytecode module: DGE")
endif()
endif()
##
## GDCC_BC_ZDACS
##
if(NOT DEFINED GDCC_BC_ZDACS)
if(EXISTS "${CMAKE_SOURCE_DIR}/src/BC/ZDACS")
set(GDCC_BC_ZDACS ON CACHE BOOL "Enable bytecode module: ZDACS")
else()
set(GDCC_BC_ZDACS OFF CACHE BOOL "Enable bytecode module: ZDACS")
endif()
endif()
##
## GDCC_Core_BigNum
##
if(NOT DEFINED GDCC_Core_BigNum)
set(GDCC_Core_BigNum ${GMP_FOUND} CACHE BOOL
"Enable extended precision types and functions.")
endif()
##
## GDCC_INSTALL_API
##
if(NOT DEFINED GDCC_INSTALL_API)
set(GDCC_INSTALL_API ON CACHE BOOL "Install headers.")
endif()
##
## GDCC_INSTALL_DOC
##
if(NOT DEFINED GDCC_INSTALL_DOC)
set(GDCC_INSTALL_DOC ON CACHE BOOL "Install documentation.")
endif()
##
## GDCC_INSTALL_EXE
##
if(NOT DEFINED GDCC_INSTALL_EXE)
set(GDCC_INSTALL_EXE ON CACHE BOOL "Install executables.")
endif()
##
## GDCC_INSTALL_LIB
##
if(NOT DEFINED GDCC_INSTALL_LIB)
set(GDCC_INSTALL_LIB ON CACHE BOOL "Install libraries.")
endif()
##
## GDCC_SHARED
##
## If true (or equivalent), libraries will be built as SHARED. Otherwise,
## they are built as STATIC.
##
if(NOT DEFINED GDCC_SHARED)
set(GDCC_SHARED ${GDCC_SHARED_DEFAULT} CACHE BOOL
"Build libraries as shared objects.")
endif()
##
## GDCC_SHARED_DECL
##
## Used internally for convenience in add_library commands.
##
if(GDCC_SHARED)
set(GDCC_SHARED_DECL SHARED)
else()
set(GDCC_SHARED_DECL STATIC)
endif()
##----------------------------------------------------------------------------|
## Environment Configuration |
##
configure_file(inc/Config.hpp inc/GDCC/Config.hpp)
include_directories(${CMAKE_BINARY_DIR}/inc inc src)
if(GMP_FOUND)
include_directories(${GMP_INCLUDE_DIRS})
endif()
##----------------------------------------------------------------------------|
## Targets |
##
add_subdirectory(src)
if(GDCC_INSTALL_API)
install(DIRECTORY inc/ DESTINATION include/GDCC)
endif()
if(GDCC_INSTALL_DOC)
install(DIRECTORY doc/ DESTINATION share/gdcc/doc)
install(FILES COPYING DESTINATION share/gdcc/doc)
install(FILES COPYLIB DESTINATION share/gdcc/doc)
endif()
install(DIRECTORY lib/ DESTINATION share/gdcc/lib)
## EOF