-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
193 lines (154 loc) · 4.37 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
##-----------------------------------------------------------------------------
##
## Copyright (C) 2015-2016 David Hill
##
## See COPYING for license information.
##
##-----------------------------------------------------------------------------
##
## Root CMake file.
##
##-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0017 NEW)
project(acsvm)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
##----------------------------------------------------------------------------|
## Functions |
##
##
## ACSVM_INSTALL_EXE
##
function(ACSVM_INSTALL_EXE name)
if(ACSVM_INSTALL_EXE)
install(TARGETS ${name}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif()
endfunction()
##
## ACSVM_INSTALL_LIB
##
function(ACSVM_INSTALL_LIB name)
if(ACSVM_INSTALL_LIB)
if(ACSVM_INSTALL_API)
install(TARGETS ${name}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
elseif(ACSVM_SHARED)
install(TARGETS ${name}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
endif()
endif()
endfunction()
##
## ACSVM_TRY_C_FLAG
##
function(ACSVM_TRY_C_FLAG flag name)
CHECK_C_COMPILER_FLAG(${flag} ACSVM_C_FLAG_${name})
if(ACSVM_C_FLAG_${name})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
endif()
endfunction()
##
## ACSVM_TRY_CXX_FLAG
##
function(ACSVM_TRY_CXX_FLAG flag name)
CHECK_CXX_COMPILER_FLAG(${flag} ACSVM_CXX_FLAG_${name})
if(ACSVM_CXX_FLAG_${name})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif()
endfunction()
##----------------------------------------------------------------------------|
## Environment Detection |
##
set(ACSVM_SHARED_DEFAULT ON)
if(NOT ACSVM_NOFLAGS)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
ACSVM_TRY_C_FLAG(-Wall Wall)
ACSVM_TRY_C_FLAG(-Wextra Wextra)
ACSVM_TRY_C_FLAG(-std=c11 STD_C)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
ACSVM_TRY_CXX_FLAG(-Wall Wall)
ACSVM_TRY_CXX_FLAG(-Wextra Wextra)
ACSVM_TRY_CXX_FLAG(-std=c++11 STD_CXX)
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(ACSVM_SHARED_DEFAULT OFF)
endif()
##----------------------------------------------------------------------------|
## Variables |
##
##
## ACSVM_INSTALL_API
##
if(NOT DEFINED ACSVM_INSTALL_API)
set(ACSVM_INSTALL_API ON CACHE BOOL "Install ACSVM headers.")
endif()
##
## ACSVM_INSTALL_DOC
##
if(NOT DEFINED ACSVM_INSTALL_DOC)
set(ACSVM_INSTALL_DOC ON CACHE BOOL "Install ACSVM documentation.")
endif()
##
## ACSVM_INSTALL_EXE
##
if(NOT DEFINED ACSVM_INSTALL_EXE)
set(ACSVM_INSTALL_EXE ON CACHE BOOL "Install ACSVM executables.")
endif()
##
## ACSVM_INSTALL_LIB
##
if(NOT DEFINED ACSVM_INSTALL_LIB)
set(ACSVM_INSTALL_LIB ON CACHE BOOL "Install ACSVM libraries.")
endif()
##
## ACSVM_SHARED
##
## If true (or equiavalent), libraries will be built as SHARED. Otherwise,
## they are built as STATIC.
##
if(NOT DEFINED ACSVM_SHARED)
set(ACSVM_SHARED ${ACSVM_SHARED_DEFAULT} CACHE BOOL
"Build libraries as shared objects.")
endif()
##
## ACSVM_SHARED_DECL
##
## Used internally for convenience in add_library commands.
##
if(ACSVM_SHARED)
set(ACSVM_SHARED_DECL SHARED)
else()
set(ACSVM_SHARED_DECL STATIC)
endif()
##----------------------------------------------------------------------------|
## Environment Configuration |
##
include_directories(.)
##----------------------------------------------------------------------------|
## Targets |
##
add_subdirectory(ACSVM)
if(EXISTS "${CMAKE_SOURCE_DIR}/CAPI")
add_subdirectory(CAPI)
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/Exec")
add_subdirectory(Exec)
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/Util")
add_subdirectory(Util)
endif()
## EOF