From 63d829682e771a6b83db7039778a35afb41e2dff Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 30 Jun 2024 20:53:28 +0200 Subject: [PATCH] [sdl] Refactor CMake build --- spine-sdl/CMakeLists.txt | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/spine-sdl/CMakeLists.txt b/spine-sdl/CMakeLists.txt index 7e2b67b034..45ebb7502d 100644 --- a/spine-sdl/CMakeLists.txt +++ b/spine-sdl/CMakeLists.txt @@ -1,34 +1,38 @@ -if(MSVC) - message("MSCV detected") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS") -else() - message("${CMAKE_C_FLAGS}") - message("${CMAKE_CXX_FLAGS}") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -std=c99") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -pedantic -Wno-unused-parameter -std=c++11 -fno-exceptions -fno-rtti") -endif() +cmake_minimum_required(VERSION 3.10) +project(spine-glfw) +# Default flags +include(${CMAKE_SOURCE_DIR}/../flags.cmake) + +# Add spine-cpp and spine-c +add_subdirectory(${CMAKE_SOURCE_DIR}/../spine-cpp ${CMAKE_BINARY_DIR}/spine-cpp-build) +add_subdirectory(${CMAKE_SOURCE_DIR}/../spine-c ${CMAKE_BINARY_DIR}/spine-c) + +# SDL include(FetchContent) FetchContent_Declare(SDL GIT_REPOSITORY https://github.com/libsdl-org/SDL GIT_TAG release-2.30.2) FetchContent_MakeAvailable(SDL) include_directories(src) +# spine-sdl-c library add_library(spine-sdl-c STATIC src/spine-sdl-c.c src/spine-sdl-c.h src/stb_image.h) target_link_libraries(spine-sdl-c LINK_PUBLIC SDL2-static spine-c) install(TARGETS spine-sdl-c DESTINATION dist/lib) install(FILES src/spine-sdl-c.h src/stb_image.h DESTINATION dist/include) +# spine-sdl-cpp library add_library(spine-sdl-cpp STATIC src/spine-sdl-cpp.cpp src/spine-sdl-cpp.h src/stb_image.h) target_link_libraries(spine-sdl-cpp LINK_PUBLIC SDL2-static spine-cpp) install(TARGETS spine-sdl-cpp DESTINATION dist/lib) install(FILES src/spine-sdl-cpp.h src/stb_image.h DESTINATION dist/include) +# Example (spine-sdl-c) add_executable(spine-sdl-c-example example/main.c) target_link_libraries(spine-sdl-c-example SDL2-static spine-sdl-c) set_property(TARGET spine-sdl-c-example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/spine-sdl") +# Example (spine-sdl-cpp) add_executable(spine-sdl-cpp-example example/main.cpp) target_link_libraries(spine-sdl-cpp-example SDL2-static spine-sdl-cpp) set_property(TARGET spine-sdl-cpp-example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/spine-sdl")