Skip to content

Commit

Permalink
(#8956) xmlsec: modernize
Browse files Browse the repository at this point in the history
* modernize

* bump openssl

* use conan.tools.microsoft.msvc_runtime_flag()
  • Loading branch information
SpaceIm authored Jan 21, 2022
1 parent 145e4c3 commit 49b1cb5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions recipes/xmlsec/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from conan.tools.microsoft import msvc_runtime_flag
from conans import ConanFile, tools, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment
from conans.errors import ConanInvalidConfiguration
from contextlib import contextmanager
import os

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.36.0"


class XmlSecConan(ConanFile):
Expand All @@ -14,7 +15,7 @@ class XmlSecConan(ConanFile):
url = "https://github.com/conan-io/conan-center-index"
topics = ("xml", "signature", "encryption")

settings = "os", "compiler", "arch", "build_type"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
Expand All @@ -37,7 +38,11 @@ def _source_subfolder(self):

@property
def _is_msvc(self):
return self.settings.compiler == "Visual Studio"
return str(self.settings.compiler) in ["Visual Studio", "msvc"]

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def config_options(self):
if self.settings.os == "Windows":
Expand All @@ -52,18 +57,14 @@ def configure(self):
def requirements(self):
self.requires("libxml2/2.9.12")
if self.options.with_openssl:
self.requires("openssl/1.1.1k")
self.requires("openssl/1.1.1m")
if self.options.with_xslt:
self.requires("libxslt/1.1.34")

def validate(self):
if not self.options.with_openssl:
raise ConanInvalidConfiguration("At least one crypto engine needs to be enabled")

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def build_requirements(self):
if not self._is_msvc:
self.build_requires("libtool/2.4.6")
Expand Down Expand Up @@ -93,7 +94,7 @@ def _build_msvc(self):
"cscript",
"configure.js",
"prefix={}".format(self.package_folder),
"cruntime=/{}".format(self.settings.compiler.runtime),
"cruntime=/{}".format(msvc_runtime_flag(self)),
"debug={}".format(yes_no(self.settings.build_type == "Debug")),
"static={}".format(yes_no(not self.options.shared)),
"include=\"{}\"".format(";".join(self.deps_cpp_info.include_paths)),
Expand Down Expand Up @@ -198,7 +199,9 @@ def package_info(self):
self.cpp_info.components["libxmlsec"].libs = [get_libname(None)]
self.cpp_info.components["libxmlsec"].includedirs.append(os.path.join("include", "xmlsec{}".format(tools.Version(self.version).major)))
self.cpp_info.components["libxmlsec"].requires = ["libxml2::libxml2"]
self.cpp_info.components["libxmlsec"].names["pkg_config"] = "xmlsec{}".format(tools.Version(self.version).major)
self.cpp_info.components["libxmlsec"].set_property(
"pkg_config_name", "xmlsec{}".format(tools.Version(self.version).major)
)
if not self.options.shared:
self.cpp_info.components["libxmlsec"].defines.append("XMLSEC_STATIC")
if self.options.with_xslt:
Expand All @@ -215,4 +218,6 @@ def package_info(self):
self.cpp_info.components["openssl"].libs = [get_libname("openssl")]
self.cpp_info.components["openssl"].requires = ["libxmlsec", "openssl::openssl"]
self.cpp_info.components["openssl"].defines = ["XMLSEC_CRYPTO_OPENSSL=1"]
self.cpp_info.components["openssl"].names["pkg_config"] = "xmlsec{}-openssl".format(tools.Version(self.version).major)
self.cpp_info.components["openssl"].set_property(
"pkg_config_name", "xmlsec{}-openssl".format(tools.Version(self.version).major)
)
2 changes: 1 addition & 1 deletion recipes/xmlsec/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
CONAN_BASIC_SETUP(TARGETS)
Expand Down

0 comments on commit 49b1cb5

Please sign in to comment.