-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
163 lines (134 loc) · 4.97 KB
/
Makefile
File metadata and controls
163 lines (134 loc) · 4.97 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# MolVis - CUDA Molecular Visualization
# Makefile for Windows with MSVC and NVCC
#
# Usage:
# build.bat - Build the application (recommended)
# build.bat clean - Clean build artifacts
# build.bat run - Build and run
#
# Or from VS Developer Command Prompt:
# nmake
# nmake clean
# nmake run
#==============================================================================
# Configuration
#==============================================================================
APP_NAME = molvis
TARGET = $(APP_NAME).exe
# Compilers
CXX = cl
NVCC = nvcc
# Directories
SRC_DIR = src
BUILD_DIR = build
IMGUI_DIR = third_party/imgui
LEGACY_DIR = legacy
# CUDA paths
CUDA_INC = $(CUDA_PATH)/include
CUDA_LIB = $(CUDA_PATH)/lib/x64
#==============================================================================
# Compiler Flags
#==============================================================================
# MSVC flags
CXXFLAGS = /nologo /W3 /O2 /EHsc /std:c++17 /D_CRT_SECURE_NO_WARNINGS
# NVCC flags (sm_86 = RTX 3080, adjust for your GPU)
NVCCFLAGS = -O3 -arch=sm_86 -allow-unsupported-compiler
# Include paths
INCLUDES = /I. /I$(SRC_DIR) /Iinclude /I$(IMGUI_DIR) /I$(IMGUI_DIR)/backends /I"$(CUDA_INC)"
CUDA_INC_FLAGS = -I. -I$(SRC_DIR) -Iinclude -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
# Libraries
LIBS = user32.lib gdi32.lib d3d11.lib dxgi.lib d3dcompiler.lib cudart.lib
LIB_PATHS = /LIBPATH:"$(CUDA_LIB)"
#==============================================================================
# Source Files
#==============================================================================
# Application sources
APP_SOURCES = \
$(SRC_DIR)/gui/main_windows.cpp \
$(SRC_DIR)/molecule/molecule_db.cpp
# CUDA sources
CUDA_SOURCES = $(SRC_DIR)/renderer/cuda_renderer.cu
# Dear ImGui sources
IMGUI_SOURCES = \
$(IMGUI_DIR)/imgui.cpp \
$(IMGUI_DIR)/imgui_draw.cpp \
$(IMGUI_DIR)/imgui_tables.cpp \
$(IMGUI_DIR)/imgui_widgets.cpp \
$(IMGUI_DIR)/backends/imgui_impl_win32.cpp \
$(IMGUI_DIR)/backends/imgui_impl_dx11.cpp
# Object files
CUDA_OBJ = $(BUILD_DIR)/cuda_renderer.obj
RES_OBJ = $(BUILD_DIR)/resource.res
#==============================================================================
# Build Targets
#==============================================================================
.PHONY: all clean run legacy help dirs
all: dirs $(TARGET)
@echo.
@echo ========================================
@echo MolVis built successfully!
@echo Run with: $(TARGET)
@echo ========================================
dirs:
@if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
# Compile CUDA sources
$(CUDA_OBJ): $(CUDA_SOURCES)
$(NVCC) $(NVCCFLAGS) $(CUDA_INC_FLAGS) -c $** -o $@
# Compile Windows resource file (for app icon)
$(RES_OBJ): resource.rc
rc /nologo /fo $@ $**
# Link everything
$(TARGET): $(CUDA_OBJ) $(RES_OBJ) $(APP_SOURCES) $(IMGUI_SOURCES)
$(CXX) $(CXXFLAGS) $(INCLUDES) /Fe:$@ /Fo:$(BUILD_DIR)/ \
$(APP_SOURCES) $(IMGUI_SOURCES) $(CUDA_OBJ) \
/link $(LIB_PATHS) $(LIBS) $(RES_OBJ)
run: all
@echo Starting MolVis...
@$(TARGET)
#==============================================================================
# Legacy Build (original CUDA-only version)
#==============================================================================
legacy: $(LEGACY_DIR)/cuda_molecule.cu $(LEGACY_DIR)/win32_display.h
$(NVCC) $(NVCCFLAGS) -o $(LEGACY_DIR)/molvis_legacy.exe \
$(LEGACY_DIR)/cuda_molecule.cu gdi32.lib user32.lib
@echo Built: $(LEGACY_DIR)/molvis_legacy.exe
#==============================================================================
# Clean
#==============================================================================
clean:
@echo Cleaning build artifacts...
@if exist $(TARGET) del /Q $(TARGET)
@if exist $(BUILD_DIR)\*.obj del /Q $(BUILD_DIR)\*.obj
@if exist $(BUILD_DIR)\*.res del /Q $(BUILD_DIR)\*.res
@if exist *.obj del /Q *.obj
@if exist *.exp del /Q *.exp
@if exist *.lib del /Q *.lib
@if exist *.pdb del /Q *.pdb
@if exist *.ilk del /Q *.ilk
@if exist imgui.ini del /Q imgui.ini
@echo Done.
#==============================================================================
# Help
#==============================================================================
help:
@echo.
@echo MolVis Build System
@echo ========================================
@echo.
@echo Targets:
@echo all Build the application (default)
@echo run Build and run
@echo clean Remove build artifacts
@echo legacy Build original CUDA-only version
@echo help Show this message
@echo.
@echo Configuration:
@echo GPU: sm_86 (RTX 3080)
@echo Compiler: MSVC + NVCC
@echo.
@echo Requirements:
@echo - Visual Studio with C++ workload
@echo - NVIDIA CUDA Toolkit
@echo - Run from VS Developer Command Prompt
@echo or use build.bat
@echo.