-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
132 lines (110 loc) · 3.61 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
cmake_minimum_required(VERSION 3.18)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "" FORCE)
project(Hook
VERSION 0.1.1
LANGUAGES CXX OBJCXX
)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wformat")
if(APPLE)
set(CMAKE_INSTALL_PREFIX "/Applications")
endif()
find_package(Git REQUIRED)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/external/llvm-project/lldb/scripts/macos-setup-codesign.sh)
include(ExternalProject)
ExternalProject_Add(${PROJECT_NAME}-llvm
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/llvm-project/llvm
BINARY_DIR ${PROJECT_BINARY_DIR}/lldb-build
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-G Ninja
-DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.app/Contents/Frameworks
-C ${CMAKE_CURRENT_SOURCE_DIR}/cmake/standalone.cmake
${CMAKE_CURRENT_SOURCE_DIR}/external/llvm-project/llvm
BUILD_COMMAND ninja
-C ${PROJECT_BINARY_DIR}/lldb-build
lldb
debugserver
# darwin-debug
INSTALL_COMMAND ninja
-C ${PROJECT_BINARY_DIR}/lldb-build
#install-lldb
install-debugserver
install-liblldb
#install-darwin-debug
TEST_COMMAND ""
)
add_subdirectory(external/glfw)
set(CPP_SOURCES
src/main.cpp
external/imgui/imgui.cpp
external/imgui/misc/cpp/imgui_stdlib.cpp
external/imgui/imgui_draw.cpp
external/imgui/imgui_tables.cpp
external/imgui/imgui_widgets.cpp
external/imgui/backends/imgui_impl_glfw.cpp
)
set(OBJC_SOURCES
external/imgui/backends/imgui_impl_metal.mm
src/backend.cpp
)
set(APP_ICON_MACOSX resources/icons/hook.icns)
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources"
)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE
${CPP_SOURCES}
${OBJC_SOURCES}
${APP_ICON_MACOSX}
)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_ICON_FILE hook.icns
)
configure_file(src/config.h.in config.h)
target_include_directories(${PROJECT_NAME}
PUBLIC ${PROJECT_BINARY_DIR}
PUBLIC external/glfw/include
PUBLIC external/imgui
PUBLIC external/imgui/backends
PUBLIC external/imgui/misc/cpp
PUBLIC external/llvm-project/lldb/include
PUBLIC src
)
target_link_directories(${PROJECT_NAME}
PUBLIC ${PROJECT_BINARY_DIR}/lldb-build/lib
)
target_link_libraries(${PROJECT_NAME}
"lldb"
"glfw"
"-framework Metal"
"-framework MetalKit"
"-framework Cocoa"
"-framework IOKit"
"-framework CoreVideo"
"-framework QuartzCore"
"-framework Security"
)
set_source_files_properties(${OBJC_SOURCES} PROPERTIES
LANGUAGE OBJCXX
COMPILE_FLAGS "-x objective-c++"
)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change @rpath/liblldb.17.0.4.dylib @executable_path/../Frameworks/lib/liblldb.dylib $<TARGET_FILE:${PROJECT_NAME}>
)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION .
)