From 332dc26de81c45af7b1c2c69b05bf2cfd857bd95 Mon Sep 17 00:00:00 2001 From: staylor Date: Mon, 13 May 2024 14:46:48 -0500 Subject: [PATCH] Build both C and C++ libraries every time --- recipes/qr-code-generator/all/CMakeLists.txt | 21 ++++++-------- recipes/qr-code-generator/all/conanfile.py | 30 +++++--------------- 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/recipes/qr-code-generator/all/CMakeLists.txt b/recipes/qr-code-generator/all/CMakeLists.txt index 559c32e74f13dc..7629857f9b79e7 100644 --- a/recipes/qr-code-generator/all/CMakeLists.txt +++ b/recipes/qr-code-generator/all/CMakeLists.txt @@ -1,19 +1,16 @@ cmake_minimum_required(VERSION 3.15) project(QR-Code-Generator) -include(src/files.cmake) -IF (COMPILE_AS_C) - set(SRC ${CMAKE_SOURCE_DIR}/src/c/qrcodegen.c) - set(CMAKE_C_STANDARD 99) - set(LIBRARY_NAME qrcodegenc) - set(HEADERS ${CMAKE_SOURCE_DIR}/src/c/qrcodegen.h) - set(INCLUDE_DIR qrcodegenc) -ELSE () - set(INCLUDE_DIR qrcodegen) -ENDIF () +set(SRC_C ${CMAKE_SOURCE_DIR}/src/c/qrcodegen.c) +set(LIBRARY_NAME_C qrcodegenc) +set(HEADERS_C ${CMAKE_SOURCE_DIR}/src/c/qrcodegen.h) -add_library(${LIBRARY_NAME} ${SRC}) +add_library(${LIBRARY_NAME_C} ${SRC_C}) +set_target_properties(${LIBRARY_NAME_C} PROPERTIES PUBLIC_HEADER "${HEADERS_C}") +install(TARGETS ${LIBRARY_NAME_C} RUNTIME LIBRARY ARCHIVE PUBLIC_HEADER DESTINATION include/qrcodegenc) +include(src/files.cmake) +add_library(${LIBRARY_NAME} ${SRC}) set_target_properties(${LIBRARY_NAME} PROPERTIES PUBLIC_HEADER "${HEADERS}") -install(TARGETS ${LIBRARY_NAME} RUNTIME LIBRARY ARCHIVE PUBLIC_HEADER DESTINATION include/${INCLUDE_DIR}) +install(TARGETS ${LIBRARY_NAME} RUNTIME LIBRARY ARCHIVE PUBLIC_HEADER DESTINATION include/qrcodegen) diff --git a/recipes/qr-code-generator/all/conanfile.py b/recipes/qr-code-generator/all/conanfile.py index 93d015474994b4..b1e86986b2a22f 100644 --- a/recipes/qr-code-generator/all/conanfile.py +++ b/recipes/qr-code-generator/all/conanfile.py @@ -27,12 +27,10 @@ class QrCodeGeneratorConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], - "compile_as_c": [True, False], } default_options = { "shared": False, "fPIC": True, - "compile_as_c": False, } @property @@ -56,10 +54,6 @@ def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - if not self.options.compile_as_c: - self.options.rm_safe("compiler.libcxx") - self.options.rm_safe("compiler.cppstd") - def layout(self): cmake_layout(self, src_folder="src") @@ -77,13 +71,10 @@ def source(self): def generate(self): tc = CMakeToolchain(self) - tc.variables["COMPILE_AS_C"] = self.options.compile_as_c if self.settings.os == "Windows" and self.options.shared: tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True if not valid_min_cppstd(self, self._min_cppstd): tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd - if not valid_min_cppstd(self, self._min_cppstd): - tc.variables["CMAKE_C_STANDARD"] = "11" tc.generate() def build(self): @@ -93,14 +84,10 @@ def build(self): cmake.build() def _extract_license(self): - if self.options.compile_as_c: - header_name = ("qrcodegen.h") - header = load(self, os.path.join(self.source_folder, "c", header_name)) - else: - header_name = ( - "QrCode.hpp" if Version(self.version) < "1.7.0" else "qrcodegen.hpp" - ) - header = load(self, os.path.join(self.source_folder, "cpp", header_name)) + header_name = ( + "QrCode.hpp" if Version(self.version) < "1.7.0" else "qrcodegen.hpp" + ) + header = load(self, os.path.join(self.source_folder, "cpp", header_name)) license_contents = header[2 : header.find("*/", 1)] return license_contents @@ -114,12 +101,9 @@ def package(self): cmake.install() def package_info(self): - if self.options.compile_as_c: - self.cpp_info.libs = ["qrcodegen"] - else: - self.cpp_info.libs =[ - "qrcodegen" if Version(self.version) < "1.7.0" else "qrcodegencpp" - ] + self.cpp_info.libs = [ + "qrcodegen" if Version(self.version) < "1.7.0" else "qrcodegencpp" + ] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m")