From d9bb748ac8ae8d984aa796d21487effc6da26f61 Mon Sep 17 00:00:00 2001 From: Stephen Just Date: Mon, 6 Jan 2020 14:44:15 -0800 Subject: [PATCH] [bullet3] Install CMake toolchain files and targets (#9098) * [bullet3] Install CMake toolchain files and targets * Use vcpkg_fixup_cmake_targets * Bump version number --- ports/bullet3/CONTROL | 2 +- ports/bullet3/cmake-fix.patch | 277 ++++++++++++++++++++++++++++++++++ ports/bullet3/portfile.cmake | 7 +- 3 files changed, 283 insertions(+), 3 deletions(-) create mode 100644 ports/bullet3/cmake-fix.patch diff --git a/ports/bullet3/CONTROL b/ports/bullet3/CONTROL index d313255a5e9..e8221d1f7ff 100644 --- a/ports/bullet3/CONTROL +++ b/ports/bullet3/CONTROL @@ -1,5 +1,5 @@ Source: bullet3 -Version: 2.88-1 +Version: 2.88-2 Homepage: https://github.com/bulletphysics/bullet3 Description: Bullet Physics is a professional collision detection, rigid body, and soft body dynamics library diff --git a/ports/bullet3/cmake-fix.patch b/ports/bullet3/cmake-fix.patch new file mode 100644 index 00000000000..c8339e51e12 --- /dev/null +++ b/ports/bullet3/cmake-fix.patch @@ -0,0 +1,277 @@ +diff --git a/BulletConfig.cmake.in b/BulletConfig.cmake.in +index f5dc7bdbb..f5412dac3 100644 +--- a/BulletConfig.cmake.in ++++ b/BulletConfig.cmake.in +@@ -3,6 +3,8 @@ + # BulletConfig.cmake(.in) + # + ++@PACKAGE_INIT@ ++ + # Use the following variables to compile and link against Bullet: + # BULLET_FOUND - True if Bullet was found on your system + # BULLET_USE_FILE - The file making Bullet usable +@@ -15,11 +17,20 @@ + # BULLET_VERSION_STRING - A human-readable string containing the version + + set ( BULLET_FOUND 1 ) +-set ( BULLET_USE_FILE "@BULLET_USE_FILE@" ) ++set_and_check ( BULLET_USE_FILE "@PACKAGE_BULLET_CONFIG_CMAKE_PATH@/UseBullet.cmake" ) + set ( BULLET_DEFINITIONS "@BULLET_DEFINITIONS@" ) +-set ( BULLET_INCLUDE_DIR "@INCLUDE_INSTALL_DIR@" ) +-set ( BULLET_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@" ) ++set_and_check ( BULLET_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" ) ++set_and_check ( BULLET_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@" ) + set ( BULLET_LIBRARIES "@BULLET_LIBRARIES@" ) +-set ( BULLET_LIBRARY_DIRS "@LIB_DESTINATION@" ) +-set ( BULLET_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" ) +-set ( BULLET_VERSION_STRING "@BULLET_VERSION@" ) +\ No newline at end of file ++set_and_check ( BULLET_LIBRARY_DIRS "@PACKAGE_LIB_DESTINATION@" ) ++set_and_check ( BULLET_ROOT_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@" ) ++set ( BULLET_VERSION_STRING "@BULLET_VERSION@" ) ++ ++# Load targets ++if(NOT TARGET Bullet3Common) ++ file(GLOB CONFIG_FILES "@PACKAGE_BULLET_CONFIG_CMAKE_PATH@/*Targets.cmake") ++ foreach(f ${CONFIG_FILES}) ++ include(${f}) ++ endforeach() ++ set(_DIR) ++endif() +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 68e0a93bc..872e14361 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 2.4.3) ++cmake_minimum_required(VERSION 3.0) + set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) + cmake_policy(SET CMP0017 NEW) + #this line has to appear before 'PROJECT' in order to be able to disable incremental linking +@@ -465,23 +465,34 @@ IF (BUILD_UNIT_TESTS) + SUBDIRS(test) + ENDIF() + +-set (BULLET_CONFIG_CMAKE_PATH lib${LIB_SUFFIX}/cmake/bullet ) ++include(CMakePackageConfigHelpers) ++write_basic_package_version_file( ++ "${CMAKE_CURRENT_BINARY_DIR}/BulletConfigVersion.cmake" ++ VERSION ${BULLET_VERSION} ++ COMPATIBILITY AnyNewerVersion ++) ++ ++set (BULLET_CONFIG_CMAKE_PATH share/bullet3 ) + list (APPEND BULLET_LIBRARIES LinearMath) + list (APPEND BULLET_LIBRARIES Bullet3Common) + list (APPEND BULLET_LIBRARIES BulletInverseDynamics) + list (APPEND BULLET_LIBRARIES BulletCollision) + list (APPEND BULLET_LIBRARIES BulletDynamics) + list (APPEND BULLET_LIBRARIES BulletSoftBody) +-set (BULLET_USE_FILE ${BULLET_CONFIG_CMAKE_PATH}/UseBullet.cmake) +-configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/BulletConfig.cmake.in +- ${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake +- @ONLY ESCAPE_QUOTES +- ) ++ ++configure_package_config_file( ++ ${CMAKE_CURRENT_SOURCE_DIR}/BulletConfig.cmake.in ++ ${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake ++ PATH_VARS INCLUDE_INSTALL_DIR LIB_DESTINATION CMAKE_INSTALL_PREFIX BULLET_CONFIG_CMAKE_PATH ++ INSTALL_DESTINATION ${BULLET_CONFIG_CMAKE_PATH} ++) ++ + OPTION(INSTALL_CMAKE_FILES "Install generated CMake files" ON) + + IF (INSTALL_CMAKE_FILES) + install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/UseBullet.cmake + ${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake ++ ${CMAKE_CURRENT_BINARY_DIR}/BulletConfigVersion.cmake + DESTINATION ${BULLET_CONFIG_CMAKE_PATH} + ) + ENDIF (INSTALL_CMAKE_FILES) +diff --git a/src/Bullet3Common/CMakeLists.txt b/src/Bullet3Common/CMakeLists.txt +index e899e67d9..0ca702eb8 100644 +--- a/src/Bullet3Common/CMakeLists.txt ++++ b/src/Bullet3Common/CMakeLists.txt +@@ -43,9 +43,12 @@ IF (INSTALL_LIBS) + #FILES_MATCHING requires CMake 2.6 + IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) + IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS Bullet3Common DESTINATION .) ++ INSTALL(TARGETS Bullet3Common ++ EXPORT Bullet3CommonTargets ++ DESTINATION .) + ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + INSTALL(TARGETS Bullet3Common ++ EXPORT Bullet3CommonTargets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX}) +@@ -59,5 +62,8 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN + SET_TARGET_PROPERTIES(Bullet3Common PROPERTIES FRAMEWORK true) + SET_TARGET_PROPERTIES(Bullet3Common PROPERTIES PUBLIC_HEADER "${Bullet3Common_HDRS}") + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ++ ++ INSTALL(EXPORT Bullet3CommonTargets ++ DESTINATION ${BULLET_CONFIG_CMAKE_PATH}) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) +diff --git a/src/BulletCollision/CMakeLists.txt b/src/BulletCollision/CMakeLists.txt +index f5d725562..e98de8ba2 100644 +--- a/src/BulletCollision/CMakeLists.txt ++++ b/src/BulletCollision/CMakeLists.txt +@@ -266,11 +266,15 @@ IF (INSTALL_LIBS) + #INSTALL of other files requires CMake 2.6 + IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) + IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS BulletCollision DESTINATION .) ++ INSTALL(TARGETS BulletCollision ++ EXPORT BulletCollisionTargets ++ DESTINATION .) + ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS BulletCollision RUNTIME DESTINATION bin +- LIBRARY DESTINATION lib${LIB_SUFFIX} +- ARCHIVE DESTINATION lib${LIB_SUFFIX}) ++ INSTALL(TARGETS BulletCollision ++ EXPORT BulletCollisionTargets ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib${LIB_SUFFIX} ++ ARCHIVE DESTINATION lib${LIB_SUFFIX}) + INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) + INSTALL(FILES ../btBulletCollisionCommon.h +@@ -290,5 +294,8 @@ DESTINATION ${INCLUDE_INSTALL_DIR}/BulletCollision) + SET_PROPERTY(SOURCE ${NarrowPhaseCollision_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/NarrowPhaseCollision) + + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ++ ++ INSTALL(EXPORT BulletCollisionTargets ++ DESTINATION ${BULLET_CONFIG_CMAKE_PATH}) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) +diff --git a/src/BulletDynamics/CMakeLists.txt b/src/BulletDynamics/CMakeLists.txt +index 3332440f2..3bbce4389 100644 +--- a/src/BulletDynamics/CMakeLists.txt ++++ b/src/BulletDynamics/CMakeLists.txt +@@ -147,11 +147,15 @@ IF (INSTALL_LIBS) + IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) + IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS BulletDynamics DESTINATION .) ++ INSTALL(TARGETS BulletDynamics ++ EXPORT BulletDynamicsTargets ++ DESTINATION .) + ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS BulletDynamics RUNTIME DESTINATION bin +- LIBRARY DESTINATION lib${LIB_SUFFIX} +- ARCHIVE DESTINATION lib${LIB_SUFFIX}) ++ INSTALL(TARGETS BulletDynamics ++ EXPORT BulletDynamicsTargets ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib${LIB_SUFFIX} ++ ARCHIVE DESTINATION lib${LIB_SUFFIX}) + INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN + ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) +@@ -172,4 +176,7 @@ DESTINATION ${INCLUDE_INSTALL_DIR}/BulletDynamics) + SET_PROPERTY(SOURCE ${MLCPSolvers_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/MLCPSolvers) + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ++ ++ INSTALL(EXPORT BulletDynamicsTargets ++ DESTINATION ${BULLET_CONFIG_CMAKE_PATH}) + ENDIF (INSTALL_LIBS) +diff --git a/src/BulletInverseDynamics/CMakeLists.txt b/src/BulletInverseDynamics/CMakeLists.txt +index 3331c27ea..86b4e54be 100644 +--- a/src/BulletInverseDynamics/CMakeLists.txt ++++ b/src/BulletInverseDynamics/CMakeLists.txt +@@ -42,11 +42,15 @@ IF (INSTALL_LIBS) + #INSTALL of other files requires CMake 2.6 + IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) + IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS BulletInverseDynamics DESTINATION .) ++ INSTALL(TARGETS BulletInverseDynamics ++ EXPORT BulletInverseDynamicsTargets ++ DESTINATION .) + ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS BulletInverseDynamics RUNTIME DESTINATION bin +- LIBRARY DESTINATION lib${LIB_SUFFIX} +- ARCHIVE DESTINATION lib${LIB_SUFFIX}) ++ INSTALL(TARGETS BulletInverseDynamics ++ EXPORT BulletInverseDynamicsTargets ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib${LIB_SUFFIX} ++ ARCHIVE DESTINATION lib${LIB_SUFFIX}) + INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) + INSTALL(FILES ../btBulletCollisionCommon.h +@@ -62,5 +66,8 @@ DESTINATION ${INCLUDE_INSTALL_DIR}/BulletInverseDynamics) + SET_PROPERTY(SOURCE ${BulletInverseDynamicsDetails_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/details) + + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ++ ++ INSTALL(EXPORT BulletInverseDynamicsTargets ++ DESTINATION ${BULLET_CONFIG_CMAKE_PATH}) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) +diff --git a/src/BulletSoftBody/CMakeLists.txt b/src/BulletSoftBody/CMakeLists.txt +index d43df1c67..6ba508ec5 100644 +--- a/src/BulletSoftBody/CMakeLists.txt ++++ b/src/BulletSoftBody/CMakeLists.txt +@@ -50,11 +50,15 @@ IF (INSTALL_LIBS) + IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) + IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS BulletSoftBody DESTINATION .) ++ INSTALL(TARGETS BulletSoftBody ++ EXPORT BulletSoftBodyTargets ++ DESTINATION .) + ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS BulletSoftBody RUNTIME DESTINATION bin +- LIBRARY DESTINATION lib${LIB_SUFFIX} +- ARCHIVE DESTINATION lib${LIB_SUFFIX}) ++ INSTALL(TARGETS BulletSoftBody ++ EXPORT BulletSoftBodyTargets ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib${LIB_SUFFIX} ++ ARCHIVE DESTINATION lib${LIB_SUFFIX}) + INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN + ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) +@@ -65,5 +69,8 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN + SET_TARGET_PROPERTIES(BulletSoftBody PROPERTIES FRAMEWORK true) + SET_TARGET_PROPERTIES(BulletSoftBody PROPERTIES PUBLIC_HEADER "${BulletSoftBody_HDRS}") + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ++ ++ INSTALL(EXPORT BulletSoftBodyTargets ++ DESTINATION ${BULLET_CONFIG_CMAKE_PATH}) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) +diff --git a/src/LinearMath/CMakeLists.txt b/src/LinearMath/CMakeLists.txt +index 0c8c0133a..56d4b5bcc 100644 +--- a/src/LinearMath/CMakeLists.txt ++++ b/src/LinearMath/CMakeLists.txt +@@ -59,9 +59,12 @@ IF (INSTALL_LIBS) + #FILES_MATCHING requires CMake 2.6 + IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) + IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) +- INSTALL(TARGETS LinearMath DESTINATION .) ++ INSTALL(TARGETS LinearMath ++ EXPORT LinearMathTargets ++ DESTINATION .) + ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) + INSTALL(TARGETS LinearMath ++ EXPORT LinearMathTargets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX}) +@@ -75,5 +78,8 @@ DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN + SET_TARGET_PROPERTIES(LinearMath PROPERTIES FRAMEWORK true) + SET_TARGET_PROPERTIES(LinearMath PROPERTIES PUBLIC_HEADER "${LinearMath_HDRS}") + ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ++ ++ INSTALL(EXPORT LinearMathTargets ++ DESTINATION ${BULLET_CONFIG_CMAKE_PATH}) + ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ENDIF (INSTALL_LIBS) diff --git a/ports/bullet3/portfile.cmake b/ports/bullet3/portfile.cmake index 031ddf23fa0..ffd5a80e4cb 100644 --- a/ports/bullet3/portfile.cmake +++ b/ports/bullet3/portfile.cmake @@ -8,6 +8,7 @@ vcpkg_from_github( REF 2.88 SHA512 15face1940d496c96fd19a44139d11d2cbb629526c40432be4a0eef5fa9a532c842ec7318248c0359a080f2034111bf1a3c2d3a6fd789bec675bd368fac7bd93 HEAD_REF master + PATCHES cmake-fix.patch ) set(BULLET_MULTITHREADING OFF) @@ -32,8 +33,10 @@ vcpkg_configure_cmake( vcpkg_install_cmake() -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/cmake) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/cmake) +vcpkg_fixup_cmake_targets(CONFIG_PATH "share/bullet3") + +# Clean up unneeded files +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/bullet/BulletInverseDynamics/details)