Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake Target Exporting & option to disable testing in the build #2329

Merged
merged 5 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("@CMAKE_CURRENT_BINARY_DIR@/spine-cpp/spine-cppTargets.cmake")
12 changes: 10 additions & 2 deletions spine-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
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::")