diff --git a/recipes/joltphysics/all/conandata.yml b/recipes/joltphysics/3.x/conandata.yml similarity index 100% rename from recipes/joltphysics/all/conandata.yml rename to recipes/joltphysics/3.x/conandata.yml diff --git a/recipes/joltphysics/all/conanfile.py b/recipes/joltphysics/3.x/conanfile.py similarity index 100% rename from recipes/joltphysics/all/conanfile.py rename to recipes/joltphysics/3.x/conanfile.py diff --git a/recipes/joltphysics/all/patches/2.0.1-0001-fix-cmake.patch b/recipes/joltphysics/3.x/patches/2.0.1-0001-fix-cmake.patch similarity index 100% rename from recipes/joltphysics/all/patches/2.0.1-0001-fix-cmake.patch rename to recipes/joltphysics/3.x/patches/2.0.1-0001-fix-cmake.patch diff --git a/recipes/joltphysics/all/patches/3.0.1-0001-fix-cmake.patch b/recipes/joltphysics/3.x/patches/3.0.1-0001-fix-cmake.patch similarity index 100% rename from recipes/joltphysics/all/patches/3.0.1-0001-fix-cmake.patch rename to recipes/joltphysics/3.x/patches/3.0.1-0001-fix-cmake.patch diff --git a/recipes/joltphysics/all/test_package/CMakeLists.txt b/recipes/joltphysics/3.x/test_package/CMakeLists.txt similarity index 100% rename from recipes/joltphysics/all/test_package/CMakeLists.txt rename to recipes/joltphysics/3.x/test_package/CMakeLists.txt diff --git a/recipes/joltphysics/all/test_package/conanfile.py b/recipes/joltphysics/3.x/test_package/conanfile.py similarity index 100% rename from recipes/joltphysics/all/test_package/conanfile.py rename to recipes/joltphysics/3.x/test_package/conanfile.py diff --git a/recipes/joltphysics/all/test_package/test_package.cpp b/recipes/joltphysics/3.x/test_package/test_package.cpp similarity index 100% rename from recipes/joltphysics/all/test_package/test_package.cpp rename to recipes/joltphysics/3.x/test_package/test_package.cpp diff --git a/recipes/joltphysics/5.x/conandata.yml b/recipes/joltphysics/5.x/conandata.yml new file mode 100644 index 0000000000000..286fa74fd26ba --- /dev/null +++ b/recipes/joltphysics/5.x/conandata.yml @@ -0,0 +1,4 @@ +sources: + "5.2.0": + url: "https://github.com/jrouwe/JoltPhysics/archive/refs/tags/v5.2.0.tar.gz" + sha256: "f478afe3050c885e21403748e10ab18e3e8df8b0982c540e75f1e078ef8b2c88" diff --git a/recipes/joltphysics/5.x/conanfile.py b/recipes/joltphysics/5.x/conanfile.py new file mode 100644 index 0000000000000..545596f2925de --- /dev/null +++ b/recipes/joltphysics/5.x/conanfile.py @@ -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"]) diff --git a/recipes/joltphysics/5.x/test_package/CMakeLists.txt b/recipes/joltphysics/5.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..080b63d50fff6 --- /dev/null +++ b/recipes/joltphysics/5.x/test_package/CMakeLists.txt @@ -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) diff --git a/recipes/joltphysics/5.x/test_package/conanfile.py b/recipes/joltphysics/5.x/test_package/conanfile.py new file mode 100644 index 0000000000000..87901dd77830a --- /dev/null +++ b/recipes/joltphysics/5.x/test_package/conanfile.py @@ -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") diff --git a/recipes/joltphysics/5.x/test_package/test_package.cpp b/recipes/joltphysics/5.x/test_package/test_package.cpp new file mode 100644 index 0000000000000..5f0927f9ae8d1 --- /dev/null +++ b/recipes/joltphysics/5.x/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include +#include + + +int main() { + JPH::RegisterDefaultAllocator(); + return EXIT_SUCCESS; +} diff --git a/recipes/joltphysics/all/test_v1_package/CMakeLists.txt b/recipes/joltphysics/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 0d20897301b68..0000000000000 --- a/recipes/joltphysics/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package - ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/joltphysics/all/test_v1_package/conanfile.py b/recipes/joltphysics/all/test_v1_package/conanfile.py deleted file mode 100644 index 38f4483872d47..0000000000000 --- a/recipes/joltphysics/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,17 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) diff --git a/recipes/joltphysics/config.yml b/recipes/joltphysics/config.yml index 41bbdfae2300d..2a48b28a6e4c3 100644 --- a/recipes/joltphysics/config.yml +++ b/recipes/joltphysics/config.yml @@ -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