-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
100 lines (80 loc) · 3.32 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
cmake_minimum_required(VERSION 3.0)
set(TINYREFL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "")
set(TINYREFL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "")
set(TINYREFL_INCLUDE_DIR "${TINYREFL_SOURCE_DIR}/include" CACHE PATH "")
list(APPEND CMAKE_PREFIX_PATH "${TINYREFL_BINARY_DIR}")
include(cmake/git.cmake)
include(cmake/utils.cmake)
project(tinyrefl VERSION "${TINYREFL_VERSION}")
include (CheckCXXCompilerFlag)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(TINYREFL_IS_ROOT_PROJECT TRUE)
else()
set(TINYREFL_IS_ROOT_PROJECT FALSE)
endif()
option(TINYREFL_USE_LOCAL_LLVM "Use local LLVM install instead of downloading LLVM" OFF)
option(TINYREFL_LLVM_DOWNLOAD_FROM_OFFICIAL_SERVER "Download LLVM from official LLVM server instead of artifactory" OFF)
option(TINYREFL_BUILD_TESTS "Build tinyrefl tests" ${TINYREFL_IS_ROOT_PROJECT})
option(TINYREFL_BUILD_EXAMPLES "Build tinyrefl examples" ${TINYREFL_IS_ROOT_PROJECT})
option(TINYREFL_BUILD_TOOL "Build tinyrefl-tool" ON)
if(NOT DEFINED TINYREFL_LLVM_VERSION)
set(TINYREFL_LLVM_VERSION "6.0.1")
endif()
parse_version_number(${TINYREFL_LLVM_VERSION} TINYREFL_LLVM_VERSION_MAJOR TINYREFL_LLVM_VERSION_MINOR TINYREFL_LLVM_VERSION_FIX)
set(CMAKE_CXX_STANDARD 14)
if(NOT MSVC)
check_cxx_compiler_flag("-Wnoexcept-type" HAS_NOEXCEPT_ABI_WARNING)
if(HAS_NOEXCEPT_ABI_WARNING)
set(no_noexcept_abi_warning "-Wno-noexcept-type")
endif()
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wno-attributes ${no_noexcept_abi_warning}")
endif()
if(CMAKE_TOOLCHAIN_FILE OR TINYREFL_CROSS_BUILDING)
message(STATUS "Tinyrefl cross building")
set(TINYREFL_CROSS_BUILDING ON CACHE BOOL "")
else()
message(STATUS "Tinyrefl building for host")
set(TINYREFL_CROSS_BUILDING OFF CACHE BOOL "")
endif()
set(CONAN_BUILDINFO_FILE "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
if(EXISTS "${CONAN_BUILDINFO_FILE}")
message(STATUS "Importing Conan targets from build info file...")
include("${CONAN_BUILDINFO_FILE}")
conan_basic_setup(TARGETS)
set(TINYREFL_USING_CONAN_TARGETS TRUE CACHE INTERNAL "")
if(NOT MSVC)
if(CONAN_SETTINGS_COMPILER_LIBCXX STREQUAL "libstdc++11")
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
endif()
if(CONAN_SETTINGS_COMPILER_LIBCXX STREQUAL "libstdc++")
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
endif()
endif()
endif()
message(STATUS "Configuring tinyrefl external dependencies...")
include(external/external.cmake)
message(STATUS "Configuring tinyrefl library...")
add_subdirectory(src)
if(TINYREFL_BUILD_TOOL)
message(STATUS "Configuring tinyrefl tool...")
add_subdirectory(tool)
endif()
# Implicitly add driver for users
include(${TINYREFL_SOURCE_DIR}/tool/driver.cmake)
if(TINYREFL_BUILD_TESTS AND NOT TINYREFL_CROSS_BUILDING)
include(cmake/ctest_setup.cmake)
message(STATUS "Configuring tinyrefl tests...")
add_subdirectory(tests)
endif()
if(TINYREFL_BUILD_EXAMPLES)
include(cmake/ctest_setup.cmake)
message(STATUS "Configuring tinyrefl examples...")
add_subdirectory(examples)
endif()
if(TINYREFL_IS_ROOT_PROJECT)
message(STATUS "Generate vim YCM config file for tinyrefl at ${TINYREFL_SOURCE_DIR} ...")
configure_file(
${TINYREFL_SOURCE_DIR}/.ycm_extra_conf.py.in
${TINYREFL_SOURCE_DIR}/.ycm_extra_conf.py
)
endif()