-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
145 lines (127 loc) · 4.91 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
cmake_minimum_required(VERSION 3.20)
project(CastXMLSuperbuild NONE)
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
enable_language(C)
enable_language(CXX)
set(CMAKE_CXX_STANDARD "17")
if(APPLE)
set(osx_args
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.11
)
endif()
include(ExternalProject)
if(${CMAKE_VERSION} VERSION_LESS 3.24)
set(download_extract_timestamp_flag)
else()
set(download_extract_timestamp_flag DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
endif()
find_program(NINJA_EXECUTABLE ninja)
if(NINJA_EXECUTABLE)
set(CMAKE_GENERATOR "Ninja")
# Make Ninja verbose so CircleCI does not think the build has halted.
set(verbose_command BUILD_COMMAND ${NINJA_EXECUTABLE} ${BUILD_FLAGS} -v)
endif()
option(USE_SYSTEM_LLVM "Use the system LLVM instead of building it." OFF)
if(USE_SYSTEM_LLVM)
find_package(LLVM REQUIRED NO_MODULE)
set(castxml_deps)
else()
set(llvm_version 18.1.3)
set(llvm_folder 18.1.3)
set(LLVM_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm/lib/cmake/llvm/)
set(llvm_cmake_sha256 acfecb615d41c5b1a0a31e15324994ca06f7a3f37d8958d719b20de0d217b71b)
ExternalProject_Add(llvm-cmake
URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${llvm_folder}/cmake-${llvm_version}.src.tar.xz"
URL_HASH SHA256=${llvm_cmake_sha256}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
${download_extract_timestamp_flag}
LOG_BUILD 0
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm-prefix/src/cmake
)
set(llvm_sha256 fa6db8951f5ef576ac6bad43d5e1ed83962754538c998fbfa0397cd4521abc00)
ExternalProject_Add(llvm
URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${llvm_folder}/llvm-${llvm_version}.src.tar.xz"
URL_HASH SHA256=${llvm_sha256}
DEPENDS llvm-cmake
CMAKE_ARGS -Wno-dev
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_CACHE_ARGS
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DLLVM_STATIC_LINK_CXX_STDLIB:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DLLVM_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DLLVM_ENABLE_TERMINFO:BOOL=OFF
-DLLVM_INCLUDE_TESTS:BOOL=OFF
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF
-DLLVM_INCLUDE_DOCS:BOOL=OFF
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN:BOOL=ON
${osx_args}
${verbose_command}
${download_extract_timestamp_flag}
LOG_BUILD 0
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm
)
set(clang_sha256 e43e1729713ac0241aa026fa2f98bb54e74a196a6fed60ab4819134a428eb6d8)
ExternalProject_Add(clang
URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${llvm_folder}/clang-${llvm_version}.src.tar.xz"
URL_HASH SHA256=${clang_sha256}
DEPENDS llvm
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm-prefix/src/cfe-${llvm_version}
CMAKE_ARGS -Wno-dev
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_CACHE_ARGS
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCLANG_INCLUDE_DOCS:BOOL=OFF
-DCLANG_INCLUDE_TESTS:BOOL=OFF
-DLLVM_INCLUDE_TESTS:BOOL=OFF
-DLLVM_CONFIG:PATH=${CMAKE_CURRENT_BINARY_DIR}/llvm/bin/llvm-config
-DLLVM_DIR:PATH=${LLVM_DIR}
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN:BOOL=ON
${osx_args}
${verbose_command}
${download_extract_timestamp_flag}
LOG_BUILD 0
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm
)
set(castxml_deps llvm clang)
endif()
# Use a static C++ library on GCC/Linux
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME MATCHES "Linux")
set(linux_args "-DCMAKE_CXX_FLAGS:STRING=-static-libstdc++")
endif()
# 2024-04-12 master
set(CastXML_GIT_TAG v0.6.5 CACHE STRING "CastXML Git revision.")
ExternalProject_Add(castxml
GIT_REPOSITORY https://github.com/CastXML/CastXML.git
GIT_TAG ${CastXML_GIT_TAG}
DEPENDS ${castxml_deps}
CMAKE_ARGS -Wno-dev
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_CACHE_ARGS
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DLLVM_DIR:PATH=${LLVM_DIR}
${osx_args}
${linux_args}
${verbose_command}
LOG_BUILD 0
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/castxml
)