Skip to content

libucl: add version 0.8.2, support conan v2 #15208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions recipes/libucl/all/CMakeLists.txt

This file was deleted.

34 changes: 31 additions & 3 deletions recipes/libucl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
sources:
"0.8.2":
url: "https://github.com/vstakhov/libucl/archive/refs/tags/0.8.2.tar.gz"
sha256: "d95a0e2151cc167a0f3e51864fea4e8977a0f4c473faa805269a347f7fb4e165"
"0.8.1":
url: "https://github.com/vstakhov/libucl/archive/refs/tags/0.8.1.tar.gz"
sha256: "a6397e179672f0e8171a0f9a2cfc37e01432b357fd748b13f4394436689d24ef"
patches:
"0.8.2":
- patch_file: "patches/0001-0.8.1-shared-win32.patch"
patch_description: "fix UCL_EXTERN definition for shared build on win32"
patch_type: "portability"
- patch_file: "patches/0002-0.8.2-cmake-add-install+use-find_package.patch"
patch_description: "improve installation, use cci package"
patch_type: "conan"
- patch_file: "patches/0003-no-strings-h.patch"
patch_description: "include string.h instead of strings.h"
patch_type: "portability"
- patch_file: "patches/0004-0.8.2-cmake-minimum-required.patch"
patch_description: "declare cmake_minimum_required first"
patch_type: "portability"
- patch_file: "patches/0005-0.8.1-add-_tmp.patch"
patch_description: "add _tmp variables in sort macros"
patch_type: "portability"
"0.8.1":
- patch_file: "patches/0001-0.8.1-shared-win32.patch"
base_path: "source_subfolder"
patch_description: "fix UCL_EXTERN definition for shared build on win32"
patch_type: "portability"
- patch_file: "patches/0002-0.8.1-cmake-add-install+use-find_package.patch"
base_path: "source_subfolder"
patch_description: "improve installation, use cci package"
patch_type: "conan"
- patch_file: "patches/0003-no-strings-h.patch"
base_path: "source_subfolder"
patch_description: "include string.h instead of strings.h"
patch_type: "portability"
- patch_file: "patches/0004-0.8.1-cmake-minimum-required.patch"
patch_description: "declare cmake_minimum_required first"
patch_type: "portability"
- patch_file: "patches/0005-0.8.1-add-_tmp.patch"
patch_description: "add _tmp variables in sort macros"
patch_type: "portability"
73 changes: 39 additions & 34 deletions recipes/libucl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from conans import CMake, ConanFile, tools
import functools

required_conan_version = ">=1.33.0"
from conan import ConanFile
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
import os

required_conan_version = ">=1.53.0"

class LibuclConan(ConanFile):
name = "libucl"
description = "Universal configuration library parser"
license = "BSD-2-Clause"
homepage = "https://github.com/vstakhov/libucl"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/vstakhov/libucl"
topics = ("universal", "configuration", "language", "parser", "ucl")
settings = "os", "compiler", "build_type", "arch"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
Expand All @@ -27,61 +28,65 @@ class LibuclConan(ConanFile):
"with_lua": False,
}

generators = "cmake", "cmake_find_package_multi"
exports_sources = "CMakeLists.txt", "patches/*"

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

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.libcxx
del self.settings.compiler.cppstd
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
if self.options.enable_url_include:
self.requires("libcurl/7.84.0")
self.requires("libcurl/7.86.0")
if self.options.enable_url_sign:
self.requires("openssl/1.1.1q")
self.requires("openssl/1.1.1s")
if self.options.with_lua == "lua":
self.requires("lua/5.4.4")
elif self.options.with_lua == "luajit":
self.requires("luajit/2.0.5")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

@functools.lru_cache(1)
def _configure_cmake(self):
cmake = CMake(self)
def generate(self):
tc = CMakeToolchain(self)
on_off = lambda v: "ON" if v else "OFF"
cmake.definitions["ENABLE_URL_INCLUDE"] = on_off(self.options.enable_url_include)
cmake.definitions["ENABLE_URL_SIGN"] = on_off(self.options.enable_url_sign)
cmake.definitions["ENABLE_LUA"] = on_off(self.options.with_lua == "lua")
cmake.definitions["ENABLE_LUAJIT"] = on_off(self.options.with_lua == "luajit")
cmake.configure()
return cmake
tc.variables["ENABLE_URL_INCLUDE"] = on_off(self.options.enable_url_include)
tc.variables["ENABLE_URL_SIGN"] = on_off(self.options.enable_url_sign)
tc.variables["ENABLE_LUA"] = on_off(self.options.with_lua == "lua")
tc.variables["ENABLE_LUAJIT"] = on_off(self.options.with_lua == "luajit")
tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
cmake = self._configure_cmake()
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
self.copy("COPYING", src=self._source_subfolder, dst="licenses", keep_path=False)
cmake = self._configure_cmake()
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.libs = ["ucl"]
self.cpp_info.names["pkg_config"] = "libucl"
if self.settings.os == "Windows" and not self.options.shared:
self.cpp_info.defines.append("UCL_STATIC")

self.cpp_info.set_property("pkg_config_name", "libucl")

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.names["pkg_config"] = "libucl"
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
- Fixes dll/static cmake builds
- Fixes libcurl
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -4,13 +4,13 @@
SET(LIBUCL_VERSION_MAJOR 0)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b55faf..f1da7ea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,11 +5,14 @@ SET(LIBUCL_VERSION_MAJOR 0)
SET(LIBUCL_VERSION_MINOR 5)
SET(LIBUCL_VERSION_PATCH 0)
-
-SET(LIBUCL_VERSION
- "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}")
+SET(LIBUCL_VERSION "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}")
-
INCLUDE(CheckCCompilerFlag)
-INCLUDE(FindOpenSSL)
-
+IF(ENABLE_URL_SIGN)
+ FIND_PACKAGE(OpenSSL REQUIRED)
+ SET(HAVE_OPENSSL 1)
+ ADD_DEFINITIONS(-DHAVE_OPENSSL)
+ENDIF(ENABLE_URL_SIGN)

OPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF)
OPTION(ENABLE_URL_SIGN "Enable signatures check in ucl includes (requires openssl) [default: OFF]" OFF)
OPTION(BUILD_SHARED_LIBS "Build Shared Libraries [default: OFF]" OFF)
@@ -131,31 +131,31 @@
@@ -131,31 +134,11 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt)
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")

Expand Down Expand Up @@ -54,40 +52,17 @@
+IF(ENABLE_URL_INCLUDE)
+ FIND_PACKAGE(CURL REQUIRED)
+ ADD_DEFINITIONS(-DCURL_FOUND)
+ SET(CURL_LIBRARIES CURL::CURL)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SET(CURL_LIBRARIES CURL::libcurl)
+ENDIF()

SET(CMAKE_C_WARN_FLAGS "")
CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL)
@@ -214,4 +214,4 @@
@@ -214,35 +198,22 @@ IF (BUILD_SHARED_LIBS)
ENDIF (BUILD_SHARED_LIBS)
ADD_LIBRARY(ucl ${LIB_TYPE} ${UCLSRC})
SET_TARGET_PROPERTIES(ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR})
-
+INSTALL(TARGETS ucl RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
@@ -218,29 +218,29 @@
-IF(ENABLE_LUA MATCHES "ON")
+IF(ENABLE_LUA OR ENABLE_LUAJIT)
- IF(ENABLE_LUAJIT MATCHES "ON")
- FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}")
- IF(NOT LUA_FOUND)
Expand All @@ -106,6 +81,8 @@
- INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")
- ENDIF(NOT LUA_FOUND)
- ENDIF(ENABLE_LUAJIT MATCHES "ON")
+INSTALL(TARGETS ucl RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
+IF(ENABLE_LUA OR ENABLE_LUAJIT)
SET(UCL_LUA_SRC lua/lua_ucl.c)
ADD_LIBRARY(lua-ucl ${LIB_TYPE} ${UCL_LUA_SRC})
- IF(ENABLE_LUAJIT MATCHES "ON")
Expand All @@ -115,32 +92,20 @@
- ENDIF(ENABLE_LUAJIT MATCHES "ON")
TARGET_LINK_LIBRARIES(lua-ucl ucl)
SET_TARGET_PROPERTIES(lua-ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR})
-ENDIF()
+
+
+ IF(ENABLE_LUA)
+ FIND_PACKAGE(lua REQUIRED CONFIG)
+ TARGET_LINK_LIBRARIES(lua-ucl lua::lua)
+
+ ELSEIF(ENABLE_LUAJIT)
+ FIND_PACKAGE(luajit REQUIRED CONFIG)
+ TARGET_LINK_LIBRARIES(lua-ucl luajit::luajit)
+ ENDIF()
+
+
+
+
+
+
+
+
+
+
+
+ INSTALL(TARGETS lua-ucl RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
+ INSTALL(FILES include/lua_ucl.h DESTINATION include)
+ENDIF()
@@ -257,3 +257,4 @@
+ IF(ENABLE_LUA)
+ FIND_PACKAGE(lua REQUIRED CONFIG)
+ TARGET_LINK_LIBRARIES(lua-ucl lua::lua)
+
+ ELSEIF(ENABLE_LUAJIT)
+ FIND_PACKAGE(luajit REQUIRED CONFIG)
+ TARGET_LINK_LIBRARIES(lua-ucl luajit::luajit)
+ ENDIF()
+ INSTALL(TARGETS lua-ucl RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
+ INSTALL(FILES include/lua_ucl.h DESTINATION include)
ENDIF()

IF(HAVE_FETCH_H)
@@ -257,3 +228,4 @@ IF(ENABLE_URL_SIGN MATCHES "ON")
TARGET_LINK_LIBRARIES(ucl ${OPENSSL_LIBRARIES})
ENDIF(OPENSSL_FOUND)
ENDIF(ENABLE_URL_SIGN MATCHES "ON")
Expand Down
Loading