Skip to content

Commit

Permalink
(#9994) - [libgettext] fix clang-cl
Browse files Browse the repository at this point in the history
Signed-off-by: SSE4 <tomskside@gmail.com>
  • Loading branch information
SSE4 committed Apr 9, 2022
1 parent 604da45 commit f2a9a4b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions recipes/libgettext/all/conanfile.py
Expand Up @@ -32,6 +32,10 @@ def _source_subfolder(self):
def _is_msvc(self):
return str(self.settings.compiler) in ["Visual Studio", "msvc"]

@property
def _is_clang_cl(self):
return str(self.settings.compiler) in ["clang"] and str(self.settings.os) in ["Windows"]

@property
def _gettext_folder(self):
return "gettext-tools"
Expand Down Expand Up @@ -71,7 +75,7 @@ def _user_info_build(self):
def build_requirements(self):
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/cci.latest")
if self._is_msvc:
if self._is_msvc or self._is_clang_cl:
self.build_requires("automake/1.16.4")

def source(self):
Expand Down Expand Up @@ -102,7 +106,7 @@ def build(self):
args.extend(["--disable-static", "--enable-shared"])
else:
args.extend(["--disable-shared", "--enable-static"])
if self._is_msvc:
if self._is_msvc or self._is_clang_cl:
# INSTALL.windows: Native binaries, built using the MS Visual C/C++ tool chain.
build = False
if self.settings.arch == "x86":
Expand All @@ -111,16 +115,19 @@ def build(self):
elif self.settings.arch == "x86_64":
host = "x86_64-w64-mingw32"
rc = "windres --target=pe-x86-64"
args.extend(["CC=%s cl -nologo" % tools.unix_path(self._user_info_build["automake"].compile),
"LD=link",
cl = "cl" if self._is_msvc else os.environ.get("CC", 'clang-cl')
lib = "lib" if self._is_msvc else os.environ.get('AR', "llvm-lib")
link = "link" if self._is_msvc else os.environ.get("LD", "lld-link")
args.extend(["CC=%s %s -nologo" % (tools.unix_path(self._user_info_build["automake"].compile), cl),
"LD=%s" % link,
"NM=dumpbin -symbols",
"STRIP=:",
"AR=%s lib" % tools.unix_path(self._user_info_build["automake"].ar_lib),
"AR=%s %s" % (tools.unix_path(self._user_info_build["automake"].ar_lib), lib),
"RANLIB=:"])
if rc:
args.extend(['RC=%s' % rc, 'WINDRES=%s' % rc])
with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():
with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op():
with tools.vcvars(self.settings) if (self._is_msvc or self._is_clang_cl) else tools.no_op():
with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if (self._is_msvc or self._is_clang_cl) else tools.no_op():
with tools.chdir(os.path.join(self._source_subfolder, self._gettext_folder)):
env_build = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
if self._is_msvc:
Expand All @@ -140,7 +147,7 @@ def package(self):
self.copy(pattern="*libgnuintl.h", dst="include", src=self._source_subfolder, keep_path=False)
tools.rename(os.path.join(self.package_folder, "include", "libgnuintl.h"),
os.path.join(self.package_folder, "include", "libintl.h"))
if self._is_msvc and self.options.shared:
if (self._is_msvc or self._is_clang_cl) and self.options.shared:
tools.rename(os.path.join(self.package_folder, "lib", "gnuintl.dll.lib"),
os.path.join(self.package_folder, "lib", "gnuintl.lib"))

Expand Down

0 comments on commit f2a9a4b

Please sign in to comment.