Skip to content

[libdb] Conan 2.0 migration #17806

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 13 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 11 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
11 changes: 6 additions & 5 deletions recipes/libdb/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ sources:
patches:
"5.3.28":
- patch_file: "patches/0001-rename_atomic_compare_exchange.patch"
base_path: "source_subfolder"
patch_description: "Rename __atomic_compare_exchange to __atomic_compare_exchange_db"
patch_type: "portability"
- patch_file: "patches/0002-no-conditional-tcl-include.patch"
base_path: "source_subfolder"
patch_description: "Always include tcl.h. Remove conditions."
patch_type: "conan"
- patch_file: "patches/0003-msvc-db_tcl-add-static-configuration.patch"
base_path: "source_subfolder"
- patch_file: "patches/0004-msvc-tcl-include-conanbuildinfo-props.patch"
base_path: "source_subfolder"
patch_description: "Add static configuration"
patch_type: "conan"
201 changes: 112 additions & 89 deletions recipes/libdb/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from conan import ConanFile
from conan import ConanFile, conan_version
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, replace_in_file, rename, rm, rmdir
from conan.tools.microsoft import is_msvc, check_min_vs, unix_path
from conan.tools.microsoft import MSBuild, MSBuildDeps, MSBuildToolchain, is_msvc, check_min_vs, vs_layout
from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
# FIXME: Needs to be migrted to Conan v2
from conans import AutoToolsBuildEnvironment, MSBuild
from conans import tools as legacy_tools
from conan.tools.apple import fix_apple_shared_install_name

import glob
import os
import shutil

required_conan_version = ">=1.55.0"

Expand All @@ -35,13 +36,6 @@ class LibdbConan(ConanFile):
"with_cxx": False,
}

generators = "visual_studio"

_autotools = None

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

@property
def _mingw_build(self):
Expand All @@ -51,18 +45,14 @@ def _mingw_build(self):
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

@property
def _user_info_build(self):
return getattr(self, "user_info_build", self.deps_user_info)

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if self.settings.compiler == "Visual Studio":
del self.options.with_cxx
self.options.rm_safe("fPIC")
if is_msvc(self):
self.options.rm_safe("with_cxx")

def configure(self):
if self.options.shared:
Expand All @@ -76,90 +66,99 @@ def requirements(self):
self.requires("tcl/8.6.10")

def validate(self):
if is_msvc(self) and check_min_vs(self, "191", raise_invalid=False):
if is_msvc(self) and check_min_vs(self, "192", raise_invalid=False):
# FIXME: it used to work with previous versions of Visual Studio 2019 in CI of CCI.
# Currently won't work with Visual Studio 2019 or newer
raise ConanInvalidConfiguration(f"{self.ref} Visual Studio 2019 is currently not supported. Contributions are welcomed!")

if self.settings.os == "Macos" and self.settings.arch == "armv8":
raise ConanInvalidConfiguration(f"{self.ref} Macos Apple Sillicon is currently not supported. Contributions are welcomed!")

if self.options.get_safe("with_cxx"):
if self.settings.compiler == "clang" and Version(self.settings.compiler.version) < "6":
raise ConanInvalidConfiguration(f"{self.ref} does no support clang<6 with_cxx=True")
raise ConanInvalidConfiguration(f"{self.ref} does not support clang<6 with_cxx=True")
if self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) < "10":
raise ConanInvalidConfiguration(f"{self.ref} does no support apple-clang<10 with_cxx=True")
raise ConanInvalidConfiguration(f"{self.ref} does not support apple-clang<10 with_cxx=True")

def build_requirements(self):
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
if not self._settings_build.os == "Windows":
self.tool_requires("gnu-config/cci.20201022")

def layout(self):
if is_msvc(self):
vs_layout(self)
else:
basic_layout(self, src_folder="src")

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

def _patch_sources(self):
apply_conandata_patches(self)

if is_msvc(self):
if not is_msvc(self):
for subdir in [
"dist",
os.path.join("lang", "sql", "jdbc"),
os.path.join("lang", "sql", "odbc"),
os.path.join("lang", "sql", "sqlite"),
]:
for gnu_config in [
self.conf.get("user.gnu-config:config_guess", check_type=str),
self.conf.get("user.gnu-config:config_sub", check_type=str),
]:
if gnu_config:
copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=os.path.join(self._source_subfolder, subdir))

for file in glob.glob(os.path.join(self._source_subfolder, "build_windows", "VS10", "*.vcxproj")):
shutil.copy(self.dependencies.build["gnu-config"].conf_info.get("user.gnu-config:config_sub"),
os.path.join(self.source_folder, subdir, "config.sub"))
shutil.copy(self.dependencies.build["gnu-config"].conf_info.get("user.gnu-config:config_guess"),
os.path.join(self.source_folder, subdir, "config.guess"))

for file in glob.glob(os.path.join(self.source_folder, "build_windows", "VS10", "*.vcxproj")):
# The WindowsTargetPlatformVersion selected below will depend on what Windows SDK is installed.
replace_in_file(self, file,
"<PropertyGroup Label=\"Globals\">",
"<PropertyGroup Label=\"Globals\"><WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>")
# 10.0 should select the "latest" SDK available, but doesn't always work. It may be necessary to specify a specific version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This concerns me a little bit. "10.0" for the "latest available" is the documented behaviour: https://learn.microsoft.com/en-us/cpp/build/reference/general-property-page-project?view=msvc-170, and from what I can see this applies to versions 2015-2022.

Is this not the case? it would be good to document when this is a problem. Visual Studio 2015 has a maximum version, but apart from this I dont think there is an issue? https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2014%202015.html#windows-10-sdk-maximum-version-for-vs-2015

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, with this definition locally, I get the following error

replace_in_file(self, file,
            "<PropertyGroup Label=\"Globals\">",
            "<PropertyGroup Label=\"Globals\"><WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>")
The Windows SDK version 10.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Us
ers\user\.conan2\p\b\libdb691c014fe45c0\b\build_windows\VS10\db.vcxproj]

My understanding is the same as yours - this should work. You'll note that the previous implementation uses a specific SDK value - this was an improvement i tried to make, because if the specific SDK isn't installed on the build system then this will fail. My hope is that using 10.0 will work on someones system, but this is an artifact of my specific environment. Using either of the following resolves this error:

replace_in_file(self, file,
            "<PropertyGroup Label=\"Globals\">",
            "<PropertyGroup Label=\"Globals\"><WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>")
replace_in_file(self, file,
            "<PropertyGroup Label=\"Globals\">",
            "<PropertyGroup Label=\"Globals\"><WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>")

This is the only reason these are here as comment - they're what works for me locally. Obviously, since this PR only presents VS2017 compatibility (not 2019 or 2022), this won't be exercised by the CI anyway. I banged my head on a wall for a while with this one and this is far as I could take it without someone more experienced taking a look. If anybody has a suggestion for how to generalise this more, I'm happy to take it. Otherwise, we should compromise to get this recipe updated and iterate as necessary.

Logs for failure:

$ conan create . --version 5.3.28 --user user --channel testing -s:h compiler.version=191 -s:b compiler.version=191

======== Exporting recipe to the cache ========
libdb/5.3.28@user/testing: Exporting package recipe: C:\users\user\projects\conan-center-index\recipes\libdb\all\conanfile.py
libdb/5.3.28@user/testing: exports: File 'conandata.yml' found. Exporting it...
libdb/5.3.28@user/testing: Calling export_sources()
libdb/5.3.28@user/testing: Copied 1 '.yml' file: conandata.yml
libdb/5.3.28@user/testing: Copied 1 '.py' file: conanfile.py
libdb/5.3.28@user/testing: Copied 3 '.patch' files: 0001-rename_atomic_compare_exchange.patch, 0002-no-conditional-tcl-include.patch, 0003-msvc-db_tcl-add-static-configuration.patch
libdb/5.3.28@user/testing: Exported to cache folder: C:\Users\user\.conan2\p\libdb669a6ac9034ea\e
libdb/5.3.28@user/testing: Exported: libdb/5.3.28@user/testing#f57e9d9c23f6df8ac5fcceda7f6567bb (2023-08-21 12:28:42 UTC)

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=static
compiler.runtime_type=Release
compiler.update=None
compiler.version=191
os=Windows
os.subsystem=None

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=static
compiler.runtime_type=Release
compiler.update=None
compiler.version=191
os=Windows
os.subsystem=None


======== Computing dependency graph ========
Graph root
    cli
Requirements
    libdb/5.3.28@user/testing#f57e9d9c23f6df8ac5fcceda7f6567bb - Cache

======== Computing necessary packages ========
libdb/5.3.28@user/testing: Forced build from source
Requirements
    libdb/5.3.28@user/testing#f57e9d9c23f6df8ac5fcceda7f6567bb:47ecdd4ab563a726531e9e64a19e19e2c06b73c5 - Build

======== Installing packages ========
libdb/5.3.28@user/testing: Calling source() in C:\Users\user\.conan2\p\libdb669a6ac9034ea\s\.
libdb/5.3.28@user/testing: Downloading 35.1MB db-5.3.28.tar.gz

-------- Installing package libdb/5.3.28@user/testing (1 of 1) --------
libdb/5.3.28@user/testing: Building from source
libdb/5.3.28@user/testing: Package libdb/5.3.28@user/testing:47ecdd4ab563a726531e9e64a19e19e2c06b73c5
libdb/5.3.28@user/testing: Copying sources to build folder
libdb/5.3.28@user/testing: Building your package in C:\Users\user\.conan2\p\b\libdb691c014fe45c0\b
libdb/5.3.28@user/testing: Calling generate()
libdb/5.3.28@user/testing: Generators folder: C:\Users\user\.conan2\p\b\libdb691c014fe45c0\b\conan
libdb/5.3.28@user/testing: MSBuildToolchain created conantoolchain_release_x64.props
libdb/5.3.28@user/testing: MSBuildToolchain writing conantoolchain.props
libdb/5.3.28@user/testing: Generating aggregated env files
libdb/5.3.28@user/testing: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
libdb/5.3.28@user/testing: Calling build()
libdb/5.3.28@user/testing: Apply patch (portability): Rename __atomic_compare_exchange to __atomic_compare_exchange_db
libdb/5.3.28@user/testing: Apply patch (conan): Always include tcl.h. Remove conditions.
libdb/5.3.28@user/testing: Apply patch (conan): Add static configuration
libdb/5.3.28@user/testing: RUN: msbuild "C:\Users\user\.conan2\p\b\libdb691c014fe45c0\b\.\build_windows\VS10\db.vcxproj" /p:Configuration="Static Release" /p:Platform=x64
conanvcvars.bat: Activating environment Visual Studio 15 - amd64 - vcvars_ver=14.1
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 21/08/2023 10:00:09 PM.
Project "C:\Users\user\.conan2\p\b\libdb691c014fe45c0\b\build_windows\VS10\db.vcxproj" on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Us
ers\user\.conan2\p\b\libdb691c014fe45c0\b\build_windows\VS10\db.vcxproj]
Done Building Project "C:\Users\user\.conan2\p\b\libdb691c014fe45c0\b\build_windows\VS10\db.vcxproj" (default targets) -- FAILED.


Build FAILED.

"C:\Users\user\.conan2\p\b\libdb691c014fe45c0\b\build_windows\VS10\db.vcxproj" (default target) (1) ->
(_CheckWindowsSDKInstalled target) ->
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\
Users\user\.conan2\p\b\libdb691c014fe45c0\b\build_windows\VS10\db.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.57

libdb/5.3.28@user/testing: ERROR:
Package '47ecdd4ab563a726531e9e64a19e19e2c06b73c5' build failed
libdb/5.3.28@user/testing: WARN: Build folder C:\Users\user\.conan2\p\b\libdb691c014fe45c0\b\.
*********************************************************
Recipe 'libdb/5.3.28@user/testing' cannot build its binary
It is possible that this recipe is not Conan 2.0 ready
If the recipe comes from ConanCenter check: https://conan.io/cci-v2.html
If it is your recipe, check if it is updated to 2.0
*********************************************************

ERROR: libdb/5.3.28@user/testing: Error in build() method, line 213
        msbuild.build(sln=project_file)
        ConanException: Error 1 while executing

Copy link
Contributor Author

@samuel-emrys samuel-emrys Oct 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@conan-io/barbarians has anybody got any ideas on how to get the windows build to pass/to upgrade the project successfully?
Edit: doesn't look like the suggested ping does anything

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuel-emrys We have a template for MSBuild projects, including dealing with sdk version: https://github.com/conan-io/conan-center-index/blob/master/docs/package_templates/msbuild_package/all/conanfile.py#L106. This is not the first recipe here in CCI that needs to change the toolset, according to the profile. If you do a grep PlatformToolset you will find several other recipes doing the same.

Copy link
Contributor Author

@samuel-emrys samuel-emrys Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @uilianries. This is something that I've already experimented with/implemented and does not appear to influence the above error: https://github.com/conan-io/conan-center-index/pull/17806/files#diff-b153d74e53befdfc8efd529e900c2626fc8949f9453e701118ad5ba7fdcf2f12R193-R205

It doesn't match what you've posted exactly, so I'll do some more experimentation to further rule it out as the cause, but I'm not confident that it will resolve the issue. The issue as it's currently presenting is with the <WindowsTargetPlatformVersion> directive, not the <PlatformToolset> directive.

Copy link
Contributor Author

@samuel-emrys samuel-emrys Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uilianries I've re-organised the changes to consolidate all patches into _patch_sources (probably why you missed the PlatformToolset implementation, it was in build()). I've also confirmed that patching the toolset (whilst necessary) doesn't impact the above error. I suspect that this is an issue with the source vcxproj files, because I can't upgrade the project manually (to use <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>) and achieve successful builds from within visual studio either. I still have to select a more specific SDK version, which may or may not be available on any given build agent/user computer.

Note that the previous author must have identified the same limitation given the previous implementation assumed <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>, which didn't work for me locally either.

"<PropertyGroup Label=\"Globals\"><WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>")
#"<PropertyGroup Label=\"Globals\"><WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>")
#"<PropertyGroup Label=\"Globals\"><WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>")

dist_configure = os.path.join(self._source_subfolder, "dist", "configure")
dist_configure = os.path.join(self.source_folder, "dist", "configure")
replace_in_file(self, dist_configure, "../$sqlite_dir", "$sqlite_dir")
replace_in_file(self, dist_configure,
"\n --disable-option-checking)",
"\n --datarootdir=*)"
"\n ;;"
"\n --disable-option-checking)")

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self, win_bash=legacy_tools.os_info.is_windows)
if self.settings.compiler in ["apple-clang", "clang"] and Version(self.settings.compiler.version) >= "12":
self._autotools.flags.append("-Wno-error=implicit-function-declaration")
conf_args = [
"--enable-debug" if self.settings.build_type == "Debug" else "--disable-debug",
"--enable-mingw" if self._mingw_build else "--disable-mingw",
"--enable-compat185",
"--enable-sql",
]
if self.options.with_cxx:
conf_args.extend(["--enable-cxx", "--enable-stl"])
else:
conf_args.extend(["--disable-cxx", "--disable-stl"])
def generate(self):
if is_msvc(self):
tc = MSBuildToolchain(self)
tc.generate()

if self.options.shared:
conf_args.extend(["--enable-shared", "--disable-static"])
deps = MSBuildDeps(self)

deps.generate()
else:
conf_args.extend(["--disable-shared", "--enable-static"])
if self.options.with_tcl:
conf_args.append("--with-tcl={}".format(unix_path(self, os.path.join(self.deps_cpp_info["tcl"].rootpath, "lib"))))
self._autotools.configure(configure_dir=os.path.join(self.source_folder, self._source_subfolder, "dist"), args=conf_args)
if self.settings.os == "Windows" and self.options.shared:
replace_in_file(self, os.path.join(self.build_folder, "libtool"),
"\ndeplibs_check_method=",
"\ndeplibs_check_method=pass_all\n#deplibs_check_method=")
replace_in_file(self, os.path.join(self.build_folder, "Makefile"),
".a",
".dll.a")
return self._autotools
tc = AutotoolsToolchain(self)
tc.configure_args.append("--enable-debug" if self.settings.build_type == "Debug" else "--disable-debug")
tc.configure_args.append("--enable-mingw" if self._mingw_build else "--disable-mingw")
tc.configure_args.append("--enable-compat185")
tc.configure_args.append("--enable-sql")
if self.options.with_cxx:
tc.configure_args.extend(["--enable-cxx", "--enable-stl"])
else:
tc.configure_args.extend(["--disable-cxx", "--disable-stl"])

if self.options.shared:
tc.configure_args.extend(["--enable-shared", "--disable-static"])
else:
tc.configure_args.extend(["--disable-shared", "--enable-static"])

if self.options.with_tcl:
tc.configure_args.append(f"--with-tcl={os.path.join(self.dependencies['tcl'].package_folder, 'lib')}")

if self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) >= "12":
tc.extra_cflags.append("-Wno-error=implicit-function-declaration")

tc.generate()

deps = AutotoolsDeps(self)
deps.generate()

@property
def _msvc_build_type(self):
Expand All @@ -174,33 +173,56 @@ def _msvc_build_type(self):
def _msvc_arch(self):
return self._msvc_platforms[str(self.settings.arch)]

def _build_msvc(self):
projects = ["db", "db_sql", "db_stl"]
if self.options.with_tcl:
projects.append("db_tcl")
msbuild = MSBuild(self)
upgraded = False
for project in projects:
msbuild.build(os.path.join(self._source_subfolder, "build_windows", "VS10", "{}.vcxproj".format(project)),
build_type=self._msvc_build_type, platforms=self._msvc_platforms,
upgrade_project=not upgraded)
upgraded = True

def build(self):
self._patch_sources()
if is_msvc(self):
self._build_msvc()
#self._build_msvc()
projects = ["db", "db_sql", "db_stl"]
if self.options.with_tcl:
projects.append("db_tcl")
msbuild = MSBuild(self)
for project in projects:
# =================================
# TODO: To remove once https://github.com/conan-io/conan/pull/12817 is available in conan client
project_file = os.path.join(self.source_folder, "build_windows", "VS10", f"{project}.vcxproj")
conantoolchain_props = os.path.join(self.generators_folder, "conantoolchain.props")
toolset = MSBuildToolchain(self).toolset
replace_in_file(
self, project_file,
"</ProjectConfiguration>",
f" <PlatformToolset>{toolset}</PlatformToolset>\n </ProjectConfiguration>",
)
replace_in_file(
self, project_file,
"</CharacterSet>",
f"</CharacterSet>\n <PlatformToolset>{toolset}</PlatformToolset>",
)
replace_in_file(
self, project_file,
"<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\"/>",
f"<Import Project=\"{conantoolchain_props}\"/>\n <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\"/>",
)
# =================================

build_type = "{}{}".format(
"" if self.options.shared else "Static ",
"Debug" if self.settings.build_type == "Debug" else "Release",
)
msbuild.build_type = build_type if Version(conan_version).major >= 2 else f"\"{build_type}\""
msbuild.platform = "Win32" if self.settings.arch == "x86" else msbuild.platform
msbuild.build(sln=project_file)
else:
autotools = self._configure_autotools()
autotools = Autotools(self)
autotools.configure(build_script_folder=os.path.join(self.source_folder, "dist"))
autotools.make()

def package(self):
copy(self, "LICENSE", src=self._source_subfolder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
bindir = os.path.join(self.package_folder, "bin")
libdir = os.path.join(self.package_folder, "lib")
if is_msvc(self):
build_windows = os.path.join(self._source_subfolder, "build_windows")
build_dir = os.path.join(self._source_subfolder, "build_windows", self._msvc_arch, self._msvc_build_type)
build_windows = os.path.join(self.source_folder, "build_windows")
build_dir = os.path.join(self.source_folder, "build_windows", self._msvc_arch, self._msvc_build_type)
copy(self, "*.lib", src=build_dir, dst=libdir)
copy(self, "*.dll", src=build_dir, dst=bindir)
for fn in ("db.h", "db.cxx", "db_int.h", "dbstl_common.h"):
Expand All @@ -217,7 +239,7 @@ def _lib_to_msvc_lib(lib):
rename(self, os.path.join(libdir, "{}.lib".format(msvc_lib)),
os.path.join(libdir, "{}.lib".format(lib)))
else:
autotools = self._configure_autotools()
autotools = Autotools(self)
autotools.install()

if self.settings.os == "Windows":
Expand All @@ -244,6 +266,7 @@ def _lib_to_msvc_lib(lib):
if not self.options.shared:
# autotools installs the static libraries twice as libXXX.a and libXXX-5.3.a ==> remove libXXX-5.3.a
rm(self, "*-{}.a".format(".".join(self._major_minor_version)), libdir)
fix_apple_shared_install_name(self)

@property
def _major_minor_version(self):
Expand All @@ -258,8 +281,8 @@ def _libs(self):
if self.options.get_safe("with_cxx"):
libs.extend(["db_cxx", "db_stl"])
libs.extend(["db_sql", "db"])
if self.settings.compiler == "Visual Studio":
libs = ["lib{}".format(lib) for lib in libs]
if is_msvc(self):
libs = [f"lib{libname}" for libname in libs]
return libs

def package_info(self):
Expand All @@ -268,5 +291,5 @@ def package_info(self):
self.cpp_info.defines = ["DB_USE_DLL"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["dl", "pthread"])
elif self.settings.os == "Windows" :
elif self.settings.os == "Windows":
self.cpp_info.system_libs.append("ws2_32")

This file was deleted.

11 changes: 5 additions & 6 deletions recipes/libdb/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)
cmake_minimum_required(VERSION 3.15)
project(PackageTest C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(libdb CONFIG REQUIRED)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
add_executable(example src/test_package.c)
target_link_libraries(example libdb::libdb)
22 changes: 16 additions & 6 deletions recipes/libdb/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
from conans import ConanFile, CMake, tools
import os

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake"

class fooTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def layout(self):
cmake_layout(self)

def test(self):
if not tools.cross_building(self):
self.run(os.path.join("bin", "test_package"), run_environment=True)
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "example")
self.run(cmd, env="conanrun")
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ int main(int argc, char *argv[]) {
puts("DP->close failed\n");
return EXIT_FAILURE;
}
puts("libdb test_package success!\n");
return EXIT_SUCCESS;
}
Loading