-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
104 lines (84 loc) · 2.76 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
cmake_minimum_required(VERSION 3.0)
if(UNIX)
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
endif(UNIX)
set(PRODUCT_NAME RISCV)
project(${PRODUCT_NAME})
set(HOPPER_SDK_PATH ${CMAKE_SOURCE_DIR}/HopperSDK/include)
if(APPLE)
set(HOPPER_PLUGINS_PATH "~/Library/Application Support/Hopper/Plugins/V4")
else(UNIX)
set(HOPPER_PLUGINS_PATH "~/GNUstep/Library/ApplicationSupport/Hopper/PlugIns/v4")
endif(APPLE)
set(HOPPER_PLUGIN_CPU_DIRNAME CPUs)
set(HOPPER_PLUGIN_CPU_EXTENSION hopperCPU)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_INSTALL_PREFIX ${HOPPER_PLUGINS_PATH} CACHE PATH "Plugins install prefix" FORCE)
add_definitions(
-std=c11
)
include_directories("${HOPPER_SDK_PATH}" "${CMAKE_SOURCE_DIR}")
if(NOT APPLE)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "Clang required!")
endif(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
find_program(GNUSTEP gnustep-config)
if(NOT GNUSTEP)
message(FATAL_ERROR "gnustep-config not found!")
endif(NOT GNUSTEP)
execute_process(COMMAND ${GNUSTEP} --objc-flags
OUTPUT_VARIABLE GNUSTEP_FLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
separate_arguments(GNUSTEP_FLAGS UNIX_COMMAND ${GNUSTEP_FLAGS})
execute_process(COMMAND ${GNUSTEP} --base-libs
OUTPUT_VARIABLE GNUSTEP_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(GNUSTEP_LIBS "${GNUSTEP_LIBS}")
endif(NOT APPLE)
add_library(
${PRODUCT_NAME} MODULE
RISCV/RISCVCPU.m
RISCV/RISCVCtx.m
)
target_compile_options(
${PRODUCT_NAME} PUBLIC
-fno-exceptions
-pedantic
-Wall
-Wextra
-Wno-gnu-binary-literal
-fPIC
-fobjc-arc
-fobjc-nonfragile-abi
-fblocks
${GNUSTEP_FLAGS}
)
if(APPLE)
set_target_properties(
${PRODUCT_NAME} PROPERTIES
BUNDLE TRUE
BUNDLE_EXTENSION ${HOPPER_PLUGIN_CPU_EXTENSION}
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in)
target_link_libraries(${PRODUCT_NAME} "-framework Foundation")
install(
TARGETS ${PRODUCT_NAME}
LIBRARY DESTINATION ${HOPPER_PLUGIN_CPU_DIRNAME}
)
else(UNIX)
set_target_properties(
${PRODUCT_NAME} PROPERTIES
PREFIX ""
SUFFIX "")
target_link_libraries(${PRODUCT_NAME} ${GNUSTEP_LIBS})
install(
TARGETS ${PRODUCT_NAME}
LIBRARY DESTINATION "${HOPPER_PLUGIN_CPU_DIRNAME}/${PRODUCT_NAME}.${HOPPER_PLUGIN_CPU_EXTENSION}"
)
configure_file(Info-gnustep.plist.in Resources/Info-gnustep.plist)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Resources
DESTINATION "${HOPPER_PLUGIN_CPU_DIRNAME}/${PRODUCT_NAME}.${HOPPER_PLUGIN_CPU_EXTENSION}"
)
endif(APPLE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)