Skip to content
Snippets Groups Projects
Commit 1b5cf435 authored by David Hermann's avatar David Hermann
Browse files

Refactoring CMakeLists.txt

parent 5eaa5d36
No related branches found
No related tags found
1 merge request!1Refactoring CMakeLists.txt
......@@ -7,7 +7,8 @@ project(ADVANCED_WARS
LANGUAGES CXX
)
file(GLOB ADVANCED_WARS_SOURCES
# Quellen sammeln
file(GLOB_RECURSE ADVANCED_WARS_SOURCES
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/*.hpp"
)
......@@ -24,23 +25,69 @@ else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# CMake
# Ressourcen kopieren
set(ASSETS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/assets)
set(OUTPUT_ASSETS_DIR ${CMAKE_CURRENT_BINARY_DIR}/assets)
file(MAKE_DIRECTORY ${OUTPUT_ASSETS_DIR})
file(GLOB FONT_FILES ${ASSETS_DIR}/*.ttf)
# Executable erstellen
add_executable(advanced_wars ${ADVANCED_WARS_SOURCES})
foreach(FONT ${FONT_FILES})
add_custom_command(
TARGET advanced_wars PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${FONT} ${OUTPUT_ASSETS_DIR}
COMMENT "Kopiere Font: ${FONT} nach ${OUTPUT_ASSETS_DIR}"
)
endforeach()
set(CMAKE_MODULE_PATH ${ADVANCED_WARS_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH})
# SDL2
# Plattform-spezifische Konfiguration
if(APPLE)
# SDL2 Frameworks für macOS
set(SDL2_PATH "/Library/Frameworks")
set(CMAKE_OSX_ARCHITECTURES "arm64")
target_include_directories(
advanced_wars PRIVATE
${SDL2_PATH}/SDL2.framework/Headers
${SDL2_PATH}/SDL2_image.framework/Headers
${SDL2_PATH}/SDL2_ttf.framework/Headers
)
target_link_libraries(
advanced_wars PRIVATE
${SDL2_PATH}/SDL2.framework/SDL2
${SDL2_PATH}/SDL2_image.framework/SDL2_image
${SDL2_PATH}/SDL2_ttf.framework/SDL2_ttf
)
# Debug-Ausgaben
message(STATUS "Include Dir (SDL2): ${SDL2_PATH}/SDL2.framework/Headers")
message(STATUS "Include Dir (SDL2_image): ${SDL2_PATH}/SDL2_image.framework/Headers")
message(STATUS "Include Dir (SDL2_ttf): ${SDL2_PATH}/SDL2_ttf.framework/Headers")
else()
find_package(SDL2 REQUIRED)
find_package(SDL2_IMAGE REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(HDF5 REQUIRED COMPONENTS CXX)
include_directories(/usr/include/SDL2)
include_directories(${SDL2_INCLUDE_DIR})
include_directories(${SDL2_IMG_INCLUDE_DIR})
include_directories(${SDL2_TTF_INCLUDE_DIR})
include_directories(${HDF5_INCLUDE_DIRS})
# Executable erstellen
add_executable(advanced_wars src/main.cpp ${ADVANCED_WARS_SOURCES})
target_link_libraries(advanced_wars
${SDL2_LIBRARY}
${SDL2_IMG_LIBRARY}
${HDF5_LIBRARIES}
-lSDL2
-lSDL2_image
-lSDL2_ttf
m
)
endif()
# Locate SDL_ttf library
#
# This module defines:
#
# ::
#
# SDL2_TTF_LIBRARIES, the name of the library to link against
# SDL2_TTF_INCLUDE_DIRS, where to find the headers
# SDL2_TTF_FOUND, if false, do not try to link against
# SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL_ttf
#
#
#
# For backward compatibility the following variables are also set:
#
# ::
#
# SDLTTF_LIBRARY (same value as SDL2_TTF_LIBRARIES)
# SDLTTF_INCLUDE_DIR (same value as SDL2_TTF_INCLUDE_DIRS)
# SDLTTF_FOUND (same value as SDL2_TTF_FOUND)
#
#
#
# $SDLDIR is an environment variable that would correspond to the
# ./configure --prefix=$SDLDIR used in building SDL.
#
# Created by Eric Wing. This was influenced by the FindSDL.cmake
# module, but with modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
HINTS
ENV SDL2TTFDIR
ENV SDL2DIR
PATH_SUFFIXES SDL2
# path suffixes to search inside ENV{SDLDIR}
include/SDL2 include
PATHS ${SDL2_TTF_PATH}
)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VC_LIB_PATH_SUFFIX lib/x64)
else ()
set(VC_LIB_PATH_SUFFIX lib/x86)
endif ()
find_library(SDL2_TTF_LIBRARY
NAMES SDL2_ttf
HINTS
ENV SDL2TTFDIR
ENV SDL2DIR
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
PATHS ${SDL2_TTF_PATH}
)
if (SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h")
file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MAJOR "${SDL2_TTF_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MINOR "${SDL2_TTF_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_PATCH "${SDL2_TTF_VERSION_PATCH_LINE}")
set(SDL2_TTF_VERSION_STRING ${SDL2_TTF_VERSION_MAJOR}.${SDL2_TTF_VERSION_MINOR}.${SDL2_TTF_VERSION_PATCH})
unset(SDL2_TTF_VERSION_MAJOR_LINE)
unset(SDL2_TTF_VERSION_MINOR_LINE)
unset(SDL2_TTF_VERSION_PATCH_LINE)
unset(SDL2_TTF_VERSION_MAJOR)
unset(SDL2_TTF_VERSION_MINOR)
unset(SDL2_TTF_VERSION_PATCH)
endif ()
set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
VERSION_VAR SDL2_TTF_VERSION_STRING)
# for backward compatibility
set(SDLTTF_LIBRARY ${SDL2_TTF_LIBRARIES})
set(SDLTTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS})
set(SDLTTF_FOUND ${SDL2_TTF_FOUND})
\ No newline at end of file
#include "engine.hpp"
#include "SDL_render.h"
#include <SDL_render.h>
#include "scene.hpp"
#include "spritesheet.hpp"
#include "window.hpp"
......
#pragma once
#include "SDL_render.h"
#include <SDL_render.h>
#include "scene.hpp"
#include "spritesheet.hpp"
#include "window.hpp"
......
#include "spritesheet.hpp"
#include "SDL_render.h"
#include <SDL_render.h>
#include "SDL_surface.h"
#include "engine.hpp"
......
#pragma once
#include "SDL_render.h"
#include <SDL_render.h>
#include <SDL.h>
#include <string>
#include <vector>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment