102 lines
2.5 KiB
CMake
102 lines
2.5 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
|
|
gui/gui.cpp
|
|
)
|
|
|
|
list(APPEND SDLLibs
|
|
sdlpp)
|
|
|
|
if(WIN32)
|
|
list(APPEND CommonFiles
|
|
filesystem/windows/filesystem.cpp)
|
|
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()
|
|
list(APPEND CommonFiles
|
|
filesystem/unix/filesystem.cpp)
|
|
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/goomba_visitor.cpp
|
|
PRIVATE visitors/bounce_visitor.cpp
|
|
PRIVATE visitors/visitor_generator.cpp
|
|
PRIVATE blocks/coinblock.cpp
|
|
PRIVATE blocks/mushroomblock.cpp
|
|
PRIVATE blocks/goombablock.cpp
|
|
)
|
|
|
|
target_sources(editor
|
|
PRIVATE ${CommonFiles}
|
|
PRIVATE blocks/coineditorblock.cpp
|
|
PRIVATE blocks/goombablock.cpp
|
|
PRIVATE editor.cpp
|
|
PRIVATE edit_box.cpp
|
|
PRIVATE tool_box.cpp
|
|
PRIVATE editor_visitor.cpp
|
|
PRIVATE scenes/editor_main.cpp
|
|
PRIVATE scenes/editor_main_menu.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})
|