-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
76 lines (60 loc) · 2.04 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
cmake_minimum_required(VERSION 3.4.4)
project(clang-new-macro)
set(CMAKE_CXX_STANDARD 14)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Using LLVM ${LLVM_PACKAGE_VERSION}")
add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIR})
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)
find_package(Clang REQUIRED CONFIG)
include_directories(${CLANG_INCLUDE_DIRS})
list(APPEND CMAKE_MODULE_PATH "${CLANG_CMAKE_DIR}")
# Handle RTTI stuff, which often leads to error
if(NOT ${LLVM_ENABLE_RTTI})
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
message(STATUS "Disable RTTI")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
message(STATUS "Disable RTTI")
endif()
# Do not give any flags for other less widely used
# compilers
endif()
option(NACRO_ENABLE_UNITTESTS "Enable unit tests for naco" OFF)
# FIXME: What about static lib?
option(NACRO_BUILD_LIB
"Enable building a shared library containing all nacro functions" OFF)
option(NACRO_ENABLE_TESTS "Enable end-to-end tests for naco" OFF)
set(_SOURCE_FILES
NacroPragmaHandler.cpp
NacroRule.cpp
NacroParsers.cpp
NacroExpanders.cpp
NacroVerifier.cpp
)
add_llvm_library(NacroPlugin MODULE
${_SOURCE_FILES}
PLUGIN_TOOL clang)
#add_subdirectory(Playground)
if(${NACRO_BUILD_LIB} OR ${NACRO_ENABLE_UNITTESTS})
add_library(Nacro SHARED
${_SOURCE_FILES})
target_link_libraries(Nacro
clangBasic
clangLex
clangFrontend
clangAST)
endif()
if(${NACRO_ENABLE_UNITTESTS})
add_subdirectory(unittest)
endif()
if(${NACRO_ENABLE_TESTS})
add_subdirectory(test)
endif()
add_subdirectory(utils)