Repository: conan-io/conan-center-index

Issue:
[request] physx/4.1.2
### Package Name/Version

physx/4.1.2

### Changelog

https://gameworksdocs.nvidia.com/PhysX/4.1/release_notes.html

### Context about the new update

Code is available on physx4 github repo, using the latest commit: https://github.com/NVIDIAGameWorks/PhysX/commits/4.1/

The latest version is: [4.1.2.29882248](https://github.com/NVIDIAGameWorks/PhysX/commit/c3d5537bdebd6f5cd82fcaf87474b838fe6fd5fa)

The above-mentioned version is newly released by the upstream project and not yet available as a recipe.
Please add this version.



Discussion:
@zbendefy Do you need v4.1.2, specifically, or would the latest v5.3.1 from https://github.com/NVIDIA-Omniverse/PhysX also work?

Resolving patch:
diff --git a/recipes/physx/4.x.x/conanfile.py b/recipes/physx/4.x.x/conanfile.py
--- a/recipes/physx/4.x.x/conanfile.py
+++ b/recipes/physx/4.x.x/conanfile.py
@@ -18,6 +18,7 @@ class PhysXConan(ConanFile):
     homepage = "https://github.com/NVIDIAGameWorks/PhysX"
     url = "https://github.com/conan-io/conan-center-index"
 
+    package_type = "library"
     settings = "os", "compiler", "arch", "build_type"
     options = {
         "shared": [True, False],
@@ -35,8 +36,7 @@ class PhysXConan(ConanFile):
     }
 
     short_paths = True
-
-    generators = "CMakeDeps"
+    no_copy_source = True
 
     def export_sources(self):
         export_conandata_patches(self)
@@ -64,30 +64,28 @@ def validate(self):
 
         if self.settings.os == "Macos":
             if self.settings.arch not in ["x86", "x86_64"]:
-                raise ConanInvalidConfiguration("{} only supports x86 and x86_64 on macOS".format(self.name))
-            
+                raise ConanInvalidConfiguration(f"{self.name} only supports x86 and x86_64 on macOS")
+
             if valid_min_cppstd(self, 17):
-                raise ConanInvalidConfiguration("{} is not supported with C++ 17. Contributions are welcome.".format(self.name))
+                raise ConanInvalidConfiguration(f"{self.name} is not supported with C++ 17. Contributions are welcome.")
 
         build_type = self.settings.build_type
         if build_type not in ["Debug", "RelWithDebInfo", "Release"]:
             raise ConanInvalidConfiguration("Current build_type is not supported")
 
         if self.settings.os == "Windows" and not is_msvc(self):
-            raise ConanInvalidConfiguration("{} only supports Visual Studio on Windows".format(self.name))
+            raise ConanInvalidConfiguration(f"{self.name} only supports Visual Studio on Windows")
 
         if is_msvc(self):
             allowed_runtimes = ["MDd", "MTd"] if build_type == "Debug" else ["MD", "MT"]
             if msvc_runtime_flag(self) not in allowed_runtimes:
                 raise ConanInvalidConfiguration(
-                    "Visual Studio runtime {0} is required for {1} build type".format(
-                        " or ".join(allowed_runtimes),
-                        build_type,
-                    )
+                    f"Visual Studio runtime {' or '.join(allowed_runtimes)} is required for {build_type} build type"
                 )
 
     def source(self):
         get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)
+        self._patch_sources()
 
     def generate(self):
         tc = CMakeToolchain(self)
@@ -141,8 +139,6 @@ def generate(self):
         tc.generate()
 
     def build(self):
-        self._patch_sources()
-
         cmake = CMake(self)
         cmake.configure(build_script_folder=os.path.join(self.source_folder, "physx/compiler/public"))
         cmake.build(build_type=self._get_physx_build_type())
@@ -185,8 +181,7 @@ def _patch_sources(self):
         ):
             target, _ = os.path.splitext(os.path.basename(cmake_file))
             replace_in_file(self, os.path.join(physx_source_cmake_dir, cmake_file),
-                                  "SET_TARGET_PROPERTIES({} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)".format(target),
-                                  "")
+                            f"SET_TARGET_PROPERTIES({target} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)", "")
 
         # No error for compiler warnings
         replace_in_file(self, os.path.join(physx_source_cmake_dir, "windows", "CMakeLists.txt"),
@@ -263,7 +258,7 @@ def _copy_external_bin(self):
                 "pattern": "PhysXDevice*.dll",
                 "vc_ver": {"180": "vc120", "190": "vc140", "191": "vc141"}.get(str(compiler_version), "vc142")
             }]
-            
+
             package_dst_bin_dir = os.path.join(self.package_folder, "bin")
 
             for dll_info in dll_info_list:


Test patch:
diff --git a/recipes/physx/4.x.x/test_package/conanfile.py b/recipes/physx/4.x.x/test_package/conanfile.py
--- a/recipes/physx/4.x.x/test_package/conanfile.py
+++ b/recipes/physx/4.x.x/test_package/conanfile.py
@@ -6,6 +6,7 @@
 class TestPackageConan(ConanFile):
     settings = "os", "arch", "compiler", "build_type"
     generators = "CMakeDeps", "VirtualRunEnv"
+    test_type = "explicit"
 
     def requirements(self):
         self.requires(self.tested_reference_str)
@@ -15,7 +16,7 @@ def layout(self):
 
     def generate(self):
         tc = CMakeToolchain(self)
-        tc.variables["TEST_SHARED_LIBRARY"] = True if "fPIC" not in self.options["physx"].fields else self.options["physx"].fPIC
+        tc.variables["TEST_SHARED_LIBRARY"] = self.dependencies["physx"].options.get_safe("fPIC", True)
         tc.generate()
 
     def build(self):
@@ -25,5 +26,5 @@ def build(self):
 
     def test(self):
         if can_run(self):
-            bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
+            bin_path = os.path.join(self.cpp.build.bindir, "test_package")
             self.run(bin_path, env="conanrun")