-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
73 lines (59 loc) · 2.72 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
cmake_minimum_required(VERSION 3.20)
project(unplusplus)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(LLVM 13.0.0 REQUIRED CONFIG)
include(FindPkgConfig)
pkg_check_modules(jsoncpp REQUIRED IMPORTED_TARGET jsoncpp)
# Find Clang resource directory with Clang executable.
if(NOT CLANG_RESOURCE_DIR)
set(CLANG_EXECUTABLE "clang")
if(NOT CLANG_EXECUTABLE)
message(FATAL_ERROR "clang executable not found.")
endif()
execute_process(
COMMAND ${CLANG_EXECUTABLE} -print-resource-dir
RESULT_VARIABLE CLANG_FIND_RESOURCE_DIR_RESULT
OUTPUT_VARIABLE CLANG_RESOURCE_DIR
ERROR_VARIABLE CLANG_FIND_RESOURCE_DIR_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(CLANG_FIND_RESOURCE_DIR_RESULT)
message(FATAL_ERROR "Error retrieving Clang resource directory with Clang \
executable. Output:\n ${CLANG_FIND_RESOURCE_DIR_ERROR}")
endif()
endif()
set(SOURCE_FILES
src/main.cpp
src/identifier.cpp
src/outputs.cpp
src/action.cpp
src/filter.cpp
src/cxxrecord.cpp
src/function.cpp
src/enum.cpp
src/jobs.cpp
src/options.cpp
src/json.cpp)
add_executable(unplusplus ${SOURCE_FILES})
target_compile_definitions(unplusplus PUBLIC "CLANG_RESOURCE_DIRECTORY=R\"\(${CLANG_RESOURCE_DIR}\)\"")
set_target_properties(unplusplus PROPERTIES CXX_STANDARD 17)
target_include_directories(unplusplus PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
# For development, it's recommended to use clang/LLVM which include the debugging symbols and assertions
# target_include_directories(unplusplus PUBLIC ~/src/clang11/src/clang-11.0.1.src/include)
# target_include_directories(unplusplus PUBLIC ~/src/llvm11/src/llvm-11.0.1.src/include)
# target_include_directories(unplusplus PUBLIC ~/src/llvm11/src/llvm-11.0.1.src/build/include)
# target_link_directories(unplusplus PUBLIC ~/src/clang11/src/clang-11.0.1.src/build/lib)
# target_link_directories(unplusplus PUBLIC ~/src/llvm11/src/llvm-11.0.1.src/build/lib)
# target_compile_definitions(unplusplus PUBLIC _GNU_SOURCE __STDC_CONSTANT_MACROS __STDC_FORMAT_MACROS __STDC_LIMIT_MACROS _DEBUG)
# target_link_libraries(unplusplus PUBLIC ~/src/clang11/src/clang-11.0.1.src/build/lib/libclang-cpp.so ~/src/llvm11/src/llvm-11.0.1.src/build/lib/libLLVM-11.so)
target_link_libraries(unplusplus PUBLIC clang-cpp LLVM PkgConfig::jsoncpp)
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin")
set_target_properties(unplusplus PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}"
)
include(cmake/unplusplus.cmake)
set(BUILD_UNPLUSPLUS_EXAMPLES ON CACHE BOOL "Build the examples for unplusplus")
if (BUILD_UNPLUSPLUS_EXAMPLES)
add_subdirectory(examples)
endif()
install(TARGETS unplusplus DESTINATION bin)