conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
967 stars 1.78k forks source link

[package] cppunit/1.15.1: The built library file is called libcppunit.a on Windows instead of cppunit.lib #22822

Open tmiseikis opened 9 months ago

tmiseikis commented 9 months ago

Description

Hi,

I am building 32-bit version of cppunit/1.15.1 library on Windows using msvc compiler, but it looks like the resulting library that is built is named after Unix convention: libcppunit.a. However, since I am building for Windows platform I would have expected it to be called cppunit.lib. Because of this the find_package call in CMake fails:

CMake Error at build/cmakedeps_macros.cmake:67 (message):
  Library 'cppunit' not found in package.  If 'cppunit' is a system library,
  declare it with 'cpp_info.system_libs' property
Call Stack (most recent call first):
  build/cppunit-Target-release.cmake:24 (conan_package_library_targets)
  build/cppunitTargets.cmake:26 (include)
  build/cppunit-config.cmake:16 (include)
  CMakeLists.txt:99 (find_package)

If I manually rename the built library from libcppunit.a to cppunit.lib then CMake's find_package no longer fails.

Package and Environment Details

Conan profile

Profile host:

[settings]
arch=x86
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows

Profile build:

[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows

Steps to reproduce

  1. Add cppunit requirement to conanfile.py
    def requirements(self):
        self.requires("cppunit/1.15.1")
  2. Create conan_profiles/build and conan_profiles/host files based on the conan profiles specified above.
  3. Run: conan install -s:a build_type=Release --profile:build=conan_profiles/build --profile:host=conan_profiles/host . --build=missing

Logs

Click to expand log ``` cppunit/1.15.1: package(): Packaged 1 '.exe' file: DllPlugInTester.exe cppunit/1.15.1: package(): Packaged 70 '.h' files cppunit/1.15.1: package(): Packaged 1 '.a' file: libcppunit.a cppunit/1.15.1: package(): Packaged 1 file: COPYING cppunit/1.15.1: Created package revision d9ecfcae26c91d43ee539a6b0e22fe38 cppunit/1.15.1: Package '229a27e22d41023d147ff16c00b2d96a6e09029f' created cppunit/1.15.1: Full package reference: cppunit/1.15.1#ab7aa369cbf20014946964574a427088:229a27e22d41023d147ff16c00b2d96a6e09029f#d9ecfcae26c91d43ee539a6b0e22fe38 cppunit/1.15.1: Package folder C:\Users\xxx\.conan2\p\b\cppun6ef23a1501b95\p ```
tmiseikis commented 9 months ago

As workaround, I have added the following to the generate method in my conanfile.py:

from conan.tools.files import rename

def generate(self):
    if self.settings.os == "Windows":
        cppunit_libdir = self.dependencies["cppunit"].cpp_info.libdir
        cppunit_from_name = f"{cppunit_libdir}/libcppunit.a"
        cppunit_to_name = f"{cppunit_libdir}/cppunit.lib"

        if os.path.isfile(cppunit_from_name):
            rename(self, cppunit_from_name, cppunit_to_name)
bandrews-spirent commented 5 months ago

Ran into this issue as well. Apparently it only happens for Windows x86 target with shared lib. Anyone know where the issue might be?

cppunit/1.15.1: RUN: "/c/users/jenkins/.conan2/p/b/cppun1cf6f4be913ff/b/src/configure" --enable-shared --disable-static --prefix=/ --bindir=${prefix}/bin --sbindir=${prefix}/bin --libdir=${prefix}/lib --includedir=${prefix}/include --oldincludedir=${prefix}/include --host=i686-unknown-windows --build=x86_64-unknown-windows --enable-debug=no --enable-doxygen=no --enable-dot=no --enable-werror=no --enable-html-docs=no 
 checking whether the /c/users/jenkins/.conan2/p/autome371915acf95c/p/res/automake-1.16/compile cl -nologo linker (link -nologo) supports shared libraries... no

Could be configure, automake, or conan core problem? supports shared libraries... no I have other packages with this same configuration and they work fine.