-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add libvault 0.48.0 * add class vars * Build fixes * Add CMakeLists.txt * don't always enable coverage flag * update clang version for filesystem support * disable clang11 and libstdc++ combination * try CONAN_PKG::libcurl * maybe fix curl linking * bump apple-clang * Update recipes/libvault/all/conanfile.py Co-authored-by: Uilian Ries <uilianries@gmail.com> * retry ci * address comments * Update recipes/libvault/all/conanfile.py Co-authored-by: Uilian Ries <uilianries@gmail.com> Co-authored-by: Uilian Ries <uilianries@gmail.com>
- Loading branch information
1 parent
ac8c5b0
commit 76d6bce
Showing
8 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory("source_subfolder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sources: | ||
"0.48.0": | ||
url: "https://github.com/abedra/libvault/archive/0.48.0.zip" | ||
sha256: 0a42be282ff0aff77b68cb7238014aa762df5c6b62e4d3561878874ca3760489 | ||
patches: | ||
"0.48.0": | ||
- patch_file: "patches/fix-cmake-0.48.0.patch" | ||
base_path: "source_subfolder" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
from conans import ConanFile, tools, CMake | ||
from conans.errors import ConanInvalidConfiguration | ||
from conans.tools import Version | ||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
|
||
|
||
class LibvaultConan(ConanFile): | ||
name = "libvault" | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/abedra/libvault" | ||
description = "A C++ library for Hashicorp Vault" | ||
topics = ("vault", "libvault", "secrets", "passwords") | ||
settings = "os", "arch", "compiler", "build_type" | ||
exports_sources = ["CMakeLists.txt", "patches/**"] | ||
generators = "cmake", "cmake_find_package" | ||
options = {"shared": [True, False], "fPIC": [True, False]} | ||
default_options = {"shared": False, "fPIC": True} | ||
|
||
_cmake = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
@property | ||
def _build_subfolder(self): | ||
return "build_subfolder" | ||
|
||
@property | ||
def _mac_os_minimum_required_version(self): | ||
return "10.15" | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
|
||
def requirements(self): | ||
self.requires("libcurl/7.80.0") | ||
self.requires("catch2/2.13.7") | ||
|
||
def validate(self): | ||
compiler = str(self.settings.compiler) | ||
compiler_version = Version(self.settings.compiler.version.value) | ||
|
||
minimum_compiler_version = { | ||
"Visual Studio": "19", | ||
"gcc": "8", | ||
"clang": "7.0", | ||
"apple-clang": "12" | ||
} | ||
|
||
minimum_cpp_standard = 17 | ||
|
||
if compiler in minimum_compiler_version and \ | ||
compiler_version < minimum_compiler_version[compiler]: | ||
raise ConanInvalidConfiguration("{} requires a compiler that supports" | ||
" at least C++{}. {} {} is not" | ||
" supported." | ||
.format(self.name, minimum_cpp_standard, compiler, compiler_version)) | ||
|
||
if compiler == "clang" and self.settings.compiler.libcxx in ["libstdc++", "libstdc++11"] and self.settings.compiler.version == "11": | ||
raise ConanInvalidConfiguration("clang 11 with libstdc++ is not supported due to old libstdc++ missing C++17 support") | ||
|
||
if tools.is_apple_os(self.settings.os): | ||
os_version = self.settings.get_safe("os.version") | ||
if os_version and Version(os_version) < self._mac_os_minimum_required_version: | ||
raise ConanInvalidConfiguration( | ||
"Macos Mojave (10.14) and earlier cannot to be built because C++ standard library too old.") | ||
|
||
if self.settings.compiler.get_safe("cppstd"): | ||
tools.check_min_cppstd(self, minimum_cpp_standard) | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) | ||
|
||
def _configure_cmake(self): | ||
if not self._cmake: | ||
self._cmake = CMake(self) | ||
self._cmake.definitions["ENABLE_TEST"] = False | ||
self._cmake.definitions["ENABLE_INTEGRATION_TEST"] = False | ||
self._cmake.definitions["ENABLE_COVERAGE"] = False | ||
self._cmake.definitions["LINK_CURL"] = False | ||
# Set `-mmacosx-version-min` to enable C++17 standard library support. | ||
self._cmake.definitions['CMAKE_OSX_DEPLOYMENT_TARGET'] = self._mac_os_minimum_required_version | ||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
self.copy("LICENSE", dst="licenses", src=self._source_subfolder) | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
|
||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = tools.collect_libs(self) | ||
self.cpp_info.names["cmake_find_package"] = "libvault" | ||
self.cpp_info.names["cmake_find_package_multi"] = "libvault" | ||
self.cpp_info.names["pkg_config"] = "vault" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -4,7 +4,6 @@ | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
-set(CMAKE_CXX_FLAGS_DEBUG --coverage) | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
|
||
option(ENABLE_TEST "Enable tests?" ON) | ||
@@ -14,13 +13,6 @@ | ||
option(BUILD_SHARED_LIBS "Build vault as a shared library" ON) | ||
option(INSTALL "Run install targets" ON) | ||
|
||
-find_package(CURL) | ||
-if (CURL_FOUND) | ||
- include_directories(${CURL_INCLUDE_DIR}) | ||
-else (CURL_FOUND) | ||
- message(FATAL_ERROR "CURL not found") | ||
-endif (CURL_FOUND) | ||
- | ||
include(GNUInstallDirs) | ||
include_directories("${PROJECT_SOURCE_DIR}/lib") | ||
|
||
@@ -120,11 +112,20 @@ | ||
|
||
target_include_directories(vault PRIVATE src) | ||
|
||
+OPTION(UseCurl "UseCurl" ON) | ||
+IF (UseCurl) | ||
+ FIND_PACKAGE(CURL) | ||
+ IF (CURL_FOUND) | ||
+ target_link_libraries(vault CURL::libcurl) | ||
+ ENDIF() | ||
+ENDIF() | ||
+ | ||
if(LINK_CURL) | ||
target_link_libraries(vault curl) | ||
endif(LINK_CURL) | ||
|
||
if (ENABLE_COVERAGE) | ||
+ set(CMAKE_CXX_FLAGS_DEBUG --coverage) | ||
target_link_libraries(vault gcov) | ||
endif () | ||
|
||
@@ -155,7 +156,7 @@ | ||
"${CMAKE_CURRENT_BINARY_DIR}/libvaultConfigVersion.cmake" | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libvault") | ||
|
||
- configure_file(vault.pc.in vault.pc @ONLY) | ||
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/vault.pc.in" "${CMAKE_BINARY_DIR}/vault.pc" @ONLY) | ||
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") | ||
endif (INSTALL) | ||
@@ -176,7 +177,7 @@ | ||
target_include_directories(libvault_test PRIVATE include) | ||
|
||
target_link_libraries(libvault_test vault) | ||
- target_link_libraries(libvault_test curl) | ||
+ target_link_libraries(libvault_test CURL::libcurl) | ||
target_link_libraries(libvault_test Catch2::Catch2) | ||
|
||
include(CTest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(PackageTest CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(Libvault CONFIG REQUIRED) | ||
|
||
add_executable(example example.cpp) | ||
set_property(TARGET example PROPERTY CXX_STANDARD 17) | ||
target_link_libraries(example libvault::libvault) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
|
||
class LibvaultTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
self.run(os.path.join("bin", "example"), run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <libvault/VaultClient.h> | ||
|
||
int main() | ||
{ | ||
Vault::Config config = Vault::ConfigBuilder().build(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.48.0": | ||
folder: "all" |