[box2d] Replace buildsystem with CMake for better cross-platform support

This commit is contained in:
Robert Schumacher 2018-05-01 15:39:19 -07:00
parent 8eac561107
commit 64c32687f3
4 changed files with 36 additions and 95 deletions

View File

@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.9)
project(Box2d CXX)
file(GLOB_RECURSE SOURCES Box2D/Box2D/*.cpp)
add_library(Box2D ${SOURCES})
target_include_directories(Box2D PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Box2D> $<INSTALL_INTERFACE:include>)
install(TARGETS Box2D
EXPORT unofficial-box2d-targets
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(
EXPORT unofficial-box2d-targets
FILE unofficial-box2d-config.cmake
NAMESPACE unofficial::box2d::
DESTINATION share/unofficial-box2d
)

View File

@ -1,3 +1,3 @@
Source: box2d
Version: 2.3.1-374664b
Version: 2.3.1-374664b-1
Description: Box2D (http://box2d.org) is an open source C++ engine for simulating rigid bodies in 2D.

View File

@ -1,17 +1,8 @@
# Get output directory
set(PROJECT_ARCH_BITS "x64")
if(TRIPLET_SYSTEM_ARCH MATCHES "x86")
set(PROJECT_ARCH_BITS "x32")
elseif(TRIPLET_SYSTEM_ARCH MATCHES "arm")
message(FATAL_ERROR "ARM not supported")
endif(TRIPLET_SYSTEM_ARCH MATCHES "x86")
include(vcpkg_common_functions)
if(EXISTS "${CURRENT_BUILDTREES_DIR}/src/.git")
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/src)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
message("Box2D only supports building as a static library")
set(VCPKG_LIBRARY_LINKAGE "static")
endif()
vcpkg_from_github(
@ -22,54 +13,23 @@ vcpkg_from_github(
HEAD_REF master
)
if(VCPKG_CRT_LINKAGE STREQUAL "static")
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES
${CMAKE_CURRENT_LIST_DIR}/use-static-linkage.patch
)
endif()
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
# Put the licence and readme files where vcpkg expects it
message(STATUS "Packaging license")
file(COPY ${SOURCE_PATH}/README.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/box2d)
file(COPY ${SOURCE_PATH}/Box2D/License.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/box2d)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/box2d/License.txt ${CURRENT_PACKAGES_DIR}/share/box2d/copyright)
message(STATUS "Packaging license done")
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)
vcpkg_install_cmake()
# Building:
set(OUTPUTS_PATH "${SOURCE_PATH}/Box2D/Build/vs2015/bin/${PROJECT_ARCH_BITS}")
vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-box2d TARGET_PATH share/unofficial-box2d)
vcpkg_build_msbuild(PROJECT_PATH ${SOURCE_PATH}/Box2D/Build/vs2015/Box2D.vcxproj)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
message(STATUS "Packaging ${TARGET_TRIPLET}-Release lib")
file(
INSTALL ${OUTPUTS_PATH}/Release/
DESTINATION ${CURRENT_PACKAGES_DIR}/lib
FILES_MATCHING PATTERN "*.lib"
)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/Box2D.lib ${CURRENT_PACKAGES_DIR}/lib/box2d.lib)
message(STATUS "Packaging ${TARGET_TRIPLET}-Release lib done")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Packaging ${TARGET_TRIPLET}-Debug lib")
file(
INSTALL ${OUTPUTS_PATH}/Debug/
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib
FILES_MATCHING PATTERN "*.lib"
)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/Box2D.lib ${CURRENT_PACKAGES_DIR}/debug/lib/box2d.lib)
message(STATUS "Packaging ${TARGET_TRIPLET}-Debug lib done")
endif()
message(STATUS "Packaging headers")
file(
COPY ${SOURCE_PATH}/Box2D/Box2D
DESTINATION ${CURRENT_PACKAGES_DIR}/include
PATTERN "*.h"
FILES_MATCHING PATTERN "*.h"
)
message(STATUS "Packaging headers done")
vcpkg_copy_pdbs()
file(COPY ${SOURCE_PATH}/Box2D/License.txt ${SOURCE_PATH}/README.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/box2d)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/box2d/License.txt ${CURRENT_PACKAGES_DIR}/share/box2d/copyright)

View File

@ -1,40 +0,0 @@
diff --git a/Box2D/Build/vs2015/Box2D.vcxproj b/Box2D/Build/vs2015/Box2D.vcxproj
index 830803c..5dda519 100644
--- a/Box2D/Build/vs2015/Box2D.vcxproj
+++ b/Box2D/Build/vs2015/Box2D.vcxproj
@@ -86,7 +86,7 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
@@ -115,7 +115,7 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
@@ -145,7 +145,7 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<StringPooling>true</StringPooling>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
@@ -176,7 +176,7 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<StringPooling>true</StringPooling>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>