118 lines
3.3 KiB
CMake
118 lines
3.3 KiB
CMake
# Copyright (c) 2021 Dominic Msters
|
|
#
|
|
# This software is released under the MIT License.
|
|
# https://opensource.org/licenses/MIT
|
|
|
|
#################################### CMAKE #####################################
|
|
cmake_minimum_required(VERSION 3.15)
|
|
set(CMAKE_C_STANDARD 99)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
#Include
|
|
include(FetchContent)
|
|
|
|
#Vars
|
|
set(DEPS_DIR "${PROJECT_BINARY_DIR}/_deps")
|
|
|
|
set(SDL2_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/SDL2)
|
|
|
|
################################## Settings ####################################
|
|
# Platform Settings
|
|
set(SETTING_PLATFORM_GLFW 1)
|
|
set(SETTING_PLATFORM_SDL 2)
|
|
set(SETTING_PLATFORM SETTING_PLATFORM_SDL)
|
|
|
|
set(SETTING_USE_GLAD 1)
|
|
|
|
# Game Settings
|
|
set(SETTING_GAME_POKER 1)
|
|
set(SETTING_GAME_DAWN 2)
|
|
set(SETTING_GAME SETTING_GAME_POKER)
|
|
|
|
set(SETTING_GAME_NAME "DawnGame")
|
|
|
|
# Configuring
|
|
configure_file(config.h.in config.h)
|
|
|
|
#################################### PROJECT ###################################
|
|
project(${SETTING_GAME_NAME} VERSION 1.0)
|
|
|
|
##################################### SRCS #####################################
|
|
file(GLOB_RECURSE SOURCE_FILES ${CMAKE_SOURCE_DIR}/src/*.c)
|
|
file(GLOB_RECURSE HEADER_FILES ${CMAKE_SOURCE_DIR}/src/*.h)
|
|
|
|
# GLFW Sources
|
|
if(${SETTING_PLATFORM} EQUAL ${SETTING_PLATFORM_GLFW})
|
|
file(GLOB_RECURSE SRC ${CMAKE_SOURCE_DIR}/platform/glfw/*.c)
|
|
file(GLOB_RECURSE HDRS ${CMAKE_SOURCE_DIR}/platform/glfw/*.h)
|
|
list(APPEND SOURCE_FILES ${SRC})
|
|
list(APPEND HEADER_FILES ${HDRS})
|
|
endif()
|
|
|
|
# SDL Sources
|
|
if(${SETTING_PLATFORM} EQUAL ${SETTING_PLATFORM_SDL})
|
|
file(GLOB_RECURSE SRC ${CMAKE_SOURCE_DIR}/platform/sdl/*.c)
|
|
file(GLOB_RECURSE HDRS ${CMAKE_SOURCE_DIR}/platform/sdl/*.h)
|
|
list(APPEND SOURCE_FILES ${SRC})
|
|
list(APPEND HEADER_FILES ${HDRS})
|
|
endif()
|
|
|
|
file(COPY ${CMAKE_CURRENT_LIST_DIR}/assets DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
##################################### LIBS #####################################
|
|
include_directories(${CMAKE_SOURCE_DIR}/lib/stb)
|
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
################################## EXECUTABLE ##################################
|
|
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
|
|
|
|
################################# STATIC LIBS ##################################
|
|
|
|
# Math
|
|
if(NOT WIN32)
|
|
target_link_libraries(${PROJECT_NAME} m)
|
|
endif()
|
|
|
|
# GLAD
|
|
if(${SETTING_USE_GLAD} EQUAL 1)
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/lib/glad)
|
|
target_link_libraries(${PROJECT_NAME} glad)
|
|
endif()
|
|
|
|
# GLFW and GLAD
|
|
if(${SETTING_PLATFORM} EQUAL ${SETTING_PLATFORM_GLFW})
|
|
if(NOT glfw3_FOUND)
|
|
FetchContent_Declare(
|
|
glfw
|
|
GIT_REPOSITORY https://github.com/glfw/glfw
|
|
GIT_TAG 3.3.4
|
|
)
|
|
FetchContent_MakeAvailable(glfw)
|
|
endif()
|
|
target_link_libraries(${PROJECT_NAME} glfw)
|
|
endif()
|
|
|
|
# SDL
|
|
if(${SETTING_PLATFORM} EQUAL ${SETTING_PLATFORM_SDL})
|
|
# add_subdirectory(${CMAKE_SOURCE_DIR}/lib/glad)
|
|
# target_link_libraries(${PROJECT_NAME} glad)
|
|
find_package(SDL2 REQUIRED)
|
|
include_directories(${SDL2_INCLUDE_DIRS})
|
|
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES})
|
|
endif()
|
|
|
|
# CGLM
|
|
if(NOT cglm_FOUND)
|
|
FetchContent_Declare(
|
|
cglm
|
|
GIT_REPOSITORY https://github.com/recp/cglm
|
|
GIT_TAG v0.8.3
|
|
)
|
|
FetchContent_MakeAvailable(cglm)
|
|
endif()
|
|
target_link_libraries(${PROJECT_NAME} cglm)
|
|
|
|
# OpenGL
|
|
find_package(OpenGL REQUIRED)
|
|
target_link_libraries(${PROJECT_NAME} OpenGL::GL) |