Make cmake work on windows

This commit is contained in:
zv0n 2021-08-05 19:16:12 +02:00
parent 8e566ddb03
commit d267402ec5
2 changed files with 77 additions and 19 deletions

View File

@ -19,29 +19,66 @@ list(APPEND CommonFiles
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)
add_executable(mario
${CommonFiles}
main.cpp
visitors/mario_visitor.cpp
visitors/bounce_visitor.cpp
visitors/visitor_generator.cpp
blocks/coinblock.cpp
target_sources(mario
PRIVATE ${CommonFiles}
PRIVATE main.cpp
PRIVATE visitors/mario_visitor.cpp
PRIVATE visitors/bounce_visitor.cpp
PRIVATE visitors/visitor_generator.cpp
PRIVATE blocks/coinblock.cpp
)
add_executable(editor
${CommonFiles}
blocks/coineditorblock.cpp
editor.cpp
edit_box.cpp
tool_box.cpp
editor_visitor.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 sdlpp SDL2 SDL2_image SDL2_gfx SDL2_ttf Threads::Threads)
target_link_libraries(editor PRIVATE sdlpp SDL2 SDL2_image SDL2_gfx SDL2_ttf Threads::Threads)
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})

View File

@ -5,7 +5,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(libsdlpp)
add_library(sdlpp STATIC
list(APPEND SDLPPFiles
sdlpp_circlecolider.cpp
sdlpp_circlerenderer.cpp
sdlpp_collision.cpp
@ -23,3 +23,24 @@ add_library(sdlpp STATIC
sdlpp_fontconfiguration.cpp
sdlpp_mouse.cpp
)
if(WIN32)
add_library(sdlpp SHARED
${SDLPPFiles}
)
add_library(SDL2 STATIC IMPORTED)
set_target_properties(SDL2 PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/SDL2.lib)
add_library(SDL2_ttf STATIC IMPORTED)
set_target_properties(SDL2_ttf PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/SDL2_ttf.lib)
add_library(SDL2_image STATIC IMPORTED)
set_target_properties(SDL2_image PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/SDL2_image.lib)
target_link_libraries(sdlpp SDL2 SDL2_ttf SDL2_image)
target_compile_definitions(sdlpp PUBLIC DLLEXPORT)
else()
add_library(sdlpp STATIC
${SDLPPFiles}
)
endif()