-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
49 lines (34 loc) · 1.6 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
# Set the minimum version of CMake required
cmake_minimum_required(VERSION 3.20)
# Set your project name
project(SolarSystem)
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# --- Include Directories ---
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/external)
# --- Excutable Source Files ---
# Source + Imgui + glad.c
file(GLOB SOURCES "${CMAKE_SOURCE_DIR}/src/*.cpp")
file(GLOB IMGUI_SOURCES "${CMAKE_SOURCE_DIR}/external/imgui/*.cpp")
add_executable(${PROJECT_NAME} ${SOURCES} ${IMGUI_SOURCES} "${CMAKE_SOURCE_DIR}/src/glad.c")
# --- Library Linking ---
# GLFW + OpenGL + Assimp
target_link_libraries(${PROJECT_NAME} "/opt/homebrew/Cellar/glfw/3.4/lib/libglfw.3.4.dylib" "-framework OpenGL")
find_package(Assimp REQUIRED)
target_link_libraries(${PROJECT_NAME} ${ASSIMP_LIBRARIES})
# Set the output directory for executables
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
add_definitions(-Wno-deprecated-declarations)
# Check if the sanitizer option is enabled
option(ENABLE_SANITIZER "Enable AddressSanitizer" OFF)
if(ENABLE_SANITIZER)
# Add flags for AddressSanitizer
set(SANITIZE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZE_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZE_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SANITIZE_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZE_FLAGS}")
endif()