Skip to content

Commit

Permalink
[sdl] Refactor CMake build
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed Jun 30, 2024
1 parent 75a23e8 commit 63d8296
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions spine-sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 63d8296

Please sign in to comment.