-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
167 lines (131 loc) · 5.65 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
# --- Script Setup
cmake_minimum_required (VERSION 3.4.3)
# Use Debug build by default.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Select build type. Options are: 'Debug', 'Release', 'RelWithDebInfo' and 'MinSizeRel'."
FORCE
)
message(STATUS "Set CMAKE_BUILD_TYPE to default '${CMAKE_BUILD_TYPE}'.")
endif(NOT CMAKE_BUILD_TYPE)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed.")
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
# Disable in-source builds and modifications
# to the source tree.
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
enable_testing()
project(llvm-abi C CXX)
# Add path for custom modules
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
)
# --- Project Properties
set(LLVMABI_VERSION_MAJOR 1)
set(LLVMABI_VERSION_MINOR 1)
set(LLVMABI_VERSION_PATCH 0)
set(LLVMABI_VERSION_BUILD 0)
set(LLVMABI_VERSION ${LLVMABI_VERSION_MAJOR}.${LLVMABI_VERSION_MINOR}.${LLVMABI_VERSION_PATCH}.${LLVMABI_VERSION_BUILD})
message(STATUS "Building llvm-abi version ${LLVMABI_VERSION} using build type '${CMAKE_BUILD_TYPE}'.")
message(STATUS " Source directory is '${PROJECT_SOURCE_DIR}'.")
message(STATUS " Build directory is '${PROJECT_BINARY_DIR}'.")
message(STATUS " Install prefix is '${CMAKE_INSTALL_PREFIX}'.")
# --- Compiler Flags
add_definitions(
-D__STDC_LIMIT_MACROS
-D__STDC_CONSTANT_MACROS
)
# Enable most warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wshadow -Wundef -Wpointer-arith -Wcast-align -Wwrite-strings")
# Use C++11.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# Add version as preprocessor defines.
add_definitions(
"-DLLVMABI_VERSION=${LLVMABI_VERSION}"
"-DLLVMABI_VERSION_MAJOR=${LLVMABI_VERSION_MAJOR}"
"-DLLVMABI_VERSION_MINOR=${LLVMABI_VERSION_MINOR}"
"-DLLVMABI_VERSION_PATCH=${LLVMABI_VERSION_PATCH}"
"-DLLVMABI_VERSION_BUILD=${LLVMABI_VERSION_BUILD}"
)
# --- User config
set(LLVM_ROOT_DIR "" CACHE STRING "Set LLVM root directory.")
if(NOT "${LLVM_ROOT_DIR}" STREQUAL "")
message(STATUS "Using LLVM_ROOT_DIR=${LLVM_ROOT_DIR}")
else(NOT "${LLVM_ROOT_DIR}" STREQUAL "")
message(STATUS "LLVM_ROOT_DIR wasn't specified (you can use this to search for LLVM in a particular path).")
endif(NOT "${LLVM_ROOT_DIR}" STREQUAL "")
# --- Dependencies
set(LLVM_SUPPORTED_VERSION "9.0")
# Find LLVM (for code generation).
set(LLVM_REQ_COMPONENTS all-targets bitreader bitwriter core irreader linker mcjit nativecodegen native ipo option)
find_package(LLVM REQUIRED ${LLVM_REQ_COMPONENTS})
# Check LLVM version.
set(LLVM_VERSION_SIMPLE_STRING "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
if("${LLVM_VERSION_SIMPLE_STRING}" VERSION_LESS "${LLVM_SUPPORTED_VERSION}")
message(FATAL_ERROR "LLVM version ${LLVM_VERSION_SIMPLE_STRING} is not supported (supported version is ${LLVM_SUPPORTED_VERSION}).")
elseif("${LLVM_VERSION_SIMPLE_STRING}" VERSION_GREATER "${LLVM_SUPPORTED_VERSION}")
message(WARNING "LLVM version ${LLVM_VERSION_SIMPLE_STRING} is not officially supported for this release (supported version is ${LLVM_SUPPORTED_VERSION}).")
endif()
math(EXPR LLVMABI_LLVM_VERSION ${LLVM_VERSION_MAJOR}*100+${LLVM_VERSION_MINOR})
message(STATUS "Using LLVM ${LLVM_VERSION_SIMPLE_STRING} (version integer is ${LLVMABI_LLVM_VERSION}).")
add_definitions(
-DLLVMABI_LLVM_VERSION=${LLVMABI_LLVM_VERSION}
)
set(LLVMABI_LLVM_INCLUDE_DIRS "${LLVM_INCLUDE_DIRS}" CACHE STRING "Set LLVM include directories.")
set(LLVMABI_LLVM_LIBRARY_DIRS "${LLVM_LIBRARY_DIRS}" CACHE STRING "Set LLVM library directories.")
message(STATUS " LLVM binary directory: ${LLVM_BINARY_DIR}")
message(STATUS " llc path: ${LLVM_LLC_EXECUTABLE}")
message(STATUS " llvm-dis path: ${LLVM_DIS_EXECUTABLE}")
message(STATUS " llvm-link path: ${LLVM_LINK_EXECUTABLE}")
message(STATUS " llvm-nm path: ${LLVM_NM_EXECUTABLE}")
message(STATUS " opt path: ${LLVM_OPT_EXECUTABLE}")
message(STATUS " LLVM include directories: ${LLVMABI_LLVM_INCLUDE_DIRS}")
message(STATUS " (if this is wrong, specify LLVMABI_LLVM_INCLUDE_DIRS)")
include_directories(SYSTEM ${LLVMABI_LLVM_INCLUDE_DIRS})
message(STATUS " LLVM library directories: ${LLVMABI_LLVM_LIBRARY_DIRS}")
message(STATUS " (if this is wrong, specify LLVMABI_LLVM_LIBRARY_DIRS)")
link_directories(${LLVMABI_LLVM_LIBRARY_DIRS})
# --- Subdirectories
include_directories(include)
add_subdirectory(lib)
add_subdirectory(test)
set(LLVMABI_PUBLIC_HEADERS
include/llvm-abi/ABI.hpp
include/llvm-abi/ABITypeInfo.hpp
include/llvm-abi/ArgInfo.hpp
include/llvm-abi/ArgumentIRMapping.hpp
include/llvm-abi/Builder.hpp
include/llvm-abi/Callee.hpp
include/llvm-abi/Caller.hpp
include/llvm-abi/CallingConvention.hpp
include/llvm-abi/DataSize.hpp
include/llvm-abi/FunctionEncoder.hpp
include/llvm-abi/FunctionIRMapping.hpp
include/llvm-abi/FunctionType.hpp
include/llvm-abi/Type.hpp
include/llvm-abi/TypeBuilder.hpp
include/llvm-abi/TypedValue.hpp
include/llvm-abi/TypePromoter.hpp
)
install(FILES ${LLVMABI_PUBLIC_HEADERS}
DESTINATION "include/llvm-abi"
)
set(LLVMABI_X86_PUBLIC_HEADERS
include/llvm-abi/x86/ArgClass.hpp
include/llvm-abi/x86/Classification.hpp
include/llvm-abi/x86/Classifier.hpp
include/llvm-abi/x86/CPUFeatures.hpp
include/llvm-abi/x86/CPUKind.hpp
include/llvm-abi/x86/Win64ABI.hpp
include/llvm-abi/x86/X86_32ABI.hpp
include/llvm-abi/x86/X86_32ABITypeInfo.hpp
include/llvm-abi/x86/X86_32Classifier.hpp
include/llvm-abi/x86/X86_64ABI.hpp
include/llvm-abi/x86/X86_64ABITypeInfo.hpp
)
install(FILES ${LLVMABI_X86_PUBLIC_HEADERS}
DESTINATION "include/llvm-abi/x86"
)