game/mario/CMakeLists.txt
2021-08-07 21:41:15 +02:00

92 lines
2.2 KiB
CMake

cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
enable_language(CXX)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
project(Mario)
if(APPLE)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()
list(APPEND CommonFiles
global_vars.cpp
sprites.cpp
maploader.cpp
mapobject.cpp
blocks/simpleblocks.cpp
mario.cpp
blocks.cpp
)
list(APPEND SDLLibs
sdlpp)
if(WIN32)
list(APPEND CommonFiles
../sdlpp/SDL2/SDL2_framerate.c
../sdlpp/SDL2/SDL2_gfxPrimitives.c
../sdlpp/SDL2/SDL2_imageFilter.c
../sdlpp/SDL2/SDL2_rotozoom.c
)
add_library(SDL2_m STATIC IMPORTED)
set_target_properties(SDL2_m PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../sdlpp/SDL2.lib)
add_library(SDL2_ttf_m STATIC IMPORTED)
set_target_properties(SDL2_ttf_m PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../sdlpp/SDL2_ttf.lib)
add_library(SDL2_image_m STATIC IMPORTED)
set_target_properties(SDL2_image_m PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../sdlpp/SDL2_image.lib)
add_executable(mario WIN32)
add_executable(editor WIN32)
list(APPEND SDLLibs
SDL2_m
SDL2_image_m
SDL2_ttf_m
)
else()
add_executable(mario)
add_executable(editor)
list(APPEND SDLLibs
SDL2
SDL2_image
SDL2_ttf
SDL2_gfx
)
endif()
add_subdirectory(../sdlpp sdlpp)
target_sources(mario
PRIVATE ${CommonFiles}
PRIVATE main.cpp
PRIVATE visitors/mario_visitor.cpp
PRIVATE visitors/mushroom_visitor.cpp
PRIVATE visitors/bounce_visitor.cpp
PRIVATE visitors/visitor_generator.cpp
PRIVATE blocks/coinblock.cpp
PRIVATE blocks/mushroomblock.cpp
)
target_sources(editor
PRIVATE ${CommonFiles}
PRIVATE blocks/coineditorblock.cpp
PRIVATE editor.cpp
PRIVATE edit_box.cpp
PRIVATE tool_box.cpp
PRIVATE editor_visitor.cpp
)
target_compile_definitions(editor PUBLIC EDITOR)
target_link_libraries(mario PRIVATE ${SDLLibs} Threads::Threads)
target_link_libraries(editor PRIVATE ${SDLLibs} Threads::Threads)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/testfont.ttf ${CMAKE_CURRENT_SOURCE_DIR}/sprites DESTINATION ${CMAKE_CURRENT_BINARY_DIR})