From 5af06875cf036dc7e2143385952c7de4c46f317f Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 17:56:43 +0100 Subject: [PATCH 01/10] use external glfw --- recipes/raylib/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index aec636d7d2f87..22f5a01443474 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -14,7 +14,7 @@ class RaylibConan(ConanFile): default_options = { "shared": False, "fPIC": True } exports_sources = ["CMakeLists.txt"] - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" _cmake = None @property @@ -36,6 +36,7 @@ def configure(self): del self.settings.compiler.cppstd def requirements(self): + self.requires("glfw/3.3.2") self.requires("opengl/system") if self.settings.os == "Linux": self.requires("xorg/system") @@ -48,6 +49,7 @@ def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) + self._cmake.definitions["USE_EXTERNAL_GLFW"] = "ON" self._cmake.configure(build_folder=self._build_subfolder) return self._cmake From f6b6b05602dadc6a562ef57271c17f5403e7ff86 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 18:06:07 +0100 Subject: [PATCH 02/10] explicitly set several CMake options --- recipes/raylib/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index 22f5a01443474..515af6f249a8d 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -49,6 +49,9 @@ def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) + self._cmake.definitions["BUILD_EXAMPLES"] = False + self._cmake.definitions["CUSTOMIZE_BUILD"] = False # TODO: might be enabled to add a lot of options to enable/disable raylib features + self._cmake.definitions["WITH_PIC"] = self.options.get_safe("fPIC", True) self._cmake.definitions["USE_EXTERNAL_GLFW"] = "ON" self._cmake.configure(build_folder=self._build_subfolder) return self._cmake From f206b6ca7ca20ee06281335b24c4afcf3c5db5e2 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 18:06:33 +0100 Subject: [PATCH 03/10] explicit cpp_info.libs --- recipes/raylib/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index 515af6f249a8d..09c78ee73969d 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -70,7 +70,7 @@ def package(self): def package_info(self): self.cpp_info.names["cmake_find_package"] = "raylib" self.cpp_info.names["cmake_find_package_multi"] = "raylib" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["raylib"] if self.settings.os == "Linux": self.cpp_info.system_libs.extend(["m", "pthread", "dl", "rt"]) elif self.settings.os == "Windows": From 6d62f825ce29ed6014cbc8fb712546be5300289e Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 18:07:04 +0100 Subject: [PATCH 04/10] explicit pkg_config --- recipes/raylib/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index 09c78ee73969d..d25ce9419966c 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -70,6 +70,7 @@ def package(self): def package_info(self): self.cpp_info.names["cmake_find_package"] = "raylib" self.cpp_info.names["cmake_find_package_multi"] = "raylib" + self.cpp_info.names["pkg_config"] = "raylib" self.cpp_info.libs = ["raylib"] if self.settings.os == "Linux": self.cpp_info.system_libs.extend(["m", "pthread", "dl", "rt"]) From 8a6759c25d144b11895c4afbc9acc7c0bd05c568 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 18:09:55 +0100 Subject: [PATCH 05/10] fix CMake imported target --- recipes/raylib/all/conanfile.py | 26 +++++++++++++++++++ .../raylib/all/test_package/CMakeLists.txt | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index d25ce9419966c..e6db879787244 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -66,11 +66,37 @@ def package(self): cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_subfolder, self._module_file), + {"raylib": "raylib::raylib"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += ( + "if(TARGET {aliased} AND NOT TARGET {alias})\n" + " add_library({alias} INTERFACE IMPORTED)\n" + " set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})\n" + "endif()\n" + ).format(alias=alias, aliased=aliased) + tools.save(module_file, content) + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake") + + @property + def _module_file(self): + return "conan-official-{}-targets.cmake".format(self.name) def package_info(self): self.cpp_info.names["cmake_find_package"] = "raylib" self.cpp_info.names["cmake_find_package_multi"] = "raylib" self.cpp_info.names["pkg_config"] = "raylib" + self.cpp_info.builddirs = [self._module_subfolder] + self.cpp_info.build_modules = [os.path.join(self._module_subfolder, self._module_file)] self.cpp_info.libs = ["raylib"] if self.settings.os == "Linux": self.cpp_info.system_libs.extend(["m", "pthread", "dl", "rt"]) diff --git a/recipes/raylib/all/test_package/CMakeLists.txt b/recipes/raylib/all/test_package/CMakeLists.txt index 61728120f71cf..2c3801fe02853 100644 --- a/recipes/raylib/all/test_package/CMakeLists.txt +++ b/recipes/raylib/all/test_package/CMakeLists.txt @@ -7,4 +7,4 @@ conan_basic_setup(TARGETS) find_package(raylib REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} raylib::raylib) +target_link_libraries(${PROJECT_NAME} raylib) From 5c3e9e34442a1cdf11958cdaef3317a30702b1b2 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 18:12:40 +0100 Subject: [PATCH 06/10] use C test_package --- recipes/raylib/all/test_package/CMakeLists.txt | 4 ++-- .../all/test_package/{test_package.cpp => test_package.c} | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename recipes/raylib/all/test_package/{test_package.cpp => test_package.c} (64%) diff --git a/recipes/raylib/all/test_package/CMakeLists.txt b/recipes/raylib/all/test_package/CMakeLists.txt index 2c3801fe02853..a1f55e19ef5a2 100644 --- a/recipes/raylib/all/test_package/CMakeLists.txt +++ b/recipes/raylib/all/test_package/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) find_package(raylib REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) +add_executable(${PROJECT_NAME} test_package.c) target_link_libraries(${PROJECT_NAME} raylib) diff --git a/recipes/raylib/all/test_package/test_package.cpp b/recipes/raylib/all/test_package/test_package.c similarity index 64% rename from recipes/raylib/all/test_package/test_package.cpp rename to recipes/raylib/all/test_package/test_package.c index c04a68ddfe602..97c33c55b19d9 100644 --- a/recipes/raylib/all/test_package/test_package.cpp +++ b/recipes/raylib/all/test_package/test_package.c @@ -1,12 +1,12 @@ -#include - #include "raylib.h" +#include + int main(void) { Vector3 center = {0, 0, 0}; float r = 1.0; if (CheckCollisionSpheres(center, r, center, r)) { - std::cout << "unit sphere collides with itself!" << std::endl; + printf("unit sphere collides with itself!\n"); } return 0; } From b0aecb91be0c3094b1e9172ac8172171f0c44373 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 22:12:05 +0100 Subject: [PATCH 07/10] define USE_LIBTYPE_SHARED if msvc and shared --- recipes/raylib/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index e6db879787244..6ba606eb55373 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -98,6 +98,8 @@ def package_info(self): self.cpp_info.builddirs = [self._module_subfolder] self.cpp_info.build_modules = [os.path.join(self._module_subfolder, self._module_file)] self.cpp_info.libs = ["raylib"] + if self.settings.compiler == "Visual Studio" and self.options.shared: + self.cpp_info.defines.append("USE_LIBTYPE_SHARED") if self.settings.os == "Linux": self.cpp_info.system_libs.extend(["m", "pthread", "dl", "rt"]) elif self.settings.os == "Windows": From 516b68d9c28d909df5e28a349ba2e54b31158416 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 22:22:19 +0100 Subject: [PATCH 08/10] remove transitive system dependencies removed system libs were coming from glfw and are not direct dependencies of raylib --- recipes/raylib/all/conanfile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index 6ba606eb55373..f6e8e25005684 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -101,8 +101,6 @@ def package_info(self): if self.settings.compiler == "Visual Studio" and self.options.shared: self.cpp_info.defines.append("USE_LIBTYPE_SHARED") if self.settings.os == "Linux": - self.cpp_info.system_libs.extend(["m", "pthread", "dl", "rt"]) + self.cpp_info.system_libs.extend(["m", "pthread"]) elif self.settings.os == "Windows": - self.cpp_info.system_libs.extend(["gdi32", "winmm"]) - elif self.settings.os == "Macos": - self.cpp_info.frameworks.extend(["Cocoa", "IOKit", "CoreVideo"]) + self.cpp_info.system_libs.append("winmm") From 2a266e94eb94414366c97a549740d4c04402de3b Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 22:23:57 +0100 Subject: [PATCH 09/10] remove CUSTOMIZE_BUILD CMake option not available in raylib 3.5.0 --- recipes/raylib/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index f6e8e25005684..e2fdcf209d90e 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -50,7 +50,6 @@ def _configure_cmake(self): return self._cmake self._cmake = CMake(self) self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["CUSTOMIZE_BUILD"] = False # TODO: might be enabled to add a lot of options to enable/disable raylib features self._cmake.definitions["WITH_PIC"] = self.options.get_safe("fPIC", True) self._cmake.definitions["USE_EXTERNAL_GLFW"] = "ON" self._cmake.configure(build_folder=self._build_subfolder) From d590666ff273c63c984e933231de2d6b7844f9c1 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 6 Feb 2021 22:58:27 +0100 Subject: [PATCH 10/10] fix windows and external glfw --- recipes/raylib/all/conanfile.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index e2fdcf209d90e..3bb9de8f4824e 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -45,6 +45,11 @@ def source(self): tools.get(**self.conan_data["sources"][self.version]) os.rename(self.name + "-" + self.version, self._source_subfolder) + def _patch_sources(self): + # avoid symbols conflicts with Win SDK + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "core.c"), + "#define GLFW_EXPOSE_NATIVE_WIN32", "") + def _configure_cmake(self): if self._cmake: return self._cmake @@ -56,6 +61,7 @@ def _configure_cmake(self): return self._cmake def build(self): + self._patch_sources() cmake = self._configure_cmake() cmake.build() @@ -96,7 +102,10 @@ def package_info(self): self.cpp_info.names["pkg_config"] = "raylib" self.cpp_info.builddirs = [self._module_subfolder] self.cpp_info.build_modules = [os.path.join(self._module_subfolder, self._module_file)] - self.cpp_info.libs = ["raylib"] + libname = "raylib" + if self.settings.compiler == "Visual Studio" and not self.options.shared: + libname += "_static" + self.cpp_info.libs = [libname] if self.settings.compiler == "Visual Studio" and self.options.shared: self.cpp_info.defines.append("USE_LIBTYPE_SHARED") if self.settings.os == "Linux":