-
Notifications
You must be signed in to change notification settings - Fork 397
/
Copy pathCMakeLists.txt
38 lines (32 loc) · 1.19 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
# DEFINE THE TARGET
#==================
set(static_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/StaticMain.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../lib/StaticCallCounter.cpp"
)
add_executable(static ${static_SOURCES})
target_include_directories(
static
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../include")
# DECIDE WHAT LIBRARIES TO LINK IN
#=================================
# The list of the libraries below is the required minimum. However, when using
# LLVM from Homebrew your system linker might complain when using these:
# ```
# (...) Opaque pointers are only supported in -opaque-pointers mode (Producer: 'LLVM15.0.0' Reader: 'LLVM APPLE_1_1400.0.29.102_0')
# ```
# To work around this this, you can use `libLLVM` instead. That solves the
# problem because:
# * `libLLVM` is always a dynamic library (and the problem above is only
# triggered for static libs)
# * libLLVM includes all LLVM libraries (i.e. all the libraries listed below
# _and more_)
set(libs "LLVMCore LLVMPasses LLVMIRReader LLVMSupport")
try_compile(testMinimalCompilation "${CMAKE_BINARY_DIR}/temp" SOURCES ${static_SOURCES})
if(NOT ${testMinimalCompilation})
set(libs "LLVM")
endif()
target_link_libraries(static
${libs}
)