-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
59 lines (48 loc) · 1.55 KB
/
CMakeLists.txt
File metadata and controls
59 lines (48 loc) · 1.55 KB
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
cmake_minimum_required(VERSION 3.10)
project(TernaryGCCPlugin)
set(CMAKE_CXX_STANDARD 14)
# Find GCC plugin includes
find_path(GCC_PLUGIN_INCLUDE_DIR
NAMES gcc-plugin.h
PATHS /opt/homebrew/Cellar/gcc/15.2.0/lib/gcc/current/gcc/aarch64-apple-darwin25/15/plugin/include
/usr/lib/gcc/x86_64-linux-gnu/9/plugin/include
/usr/local/lib/gcc/x86_64-linux-gnu/9/plugin/include
)
if(NOT GCC_PLUGIN_INCLUDE_DIR)
message(FATAL_ERROR "GCC plugin include directory not found")
endif()
# Find GMP
find_path(GMP_INCLUDE_DIR
NAMES gmp.h
PATHS /opt/homebrew/include
/usr/include
/usr/local/include
)
if(NOT GMP_INCLUDE_DIR)
message(FATAL_ERROR "GMP include directory not found")
endif()
find_library(GMP_LIBRARY
NAMES gmp
PATHS /opt/homebrew/lib
/usr/lib
/usr/local/lib
)
if(NOT GMP_LIBRARY)
message(FATAL_ERROR "GMP library not found")
endif()
include_directories(${GCC_PLUGIN_INCLUDE_DIR})
include_directories(${GMP_INCLUDE_DIR})
include_directories(include)
# Plugin
add_library(ternary_plugin SHARED src/ternary_plugin.cpp)
target_compile_definitions(ternary_plugin PRIVATE PIC)
target_link_libraries(ternary_plugin ${GMP_LIBRARY} -Wl,-undefined,dynamic_lookup)
# Runtime
add_library(ternary_runtime STATIC runtime/ternary_runtime.c)
target_include_directories(ternary_runtime PUBLIC include)
# Install
install(TARGETS ternary_plugin ternary_runtime
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(DIRECTORY include/ DESTINATION include/ternary FILES_MATCHING PATTERN "*.h")