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

joltphysics: add version 5.0.0 #24670

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/joltphysics/5.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"5.2.0":
url: "https://github.com/jrouwe/JoltPhysics/archive/refs/tags/v5.2.0.tar.gz"
sha256: "f478afe3050c885e21403748e10ab18e3e8df8b0982c540e75f1e078ef8b2c88"
91 changes: 91 additions & 0 deletions recipes/joltphysics/5.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rmdir, rm
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
import os

required_conan_version = ">=2.0.9"


class JoltPhysicsConan(ConanFile):
name = "joltphysics"
description = (
"A multi core friendly rigid body physics and collision detection "
"library, written in C++, suitable for games and VR applications."
)
license = "MIT"
topics = ("physics", "simulation", "physics-engine", "physics-simulation", "rigid-body", "game", "collision")
homepage = "https://github.com/jrouwe/JoltPhysics"
url = "https://github.com/conan-io/conan-center-index"

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
implements = ["auto_shared_fpic"]

def layout(self):
cmake_layout(self, src_folder="src")

def build_requirements(self):
self.tool_requires("cmake/[>=3.20 <4]")

def validate(self):
check_min_cppstd(self, 17)

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["TARGET_UNIT_TESTS"] = False
tc.cache_variables["TARGET_HELLO_WORLD"] = False
tc.cache_variables["TARGET_PERFORMANCE_TEST"] = False
tc.cache_variables["TARGET_SAMPLES"] = False
tc.cache_variables["TARGET_VIEWER"] = False
tc.cache_variables["CROSS_PLATFORM_DETERMINISTIC"] = False
tc.cache_variables["INTERPROCEDURAL_OPTIMIZATION"] = False
tc.cache_variables["GENERATE_DEBUG_SYMBOLS"] = False
tc.cache_variables["ENABLE_ALL_WARNINGS"] = False
tc.cache_variables["OVERRIDE_CXX_FLAGS"] = False
tc.cache_variables["DEBUG_RENDERER_IN_DEBUG_AND_RELEASE"] = False
tc.cache_variables["PROFILER_IN_DEBUG_AND_RELEASE"] = False
if is_msvc(self):
tc.cache_variables["USE_STATIC_MSVC_RUNTIME_LIBRARY"] = is_msvc_static_runtime(self)
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(self.source_folder, "Build"))
cmake.build()

def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rm(self, "*.cmake", os.path.join(self.package_folder, "include", "Jolt"))

def package_info(self):
self.cpp_info.libs = ["Jolt"]
self.cpp_info.set_property("cmake_file_name", "Jolt")
self.cpp_info.set_property("cmake_target_name", "Jolt::Jolt")
# INFO: The CMake option ENABLE_OBJECT_STREAM is enabled by default and defines JPH_OBJECT_STREAM as public
# https://github.com/jrouwe/JoltPhysics/blob/v5.2.0/Build/CMakeLists.txt#L95C8-L95C28
self.cpp_info.defines = ["JPH_OBJECT_STREAM"]
# INFO: Public defines exposed in include/Jolt/Jolt.cmake
# https://github.com/jrouwe/JoltPhysics/blob/v5.2.0/Build/CMakeLists.txt#L51
if self.settings.arch in ["x86_64", "x86"]:
self.cpp_info.defines.extend(["JPH_USE_AVX2", "JPH_USE_AVX", "JPH_USE_SSE4_1",
"JPH_USE_SSE4_2", "JPH_USE_LZCNT", "JPH_USE_TZCNT",
"JPH_USE_F16C", "JPH_USE_FMADD"])

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["m", "pthread"])
7 changes: 7 additions & 0 deletions recipes/joltphysics/5.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(Jolt REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE Jolt::Jolt)
25 changes: 25 additions & 0 deletions recipes/joltphysics/5.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
8 changes: 8 additions & 0 deletions recipes/joltphysics/5.x/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <cstdlib>
#include <Jolt/Jolt.h>


int main() {
JPH::RegisterDefaultAllocator();
return EXIT_SUCCESS;
}
8 changes: 0 additions & 8 deletions recipes/joltphysics/all/test_v1_package/CMakeLists.txt

This file was deleted.

17 changes: 0 additions & 17 deletions recipes/joltphysics/all/test_v1_package/conanfile.py

This file was deleted.

6 changes: 4 additions & 2 deletions recipes/joltphysics/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
versions:
"5.2.0":
folder: 5.x
"3.0.1":
folder: all
folder: 3.x
"2.0.1":
folder: all
folder: 3.x