Skip to content

Commit

Permalink
Merge pull request #863 from madebr/libqrencode
Browse files Browse the repository at this point in the history
Add libqrencode/4.0.0 recipe
  • Loading branch information
danimtb authored Mar 2, 2020
2 parents 57f0405 + 3a9ee31 commit 70178f6
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 0 deletions.
7 changes: 7 additions & 0 deletions recipes/libqrencode/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
10 changes: 10 additions & 0 deletions recipes/libqrencode/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sources:
"4.0.0":
url: "https://github.com/fukuchi/libqrencode/archive/v4.0.0.tar.gz"
sha256: "c2c8a8110354463a3332cb48abf8581c8d94136af4dc1418f891cc9c7719e3c1"
patches:
"4.0.0":
- base_path: "source_subfolder"
patch_file: "patches/0001-remove-deprecated-attribute.patch"
- base_path: "source_subfolder"
patch_file: "patches/0002-cmake-fix-install.patch"
77 changes: 77 additions & 0 deletions recipes/libqrencode/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from conans import CMake, ConanFile, tools
import os


class LibqrencodeConan(ConanFile):
name = "libqrencode"
description = "A fast and compact QR Code encoding library"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/fukuchi/libqrencode"
license = ("LGPL-2.1-or-later")
exports_sources = "CMakeLists.txt", "patches/**"
generators = "cmake", "cmake_find_package"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
requires = (
"libiconv/1.15",
"libpng/1.6.37",
)

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.cppstd
del self.settings.compiler.libcxx

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("libqrencode-{}".format(self.version), self._source_subfolder)

def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["WITH_TOOLS"] = False
cmake.definitions["WITH_TESTS"] = False
cmake.configure(build_folder=self._build_subfolder)
return cmake

def _patch_sources(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
cmake.install()

tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_info(self):
lib = "qrencode"
if self.settings.compiler == "Visual Studio" and self.settings.build_type == "Debug":
lib += "d"
self.cpp_info.libs = [lib]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/qrencode.h
+++ b/qrencode.h
@@ -555,7 +555,7 @@ extern char *QRcode_APIVersionString(void);
/**
* @deprecated
*/
-extern void QRcode_clearCache(void) __attribute__ ((deprecated));
+extern void QRcode_clearCache(void);

#if defined(__cplusplus)
}
11 changes: 11 additions & 0 deletions recipes/libqrencode/all/patches/0002-cmake-fix-install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -120,7 +120,7 @@
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qrencode.1 DESTINATION share/man/man1)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqrencode.pc DESTINATION lib/pkgconfig)
install(FILES qrencode.h DESTINATION include)
-install(TARGETS qrencode DESTINATION lib)
+install(TARGETS qrencode ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin)

## Build utility tools
if(WITH_TOOLS AND TARGET PNG::PNG)
10 changes: 10 additions & 0 deletions recipes/libqrencode/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8.11)
project(test_package)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp genqr.h genqr.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/libqrencode/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
Loading

0 comments on commit 70178f6

Please sign in to comment.