|
@@ -4,109 +4,50 @@ project(spine-sfml)
|
|
|
# Default flags
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/../../flags.cmake)
|
|
|
|
|
|
-#
|
|
|
-# First download and extract SFML 2.6.1 for the respective OS we are on
|
|
|
-#
|
|
|
-set(DEPS_DIR "${CMAKE_CURRENT_LIST_DIR}/dependencies/")
|
|
|
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
- set(CMAKE_OSX_ARCHITECTURES x86_64)
|
|
|
- set(ONLY_ACTIVE_ARCH NO)
|
|
|
- set(SFML_URL "https://www.sfml-dev.org/files/SFML-2.6.1-macOS-clang-64-bit.tar.gz")
|
|
|
- set(SFML_DIR ${DEPS_DIR}/SFML-2.6.1-macOS-clang-64-bit)
|
|
|
- if (NOT EXISTS "${SFML_DIR}")
|
|
|
- message("Downloading SFML for Mac OS X")
|
|
|
- file(DOWNLOAD "${SFML_URL}" "${DEPS_DIR}/sfml.tar.gz")
|
|
|
- execute_process(
|
|
|
- COMMAND ${CMAKE_COMMAND} -E tar xzf ${DEPS_DIR}/sfml.tar.gz
|
|
|
- WORKING_DIRECTORY ${DEPS_DIR}
|
|
|
- )
|
|
|
- # copy freetype over to Frameworks/ so rpath resolution works
|
|
|
- execute_process(
|
|
|
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${SFML_DIR}/extlibs/freetype.framework ${SFML_DIR}/Frameworks/freetype.framework
|
|
|
- WORKING_DIRECTORY ${SFML_DIR}
|
|
|
- )
|
|
|
- endif()
|
|
|
-elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
- set(SFML_URL "https://www.sfml-dev.org/files/SFML-2.5.1-linux-gcc-64-bit.tar.gz")
|
|
|
- set(SFML_DIR ${DEPS_DIR}/SFML-2.5.1)
|
|
|
- if (NOT EXISTS ${SFML_DIR})
|
|
|
- message("Downloading SFML for Linux 64-bit")
|
|
|
- file(DOWNLOAD "${SFML_URL}" "${DEPS_DIR}/sfml.tar.gz")
|
|
|
- execute_process(
|
|
|
- COMMAND ${CMAKE_COMMAND} -E tar xzf ${DEPS_DIR}/sfml.tar.gz
|
|
|
- WORKING_DIRECTORY ${DEPS_DIR}
|
|
|
- )
|
|
|
- endif()
|
|
|
-else()
|
|
|
- set(SFML_URL "https://www.sfml-dev.org/files/SFML-2.6.1-windows-vc17-64-bit.zip")
|
|
|
- set(SFML_DIR ${DEPS_DIR}/SFML-2.6.1)
|
|
|
- if (NOT EXISTS ${SFML_DIR})
|
|
|
- message("Downloading SFML for Windows 64-bit")
|
|
|
- file(DOWNLOAD "${SFML_URL}" "${DEPS_DIR}/sfml.zip")
|
|
|
- execute_process(
|
|
|
- COMMAND ${CMAKE_COMMAND} -E tar x ${DEPS_DIR}/sfml.zip
|
|
|
- WORKING_DIRECTORY ${DEPS_DIR}
|
|
|
- )
|
|
|
- endif()
|
|
|
-endif()
|
|
|
+# SFML
|
|
|
+include(FetchContent)
|
|
|
+FetchContent_Declare(SFML GIT_REPOSITORY https://github.com/SFML/SFML GIT_TAG 2.6.1)
|
|
|
+set(FETCHCONTENT_QUIET NO)
|
|
|
+FetchContent_MakeAvailable(SFML)
|
|
|
|
|
|
# Add spine-cpp
|
|
|
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../spine-cpp ${CMAKE_BINARY_DIR}/spine-cpp-build)
|
|
|
|
|
|
# Define spine-sfml-cpp library
|
|
|
-include_directories(src ${SFML_DIR}/include)
|
|
|
-file(GLOB INCLUDES "src/**/*.h")
|
|
|
-file(GLOB SOURCES "src/**/*.cpp")
|
|
|
+include_directories(${CMAKE_CURRENT_LIST_DIR}/src ${SFML_SOURCE_DIR}/include)
|
|
|
+file(GLOB INCLUDES "${CMAKE_CURRENT_LIST_DIR}/src/**/*.h")
|
|
|
+file(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/**/*.cpp")
|
|
|
add_library(spine-sfml-cpp STATIC ${SOURCES} ${INCLUDES})
|
|
|
-target_link_libraries(spine-sfml-cpp LINK_PUBLIC spine-cpp)
|
|
|
-install(TARGETS spine-sfml-cpp DESTINATION dist/lib)
|
|
|
-install(FILES ${INCLUDES} DESTINATION dist/include)
|
|
|
+target_link_libraries(spine-sfml-cpp LINK_PUBLIC spine-cpp sfml-graphics sfml-window sfml-system)
|
|
|
|
|
|
# Define spine-sfml example executable
|
|
|
-add_executable(spine-sfml-cpp-example example/main.cpp)
|
|
|
-target_link_libraries(spine-sfml-cpp-example spine-cpp spine-sfml-cpp)
|
|
|
+add_executable(spine-sfml-cpp-example ${CMAKE_CURRENT_LIST_DIR}/example/main.cpp)
|
|
|
+target_link_libraries(spine-sfml-cpp-example spine-cpp spine-sfml-cpp sfml-graphics sfml-window sfml-system)
|
|
|
|
|
|
# Define spine-sfml testbed executable
|
|
|
-add_executable(spine-sfml-cpp-testbed example/testbed.cpp)
|
|
|
-target_link_libraries(spine-sfml-cpp-testbed spine-cpp spine-sfml-cpp)
|
|
|
+add_executable(spine-sfml-cpp-testbed ${CMAKE_CURRENT_LIST_DIR}/example/testbed.cpp)
|
|
|
+target_link_libraries(spine-sfml-cpp-testbed spine-cpp spine-sfml-cpp sfml-graphics sfml-window sfml-system)
|
|
|
|
|
|
-# Link in SFML libraries and OS dependencies like OpenGL
|
|
|
+# Link in OS dependencies like OpenGL
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
- find_library(SFML SFML PATHS ${SFML_DIR}/Frameworks)
|
|
|
- find_library(SFML_SYSTEM "sfml-system" PATHS ${SFML_DIR}/Frameworks)
|
|
|
- find_library(SFML_WINDOW sfml-window PATHS ${SFML_DIR}/Frameworks)
|
|
|
- find_library(SFML_GRAPHICS sfml-graphics PATHS ${SFML_DIR}/Frameworks)
|
|
|
- target_link_libraries(spine-sfml-cpp-example ${SFML} ${SFML_SYSTEM} ${SFML_WINDOW} ${SFML_GRAPHICS})
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed ${SFML} ${SFML_SYSTEM} ${SFML_WINDOW} ${SFML_GRAPHICS})
|
|
|
+ find_library(COCOA_FRAMEWORK Cocoa)
|
|
|
+ find_library(OPENGL_FRAMEWORK OpenGL)
|
|
|
+ target_link_libraries(spine-sfml-cpp-example ${COCOA_FRAMEWORK} ${OPENGL_FRAMEWORK})
|
|
|
+ target_link_libraries(spine-sfml-cpp-testbed ${COCOA_FRAMEWORK} ${OPENGL_FRAMEWORK})
|
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
- target_link_libraries(spine-sfml-cpp-example sfml-graphics sfml-window sfml-system)
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed sfml-graphics sfml-window sfml-system)
|
|
|
+ target_link_libraries(spine-sfml-cpp-example GL)
|
|
|
+ target_link_libraries(spine-sfml-cpp-testbed GL)
|
|
|
else()
|
|
|
- set(SFML_LIBS ${SFML_DIR}/lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-example ${SFML_LIBS}/sfml-main-d.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-example ${SFML_LIBS}/sfml-graphics-s-d.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-example ${SFML_LIBS}/sfml-window-s-d.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-example ${SFML_LIBS}/sfml-system-s-d.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-example ${SFML_LIBS}/freetype.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-example opengl32)
|
|
|
- target_link_libraries(spine-sfml-cpp-example gdi32)
|
|
|
- target_link_libraries(spine-sfml-cpp-example winmm)
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed ${SFML_LIBS}/sfml-main-d.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed ${SFML_LIBS}/sfml-graphics-s-d.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed ${SFML_LIBS}/sfml-window-s-d.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed ${SFML_LIBS}/sfml-system-s-d.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed ${SFML_LIBS}/freetype.lib)
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed opengl32)
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed gdi32)
|
|
|
- target_link_libraries(spine-sfml-cpp-testbed winmm)
|
|
|
+ target_link_libraries(spine-sfml-cpp-example opengl32 gdi32 winmm)
|
|
|
+ target_link_libraries(spine-sfml-cpp-testbed opengl32 gdi32 winmm)
|
|
|
add_definitions(-DSFML_STATIC)
|
|
|
endif()
|
|
|
|
|
|
-# copy data to build directory
|
|
|
+# Copy data to build directory
|
|
|
add_custom_command(TARGET spine-sfml-cpp-example
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
|
${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sfml-cpp-example>/data)
|
|
|
|
|
|
add_custom_command(TARGET spine-sfml-cpp-testbed
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
|
- ${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sfml-cpp-example>/data)
|
|
|
+ ${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sfml-cpp-testbed>/data)
|