-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
68 lines (50 loc) · 1.99 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
cmake_minimum_required(VERSION 3.9)
project("fire-llvm"
VERSION 0.1
LANGUAGES CXX)
include(CTest)
option(FIRE_LLVM_ENABLE_TESTING "Enable tests" ON)
# Clang
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ClangSetup)
include(ClangSetup)
# fire-hpp
set(FIRE_EXAMPLES OFF CACHE BOOL "Compile fire-hpp examples")
set(FIRE_UNIT_TESTS OFF CACHE BOOL "Enable fire-hpp unit tests")
add_subdirectory(fire-hpp EXCLUDE_FROM_ALL)
# fire-llvm
add_subdirectory(fire-llvm)
function(fire_llvm_config TARGET)
set(options DISABLED)
set(oneValueArgs)
set(multiValueArgs)
cmake_parse_arguments(FIRE_LLVM_CONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(FATAL_ERROR "fire_llvm_config can only be used when CMAKE_CXX_COMPILER is Clang")
endif()
get_target_property(target_type ${TARGET} TYPE)
if (NOT target_type STREQUAL "EXECUTABLE")
message(FATAL_ERROR "fire_llvm_config can only be used on executable targets")
endif()
if (NOT ${FIRE_LLVM_CONFIG_DISABLED})
target_compile_options(${TARGET} PRIVATE
"SHELL:-Xclang -load"
"SHELL:-Xclang $<TARGET_FILE:fire-llvm-plugin>"
"SHELL:-Xclang -add-plugin"
"SHELL:-Xclang fire")
endif()
target_link_libraries(${TARGET} PRIVATE fire-hpp fire-llvm)
# Force rebuilding targets that depend on the fire compiler plugin.
# XXX This can be simplified when CMake starts allowing generator expression
# arguments for OBJECT_DEPENDS.
set(fire_llvm_plugin_dummy "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_fire-llvm-plugin-dummy")
add_custom_command(
OUTPUT "${fire_llvm_plugin_dummy}"
COMMAND ${CMAKE_COMMAND} -E touch "${fire_llvm_plugin_dummy}"
DEPENDS $<TARGET_FILE:fire-llvm-plugin>)
get_target_property(target_sources ${TARGET} SOURCES)
set_source_files_properties(${target_sources} PROPERTIES
OBJECT_DEPENDS "${fire_llvm_plugin_dummy}")
endfunction()
if (FIRE_LLVM_ENABLE_TESTING)
add_subdirectory(tests)
endif()