Skip to content

Commit

Permalink
libidn2: add shared MSVC build support
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Dec 8, 2023
1 parent 2a68a19 commit 9edc648
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions recipes/libidn2/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import cross_building
from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rmdir
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, unix_path
Expand Down Expand Up @@ -57,12 +56,6 @@ def layout(self):
def requirements(self):
self.requires("libiconv/1.17")

def validate(self):
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration(
"Shared libraries are not supported on Windows due to libtool limitation"
)

def build_requirements(self):
if self._settings_build.os == "Windows":
self.win_bash = True
Expand Down Expand Up @@ -91,6 +84,7 @@ def generate(self):
f"--with-libiconv-prefix={unix_path(self, self.dependencies['libiconv'].package_folder)}",
"--disable-nls",
"--disable-rpath",
"lt_cv_sys_global_symbol_pipe=cat", # for nm on MSVC
]
tc.generate()

Expand All @@ -112,11 +106,12 @@ def generate(self):
automake_conf = self.dependencies.build["automake"].conf_info
compile_wrapper = unix_path(self, automake_conf.get("user.automake:compile-wrapper", check_type=str))
ar_wrapper = unix_path(self, automake_conf.get("user.automake:lib-wrapper", check_type=str))
dumpbin_nm = unix_path(self, os.path.join(self.source_folder, "dumpbin_nm.py"))
env.define("CC", f"{compile_wrapper} cl -nologo")
env.define("CXX", f"{compile_wrapper} cl -nologo")
env.define("LD", "link -nologo")
env.define("AR", f'{ar_wrapper} lib')
env.define("NM", "dumpbin -symbols")
env.define("NM", f"python {dumpbin_nm}")
env.define("OBJDUMP", ":")
env.define("RANLIB", ":")
env.define("STRIP", ":")
Expand All @@ -137,8 +132,18 @@ def package(self):
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))

if is_msvc(self) and self.options.shared:
os.rename(os.path.join(self.package_folder, "lib", "idn2.dll.lib"),
os.path.join(self.package_folder, "lib", "idn2-0.lib"))
copy(self, "idn2.exe",
os.path.join(self.build_folder, "src", ".libs"),
os.path.join(self.package_folder, "bin"))

def package_info(self):
self.cpp_info.libs = ["idn2"]
if is_msvc(self) and self.options.shared:
self.cpp_info.libs = ["idn2-0"]
else:
self.cpp_info.libs = ["idn2"]
self.cpp_info.set_property("pkg_config_name", "libidn2")
if self.settings.os == "Windows":
if not self.options.shared:
Expand Down

0 comments on commit 9edc648

Please sign in to comment.