CMakeLists.txt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. cmake_minimum_required(VERSION 3.10)
  2. project(spine-sfml)
  3. # Default flags
  4. include(${CMAKE_CURRENT_LIST_DIR}/../../flags.cmake)
  5. # SFML
  6. include(FetchContent)
  7. FetchContent_Declare(SFML GIT_REPOSITORY https://github.com/SFML/SFML GIT_TAG 2.6.1)
  8. set(FETCHCONTENT_QUIET NO)
  9. FetchContent_MakeAvailable(SFML)
  10. # Add spine-cpp
  11. add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../spine-cpp ${CMAKE_BINARY_DIR}/spine-cpp-build)
  12. # Define spine-sfml-cpp library
  13. include_directories(${CMAKE_CURRENT_LIST_DIR}/src ${SFML_SOURCE_DIR}/include)
  14. file(GLOB INCLUDES "${CMAKE_CURRENT_LIST_DIR}/src/**/*.h")
  15. file(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/**/*.cpp")
  16. add_library(spine-sfml-cpp STATIC ${SOURCES} ${INCLUDES})
  17. target_link_libraries(spine-sfml-cpp LINK_PUBLIC spine-cpp sfml-graphics sfml-window sfml-system)
  18. # Define spine-sfml example executable
  19. add_executable(spine-sfml-cpp-example ${CMAKE_CURRENT_LIST_DIR}/example/main.cpp)
  20. target_link_libraries(spine-sfml-cpp-example spine-cpp spine-sfml-cpp sfml-graphics sfml-window sfml-system)
  21. # Define spine-sfml testbed executable
  22. add_executable(spine-sfml-cpp-testbed ${CMAKE_CURRENT_LIST_DIR}/example/testbed.cpp)
  23. target_link_libraries(spine-sfml-cpp-testbed spine-cpp spine-sfml-cpp sfml-graphics sfml-window sfml-system)
  24. # Link in OS dependencies like OpenGL
  25. if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  26. find_library(COCOA_FRAMEWORK Cocoa)
  27. find_library(OPENGL_FRAMEWORK OpenGL)
  28. target_link_libraries(spine-sfml-cpp-example ${COCOA_FRAMEWORK} ${OPENGL_FRAMEWORK})
  29. target_link_libraries(spine-sfml-cpp-testbed ${COCOA_FRAMEWORK} ${OPENGL_FRAMEWORK})
  30. elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  31. target_link_libraries(spine-sfml-cpp-example GL)
  32. target_link_libraries(spine-sfml-cpp-testbed GL)
  33. else()
  34. target_link_libraries(spine-sfml-cpp-example opengl32 gdi32 winmm)
  35. target_link_libraries(spine-sfml-cpp-testbed opengl32 gdi32 winmm)
  36. add_definitions(-DSFML_STATIC)
  37. endif()
  38. # Copy data to build directory
  39. add_custom_command(TARGET spine-sfml-cpp-example
  40. COMMAND ${CMAKE_COMMAND} -E copy_directory
  41. ${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sfml-cpp-example>/data)
  42. add_custom_command(TARGET spine-sfml-cpp-testbed
  43. COMMAND ${CMAKE_COMMAND} -E copy_directory
  44. ${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sfml-cpp-testbed>/data)