diff --git a/recipes/libq/all/conandata.yml b/recipes/libq/all/conandata.yml index ccf7438b45e02..10ff9b4c84e7a 100644 --- a/recipes/libq/all/conandata.yml +++ b/recipes/libq/all/conandata.yml @@ -2,3 +2,8 @@ sources: "0.0.0.cci.20180504": url: "https://github.com/grantila/q/archive/0117848bb3e6f0b130b546bc5851caf5f95f8b7e.zip" sha256: "f5e51c1abbbec8e6da2155740917d7f1f60628745363ebd4e2aadfd7ef2ff682" +patches: + "0.0.0.cci.20180504": + - patch_file: "patches/0001-cmake-remove-hardcoded-flags.patch" + patch_description: "Remove hardcoded flags from CMakeLists.txt" + patch_type: "conan" diff --git a/recipes/libq/all/conanfile.py b/recipes/libq/all/conanfile.py index dc16af6ef7029..5f4bda8e476df 100644 --- a/recipes/libq/all/conanfile.py +++ b/recipes/libq/all/conanfile.py @@ -4,11 +4,12 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout -from conan.tools.files import copy, get, rm, rmdir +from conan.tools.files import copy, get, rm, rmdir, export_conandata_patches, apply_conandata_patches +from conan.tools.microsoft import is_msvc from conan.tools.scm import Version from conan.tools.apple import fix_apple_shared_install_name -required_conan_version = ">=1.53.0" +required_conan_version = ">=2.1" class libqConan(ConanFile): name = "libq" @@ -28,45 +29,28 @@ class libqConan(ConanFile): "fPIC": True, } - @property - def _min_cppstd(self): - return 17 - - @property - def _compilers_minimum_version(self): - return { - "apple-clang": "10", - "clang": "7", - "gcc": "7" - } - - def configure(self): - if self.options.shared: - self.options.rm_safe("fPIC") + implements = ["auto_shared_fpic"] def layout(self): cmake_layout(self, src_folder="src") + def export_sources(self): + export_conandata_patches(self) + def validate(self): - if self.settings.compiler.cppstd: - check_min_cppstd(self, self._min_cppstd) - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if minimum_version and Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration( - f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." - ) - if self.settings.os in ["Windows"]: - # FIXME: Test package is not capable to find q.lib - raise ConanInvalidConfiguration(f"{self.ref} Conan recipe is not supported in Windows. Contributions are welcome.") + check_min_cppstd(self, 11) + if self.settings.os == "Windows" and self.options.shared: + # It exports no symbols, so it can't be used as a shared library + raise ConanInvalidConfiguration("Does not support shared libraries on Windows") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) def generate(self): tc = CMakeToolchain(self) tc.variables["q_BUILD_TESTS"] = False tc.variables["q_BUILD_APPS"] = False - tc.generate() def build(self): @@ -88,7 +72,10 @@ def package(self): rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def package_info(self): - self.cpp_info.libs = ["q"] + suffix = "" + if is_msvc(self) and self.settings.build_type == "Debug": + suffix = "d" + self.cpp_info.libs = ["q" + suffix] self.cpp_info.set_property("cmake_file_name", "libq") self.cpp_info.set_property("cmake_target_name", "libq::libq") @@ -96,3 +83,6 @@ def package_info(self): self.cpp_info.system_libs.append("m") self.cpp_info.system_libs.append("pthread") self.cpp_info.system_libs.append("dl") + + if is_msvc(self): + self.cpp_info.cxxflags.append("/bigobj") diff --git a/recipes/libq/all/test_package/test_package.cpp b/recipes/libq/all/test_package/test_package.cpp index 50d84425907de..52347690f10f3 100644 --- a/recipes/libq/all/test_package/test_package.cpp +++ b/recipes/libq/all/test_package/test_package.cpp @@ -1,24 +1,11 @@ #include #include -#include -#include -#include #include -#include + int main(void) { q::initialize(); - - auto ctx = q::make_execution_context("test"); - - std::thread t([&ctx](){ - ctx->dispatcher()->start(); - }); - std::this_thread::yield(); - ctx->dispatcher()->terminate(q::termination::annihilate); - ctx->dispatcher()->await_termination(); - t.join(); - + std::cout << "q initialized correctly" << std::endl; q::uninitialize(); return EXIT_SUCCESS; }