-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
120 lines (99 loc) · 3.36 KB
/
CMakeLists.txt
File metadata and controls
120 lines (99 loc) · 3.36 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
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
cmake_minimum_required(VERSION 3.10)
project(Mann_NeuralNetwork VERSION 1.0 LANGUAGES CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=address")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -fsanitize=address")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_ARCHITECTURES "arm64")
# Include directories
include_directories(src dependencies/includes/GLFW dependencies/includes/imgui dependencies/includes/metal-cpp .)
# Source files
# all .cpp files in src/ except for those starting with test_
file(GLOB_RECURSE SOURCES
"src/*.cpp"
"src/*.mm"
)
list(FILTER SOURCES EXCLUDE REGEX "src/test_.*\\.cpp$")
list(FILTER SOURCES EXCLUDE REGEX "src/platforms/MAC/.*")
list(FILTER SOURCES EXCLUDE REGEX "src/platforms/WINDOWS/.*")
if(APPLE)
file(GLOB PLATFORM_SOURCES "src/platforms/MAC/*.cpp")
endif()
if(WIN32)
file(GLOB PLATFORM_SOURCES "src/platforms/WINDOWS/*.cpp")
endif()
set_source_files_properties(src/SystemProfiler.mm PROPERTIES
COMPILE_FLAGS "-ObjC++"
)
set(IMGUI_SOURCES
dependencies/includes/imgui/imgui.cpp
dependencies/includes/imgui/imgui_demo.cpp
dependencies/includes/imgui/imgui_draw.cpp
dependencies/includes/imgui/imgui_tables.cpp
dependencies/includes/imgui/imgui_widgets.cpp
dependencies/includes/imgui/backends/imgui_impl_glfw.cpp
dependencies/includes/imgui/backends/imgui_impl_opengl3.cpp
)
set(IMPLOT_SOURCES # Renamed to IMPLOT_SOURCES for clarity (was IMPLOT, which was a variable name)
dependencies/includes/implot/implot.cpp
dependencies/includes/implot/implot_items.cpp
)
# Find required packages
find_package(OpenGL REQUIRED)
if(APPLE)
# On macOS, assume GLFW is installed (e.g., via Homebrew)
#link metal cpp
find_package(glfw3 3.3 REQUIRED)
elseif(WIN32)
# On Windows, try to find glfw3 normally
find_package(glfw3 3.3 QUIET)
if(NOT glfw3_FOUND)
message(STATUS "glfw3 not found, fetching GLFW via FetchContent")
include(FetchContent)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.3.8
)
FetchContent_MakeAvailable(glfw)
endif()
else()
# On Linux or other platforms, try to find glfw3 normally
find_package(glfw3 3.3 REQUIRED)
endif()
add_executable(NN
${SOURCES}
${PLATFORM_SOURCES}
${IMGUI_SOURCES}
${IMPLOT_SOURCES}
)
if(WIN32 AND NOT glfw3_FOUND)
# Link to the FetchContent glfw target
target_link_libraries(NN PRIVATE glfw opengl32 dxgi pdh)
endif()
# macOS Metal support
if(APPLE)
target_link_libraries(NN PRIVATE OpenGL::GL "glfw"
"-framework Metal"
"-framework Foundation"
"-framework MetalKit"
"-framework QuartzCore"
)
endif()
# Linux NVML
if(UNIX AND NOT APPLE)
find_library(NVML_LIB nvidia-ml)
if(NVML_LIB)
target_link_libraries(NN PRIVATE ${NVML_LIB})
else()
message(WARNING "NVML not found. GPU monitoring disabled.")
endif()
endif()