-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
77 lines (65 loc) · 2.66 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
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
#Sample CMakeLists to build SDL project written by Quang N Le
cmake_minimum_required(VERSION 3.0.0)
project(sdl_demo VERSION 0.1.0 LANGUAGES C CXX)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14) # Default to C++14
endif()
set(CMAKE_BUILD_TYPE "Release")
# set(CMAKE_CXX_FLAGS "-std=c++14")
set(CMAKE_CXX_FLAGS_RELEASE "-O0 -Wall -Wextra -Wpedantic -g")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Needed so that cmake uses our find modules.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
#find all essential packages
find_package(SDL2 REQUIRED)
find_package(SDL2_net REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_gfx REQUIRED)
find_package(SDL2_ttf REQUIRED)
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${project_SOURCE_DIR}/cmake")
include_directories(
include
${SDL2_INCLUDE_DIRS}
${SDL2_IMAGE_INCLUDE_DIR}
${SDL2_TTF_INCLUDE_DIR}
)
#Custom libraries
set(lib_names SDL2_First_Graphics)
add_library(SDL2_First_Graphics SHARED lib/mainClassSampleLib.cpp) #do not need header files in include
#Add sub-modules
# add_subdirectory(src/modules)
#Setting sources code and executable names
set(SDL_PROJECT_SOURCES
# src/health_bar_animation.cpp
src/mainClassSample.cpp
# src/image_fetch_sample.cpp
# src/testSoundBasics.cpp
# lib/mainClassSampleLib.cpp
)
set(EXECUTABLE sdl_demo)
#add main executable
add_executable(${EXECUTABLE} ${SDL_PROJECT_SOURCES})
target_link_libraries(${EXECUTABLE} PUBLIC
# ${SDL2_LIBRARIES}
${lib_names} # ORDER MATTERS !!!
SDL2::Main SDL2::Image
GL
SDL2::Net SDL2::Mixer SDL2::TTF SDL2::GFX
# ${SDL2_IMAGE_LIBRARIES}
# ${SDL2_TTF_LIBRARIES}
)
target_include_directories(${EXECUTABLE} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
# Individual linking for each separate file
# add_executable(health_bar_animation src/health_bar_animation.cpp)
# target_link_libraries(health_bar_animation PUBLIC SDL2::Main SDL2::Image GL)
# add_executable(mainClassSample src/mainClassSample.cpp)
# target_link_libraries(mainClassSample PUBLIC SDL2::Main SDL2::Image GL ${lib_names})
# target_include_directories(mainClassSample PUBLIC
# ${CMAKE_CURRENT_SOURCE_DIR}/include
# )
#For testing purposes
enable_testing()
add_test(NAME ${EXECUTABLE} COMMAND ${EXECUTABLE})