Skip to content

Commit

Permalink
Add CMake Target Exporting & option to disable testing in the build (E…
Browse files Browse the repository at this point in the history
…sotericSoftware#2329)

* Fix cmake install

* Option to build without testing

* Add target exporting and SpineConfig.cmake

* Revert relative install paths to Spine preferred ones
  • Loading branch information
aWilson41 committed Jul 29, 2023
1 parent cd1935d commit 373a163
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
16 changes: 12 additions & 4 deletions CMakeLists.txt
Expand Up @@ -5,8 +5,9 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH "Install location" FORCE)
endif()
set(CMAKE_VERBOSE_MAKEFILE ON)
set(SPINE_SFML FALSE CACHE BOOL FALSE)
set(SPINE_SANITIZE FALSE CACHE BOOL FALSE)
option(SPINE_SFML "Build spine SFML API" OFF)
option(SPINE_SANITIZE "Build with sanitization" OFF)
option(BUILD_TESTING "Build with testing" ON)

if(MSVC)
message("MSCV detected")
Expand Down Expand Up @@ -42,5 +43,12 @@ elseif((${SPINE_SDL}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-sdl"))
else()
add_subdirectory(spine-c)
add_subdirectory(spine-cpp)
add_subdirectory(spine-cpp/spine-cpp-unit-tests)
endif()
if (${BUILD_TESTING})
add_subdirectory(spine-cpp/spine-cpp-unit-tests)
endif()
endif()

# Create config file that include the exported targets
configure_file(SpineConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/SpineConfig.cmake"
@ONLY)
1 change: 1 addition & 0 deletions SpineConfig.cmake.in
@@ -0,0 +1 @@
include("@CMAKE_CURRENT_BINARY_DIR@/spine-cpp/spine-cppTargets.cmake")
12 changes: 10 additions & 2 deletions spine-cpp/CMakeLists.txt
Expand Up @@ -13,5 +13,13 @@ file(GLOB SOURCES "spine-cpp/src/**/*.cpp")

add_library(spine-cpp STATIC ${SOURCES} ${INCLUDES})
target_include_directories(spine-cpp PUBLIC spine-cpp/include)
install(TARGETS spine-cpp DESTINATION dist/lib)
install(FILES ${INCLUDES} DESTINATION dist/include)

# Install target
install(TARGETS spine-cpp EXPORT spine-cpp_TARGETS DESTINATION dist/lib)
install(FILES ${INCLUDES} DESTINATION dist/include)

# Export target
export(
EXPORT spine-cpp_TARGETS
FILE ${CMAKE_CURRENT_BINARY_DIR}/spine-cppTargets.cmake
NAMESPACE "Spine::")

0 comments on commit 373a163

Please sign in to comment.