-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathCMakeLists.txt
125 lines (103 loc) · 4.03 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
# MPark.Variant
#
# Copyright Michael Park, 2015-2017
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.6.3)
option(MPARK_VARIANT_EXCEPTIONS
"Build the tests with exceptions support." ON)
if(MPARK_VARIANT_INCLUDE_MPARK_TESTS)
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
add_definitions(-DGTEST_HAS_STD_TUPLE=1)
add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/googletest
${CMAKE_BINARY_DIR}/3rdparty/googletest)
config_compiler_and_linker()
if(MPARK_VARIANT_EXCEPTIONS)
set(compile_flags ${cxx_strict})
else()
set(compile_flags ${cxx_no_exception})
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
set(compile_flags "${compile_flags} /wd4577")
endif()
set(MPARK_TESTS
assign.copy
assign.fwd
assign.move
ctor.copy
ctor.default
ctor.fwd
ctor.in_place
ctor.move
dtor
get
hash
intro
issue
json
mod
relops
swap
visit)
foreach(test ${MPARK_TESTS})
add_executable(${test} ${test}.cpp)
set_target_properties(${test} PROPERTIES COMPILE_FLAGS "${compile_flags}")
target_link_libraries(${test} gtest_main mpark_variant)
add_test(${test} ${test} --gtest_color=yes)
endforeach()
endif()
if(MPARK_VARIANT_INCLUDE_LIBCXX_TESTS)
include(ExternalProject)
set(MPARK_VARIANT_LLVM_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm)
set(MPARK_VARIANT_LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm-build)
ExternalProject_Add(llvm
GIT_REPOSITORY https://git.llvm.org/git/llvm.git
GIT_SHALLOW 1
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_FLAGS="-w"
-DLIBCXX_ENABLE_EXCEPTIONS=${MPARK_VARIANT_EXCEPTIONS}
SOURCE_DIR ${MPARK_VARIANT_LLVM_SOURCE_DIR}
BINARY_DIR ${MPARK_VARIANT_LLVM_BINARY_DIR}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --target cxx
COMMAND ${CMAKE_COMMAND} --build . --target cxxabi
COMMAND ${CMAKE_COMMAND} --build . --target cxx_experimental
INSTALL_COMMAND "" # Disable install step
STEP_TARGETS download
)
set(MPARK_VARIANT_LIBCXX_SOURCE_DIR ${MPARK_VARIANT_LLVM_SOURCE_DIR}/projects/libcxx)
set(MPARK_VARIANT_LIBCXX_BINARY_DIR ${MPARK_VARIANT_LLVM_BINARY_DIR}/projects/libcxx)
ExternalProject_Add(libcxx-download
GIT_REPOSITORY https://git.llvm.org/git/libcxx.git
GIT_SHALLOW 1
DEPENDS llvm-download
SOURCE_DIR ${MPARK_VARIANT_LIBCXX_SOURCE_DIR}
BINARY_DIR ${MPARK_VARIANT_LIBCXX_BINARY_DIR}
CONFIGURE_COMMAND "" # Disable configure step
BUILD_COMMAND "" # Disable build step
INSTALL_COMMAND "" # Disable install step
)
set(MPARK_VARIANT_LIBCXXABI_SOURCE_DIR ${MPARK_VARIANT_LLVM_SOURCE_DIR}/projects/libcxxabi)
set(MPARK_VARIANT_LIBCXXABI_BINARY_DIR ${MPARK_VARIANT_LLVM_BINARY_DIR}/projects/libcxxabi)
ExternalProject_Add(libcxxabi-download
GIT_REPOSITORY https://git.llvm.org/git/libcxxabi.git
GIT_SHALLOW 1
DEPENDS llvm-download
SOURCE_DIR ${MPARK_VARIANT_LIBCXXABI_SOURCE_DIR}
BINARY_DIR ${MPARK_VARIANT_LIBCXXABI_BINARY_DIR}
CONFIGURE_COMMAND "" # Disable configure step
BUILD_COMMAND "" # Disable build step
INSTALL_COMMAND "" # Disable install step
)
ExternalProject_Add_StepDependencies(llvm configure libcxx-download libcxxabi-download)
add_test(libcxx
${CMAKE_COMMAND} -E
env MPARK_VARIANT_CXX_COMPILER=${CMAKE_CXX_COMPILER}
env MPARK_VARIANT_SOURCE_DIR=${CMAKE_SOURCE_DIR}
env MPARK_VARIANT_LIBCXX_SOURCE_DIR=${MPARK_VARIANT_LIBCXX_SOURCE_DIR}
env MPARK_VARIANT_LIBCXX_SITE_CONFIG=${MPARK_VARIANT_LIBCXX_BINARY_DIR}/test/lit.site.cfg
env MPARK_VARIANT_LIT=${MPARK_VARIANT_LLVM_BINARY_DIR}/bin/llvm-lit
${CMAKE_CURRENT_SOURCE_DIR}/libcxx.sh
)
endif()