-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
36 lines (25 loc) · 995 Bytes
/
Copy pathCMakeLists.txt
File metadata and controls
36 lines (25 loc) · 995 Bytes
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
cmake_minimum_required(VERSION 3.16)
project(sdlProject)
# Set the c++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Find SDL2 package
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
# Build directory packages
set(SDL2_TTF_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/vendored/SDL2_ttf-2.24.0")
set(SDL2_TTF_LIBRARY "${CMAKE_SOURCE_DIR}/build/SDL2_ttf/libSDL2_ttf.dylib")
# Add source files
file(GLOB SOURCES "*.cpp" "src/*.cpp")
# print sources
message(STATUS "source files: ${SOURCES}")
# Create executable
add_executable(${PROJECT_NAME} ${SOURCES})
# Include SDL2 headers
# includes sdl2 header files to the list of include paths
# similar g++ -I /usr/include/SDL2 -c main.cpp
# Modern target_include_directories()
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_TTF_INCLUDE_DIRS})
# Link SD2 library
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2 SDL2_image::SDL2_image ${SDL2_TTF_LIBRARY})