-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
64 lines (53 loc) · 1.95 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
cmake_minimum_required(VERSION 3.5.1)
project(DebugIR LANGUAGES C CXX)
option(LINK_LLVM_SHARED "Control whether debugir links to a shared LLVM library, or individual static components" ON)
# export compile commands
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# C++ standard
set(CMAKE_CXX_STANDARD 20)
# detect operating system
message(STATUS "We are on a ${CMAKE_SYSTEM_NAME} system")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Print build type: Debug/Release etc.
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
#
# check dependencies
#
# LLVM stuff
if(NOT DEFINED DEBUGIR_LLVM_VERSION)
set(DEBUGIR_LLVM_VERSION 18.1)
endif()
find_package(LLVM ${DEBUGIR_LLVM_VERSION} REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
if(LINK_LLVM_SHARED)
set(llvm_libs LLVM)
else()
# Find the libraries that correspond to the LLVM components we use
llvm_map_components_to_libnames(llvm_libs support core irreader transformutils Passes)
endif()
add_library(dbgir SHARED DebugIR.cpp)
# Match LLVM's RTTI build mode
if (NOT LLVM_ENABLE_RTTI)
message(STATUS "LLVM does not have RTTI enabled. Building with -fno-rtti")
target_compile_options(dbgir PUBLIC -fno-rtti)
endif()
set(DEBUGIR_WARN_FLAGS
-Wall
-Werror
-pedantic
-Wextra
-Wno-unknown-pragmas
-Wno-unused-parameter
)
# compiler and linker options
# PUBLIC because we apply the same to the debugir executable
target_compile_options(dbgir PRIVATE ${DEBUGIR_WARN_FLAGS})
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
target_compile_definitions(dbgir PUBLIC ${LLVM_DEFINITIONS_LIST})
target_include_directories(dbgir PUBLIC ${PROJECT_SOURCE_DIR}/include/)
target_include_directories(dbgir PUBLIC ${LLVM_INCLUDE_DIRS})
target_link_libraries (dbgir PUBLIC ${llvm_libs})
add_executable(debugir Main.cpp)
target_compile_options(debugir PRIVATE ${DEBUGIR_WARN_FLAGS})
target_link_libraries(debugir dbgir)