-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
51 lines (36 loc) · 1.46 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
cmake_minimum_required(VERSION 2.8.13)
# TODO: make the build process work with non-Clang compilers
# TODO: make debug mode work on Fedora
project(DungeonDave)
# So that editors can use info generated by CMake.
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
########## Setting the C standard, warning flags, and debug/release flags.
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_C_FLAGS "-Wall -Wextra -Wpedantic -Wformat -Wfloat-conversion -Wdouble-promotion -Wsign-conversion -Wincompatible-pointer-types")
set(CMAKE_C_FLAGS_DEBUG "-g -fsanitize=address,undefined,float-divide-by-zero,signed-integer-overflow")
set(CMAKE_C_FLAGS_RELEASE "-Ofast") # Note: including `-fno-fast-math` here can help with avoiding some floating-point errors.
set(TARGET_NAME dungeon_dave)
########## Declaring SDL2 as a package, and other standard CMake boilerplate.
find_package(SDL2 REQUIRED)
file(GLOB_RECURSE SRC_FILES src/*.c lib/glad/glad.c)
add_executable(${TARGET_NAME} ${SRC_FILES})
target_include_directories(
${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/lib
${SDL2_INCLUDE_DIRS}
)
##########
if (APPLE)
set(LIBRARY_FILE_SUFFIX dylib)
else()
set(LIBRARY_FILE_SUFFIX so)
endif()
target_link_libraries(${TARGET_NAME}
m # This is the C math library
${CMAKE_CURRENT_SOURCE_DIR}/lib/cjson/libcjson.${LIBRARY_FILE_SUFFIX}
${CMAKE_CURRENT_SOURCE_DIR}/lib/openal/libopenal.${LIBRARY_FILE_SUFFIX}
${SDL2_LIBRARIES}
)
##########