conan icon indicating copy to clipboard operation
conan copied to clipboard

[bug] -o:h shared=True is not used when installing packages

Open simon-rechermann opened this issue 1 year ago • 1 comments

Describe the bug

I'm on ubuntu 20.04 and I'm using conan version 2.2.3. If I set o:h to shared=True it does not have any effect and the package is beeing installed as static lib. However if I specify the package with the --require argument it works as expected.

How to reproduce it

I have this conanfile.txt:

[requires]
fmt/9.1.0

I removed the ~/.conan2 folder before doing the following steps.

╰─➤  conan profile detect
detect_api: Found gcc 9
detect_api: gcc>=5, using the major as version
detect_api: gcc C++ standard library: libstdc++11

Detected profile:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux

WARN: This profile is a guess of your environment, please check it.
WARN: The output of this command is not guaranteed to be stable and can change in future Conan versions.
WARN: Use your own profile files for stability.
Saving detected profile to /home/recherma/.conan2/profiles/default

Installing with the usage of the conanfile.txt located at .

─➤  conan install .  -of build -o:h shared=True --build=missing

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux
[options]
shared=True

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux


======== Computing dependency graph ========
fmt/9.1.0: Not found in local cache, looking in remotes...
fmt/9.1.0: Checking remote: conancenter
fmt/9.1.0: Downloaded recipe revision 551bb6d903fc22780392707fed0efb18
Graph root
    conanfile.txt: /home/recherma/dev/mrt.rfu.logging.interface/conanfile.txt
Requirements
    fmt/9.1.0#551bb6d903fc22780392707fed0efb18 - Downloaded (conancenter)

======== Computing necessary packages ========
fmt/9.1.0: Checking 7 compatible configurations
fmt/9.1.0: Compatible configurations not found in cache, checking servers
fmt/9.1.0: '9a11e23e6e5e4430903932b51bb79bc60a823ac0': compiler.cppstd=11
fmt/9.1.0: '2979a16aaad516d0cb2d3a2dc8be21c14c7a1510': compiler.cppstd=gnu11
fmt/9.1.0: 'f1fdc2e0b23fa57ae374ef49446f3affd606c493': compiler.cppstd=14
fmt/9.1.0: '7029afbc0aae22b9faa77f1f70854f109777c4cc': compiler.cppstd=17
fmt/9.1.0: '79e01cb3953bd1232cc419617c6a218bb45b5607': compiler.cppstd=gnu17
fmt/9.1.0: 'cbdb02aa6358a51c3c1624a2b16892bd905a6a19': compiler.cppstd=20
fmt/9.1.0: '6b23d441e6a6fc1e02f4b8bd2e619ec4e59548a9': compiler.cppstd=gnu20
Requirements
    fmt/9.1.0#551bb6d903fc22780392707fed0efb18:2a19bd6135b7407c91dd4595a6d38c3e56230930 - Build

======== Installing packages ========
fmt/9.1.0: Sources downloaded from 'conancenter'
fmt/9.1.0: Calling source() in /home/recherma/.conan2/p/fmt06e223470ba8c/s/src
fmt/9.1.0: Unzipping 4.5MB, this can take a while
Unzipping 100 %                                                       

-------- Installing package fmt/9.1.0 (1 of 1) --------
fmt/9.1.0: Building from source
fmt/9.1.0: Package fmt/9.1.0:2a19bd6135b7407c91dd4595a6d38c3e56230930
fmt/9.1.0: Copying sources to build folder
fmt/9.1.0: Building your package in /home/recherma/.conan2/p/b/fmtf1fde69edd61f/b
fmt/9.1.0: Calling generate()
fmt/9.1.0: Generators folder: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/b/build/Release/generators
fmt/9.1.0: CMakeToolchain generated: conan_toolchain.cmake
fmt/9.1.0: CMakeToolchain generated: CMakePresets.json
fmt/9.1.0: CMakeToolchain generated: ../../../src/CMakeUserPresets.json
fmt/9.1.0: Generating aggregated env files
fmt/9.1.0: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
fmt/9.1.0: Calling build()
fmt/9.1.0: apply_conandata_patches(): No patches defined in conandata
fmt/9.1.0: Running CMake.configure()
fmt/9.1.0: RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/recherma/.conan2/p/b/fmtf1fde69edd61f/b/build/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/recherma/.conan2/p/b/fmtf1fde69edd61f/p" -DFMT_DOC="OFF" -DFMT_TEST="OFF" -DFMT_INSTALL="ON" -DFMT_LIB_DIR="lib" -DFMT_OS="ON" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/recherma/.conan2/p/b/fmtf1fde69edd61f/b/src"
-- CMake version: 3.29.0
-- Using Conan toolchain: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/b/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: C++ Standard 14 with extensions ON
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The CXX compiler identification is GNU 9.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Module support is disabled.
-- Version: 9.1.0
-- Build type: Release
-- CXX_STANDARD: 14
-- Performing Test has_std_14_flag
-- Performing Test has_std_14_flag - Success
-- Performing Test has_std_1y_flag
-- Performing Test has_std_1y_flag - Success
-- Required features: cxx_variadic_templates
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/b/build/Release

fmt/9.1.0: Running CMake.build()
fmt/9.1.0: RUN: cmake --build "/home/recherma/.conan2/p/b/fmtf1fde69edd61f/b/build/Release" -- -j20
[ 33%] Building CXX object CMakeFiles/fmt.dir/src/format.cc.o
[ 66%] Building CXX object CMakeFiles/fmt.dir/src/os.cc.o
[100%] Linking CXX static library libfmt.a
[100%] Built target fmt

fmt/9.1.0: Package '2a19bd6135b7407c91dd4595a6d38c3e56230930' built
fmt/9.1.0: Build folder /home/recherma/.conan2/p/b/fmtf1fde69edd61f/b/build/Release
fmt/9.1.0: Generating the package
fmt/9.1.0: Packaging in folder /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p
fmt/9.1.0: Calling package()
fmt/9.1.0: Running CMake.install()
fmt/9.1.0: RUN: cmake --install "/home/recherma/.conan2/p/b/fmtf1fde69edd61f/b/build/Release" --prefix "/home/recherma/.conan2/p/b/fmtf1fde69edd61f/p"
-- Install configuration: "Release"
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/lib/libfmt.a
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/args.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/chrono.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/color.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/compile.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/core.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/format.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/format-inl.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/os.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/ostream.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/printf.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/ranges.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/std.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/include/fmt/xchar.h
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/lib/cmake/fmt/fmt-config.cmake
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/lib/cmake/fmt/fmt-config-version.cmake
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/lib/cmake/fmt/fmt-targets.cmake
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/lib/cmake/fmt/fmt-targets-release.cmake
-- Installing: /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p/lib/pkgconfig/fmt.pc

fmt/9.1.0: package(): Packaged 13 '.h' files
fmt/9.1.0: package(): Packaged 1 '.a' file: libfmt.a
fmt/9.1.0: package(): Packaged 1 '.rst' file: LICENSE.rst
fmt/9.1.0: Created package revision d6d31a1c574bd563f366dbe430174b0c
fmt/9.1.0: Package '2a19bd6135b7407c91dd4595a6d38c3e56230930' created
fmt/9.1.0: Full package reference: fmt/9.1.0#551bb6d903fc22780392707fed0efb18:2a19bd6135b7407c91dd4595a6d38c3e56230930#d6d31a1c574bd563f366dbe430174b0c
fmt/9.1.0: Package folder /home/recherma/.conan2/p/b/fmtf1fde69edd61f/p
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated:     'cpp_info.names' used in: fmt/9.1.0

======== Finalizing install (deploy, generators) ========
conanfile.txt: Generating aggregated env files
conanfile.txt: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
Install finished successfully

Installing with specifying the package with --requires argument:

╰─➤  conan install --requires fmt/9.1.0 -of build -o:h shared=True --build=missing

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux
[options]
shared=True

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux


======== Computing dependency graph ========
Graph root
    cli
Requirements
    fmt/9.1.0#551bb6d903fc22780392707fed0efb18 - Cache

======== Computing necessary packages ========
fmt/9.1.0: Checking 7 compatible configurations
fmt/9.1.0: Compatible configurations not found in cache, checking servers
fmt/9.1.0: 'd9796aadf43217209553247ac8c3bb5697b889bd': compiler.cppstd=11
fmt/9.1.0: '0d5312b7d1394a8807ea3ee0950fba345170a433': compiler.cppstd=gnu11
fmt/9.1.0: '2e716e0cc2fd93f87a0e14618adcbef41c723227': compiler.cppstd=14
fmt/9.1.0: '7d225064c906e0f44a8bdab542ed49a2fee4f3bd': compiler.cppstd=17
fmt/9.1.0: '7b3734ed9cd9f1a3ae9ae84d4d2dcd5e223e4eeb': compiler.cppstd=gnu17
fmt/9.1.0: 'a0292515cab705f08d888cb1a3c9b4c74ca8d5d8': compiler.cppstd=20
fmt/9.1.0: '18a08a075a3984901f07c7bd782550b1b0ea8966': compiler.cppstd=gnu20
Requirements
    fmt/9.1.0#551bb6d903fc22780392707fed0efb18:57f9e5ecd18972fcac0b89aaa36e55a8fcd8e6d9 - Build

======== Installing packages ========

-------- Installing package fmt/9.1.0 (1 of 1) --------
fmt/9.1.0: Building from source
fmt/9.1.0: Package fmt/9.1.0:57f9e5ecd18972fcac0b89aaa36e55a8fcd8e6d9
fmt/9.1.0: Copying sources to build folder
fmt/9.1.0: Building your package in /home/recherma/.conan2/p/b/fmt720d236d6f119/b
fmt/9.1.0: Calling generate()
fmt/9.1.0: Generators folder: /home/recherma/.conan2/p/b/fmt720d236d6f119/b/build/Release/generators
fmt/9.1.0: CMakeToolchain generated: conan_toolchain.cmake
fmt/9.1.0: CMakeToolchain generated: CMakePresets.json
fmt/9.1.0: CMakeToolchain generated: ../../../src/CMakeUserPresets.json
fmt/9.1.0: Generating aggregated env files
fmt/9.1.0: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
fmt/9.1.0: Calling build()
fmt/9.1.0: apply_conandata_patches(): No patches defined in conandata
fmt/9.1.0: Running CMake.configure()
fmt/9.1.0: RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/recherma/.conan2/p/b/fmt720d236d6f119/b/build/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/recherma/.conan2/p/b/fmt720d236d6f119/p" -DFMT_DOC="OFF" -DFMT_TEST="OFF" -DFMT_INSTALL="ON" -DFMT_LIB_DIR="lib" -DFMT_OS="ON" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/recherma/.conan2/p/b/fmt720d236d6f119/b/src"
-- CMake version: 3.29.0
-- Using Conan toolchain: /home/recherma/.conan2/p/b/fmt720d236d6f119/b/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 14 with extensions ON
-- Conan toolchain: Setting BUILD_SHARED_LIBS = ON
-- The CXX compiler identification is GNU 9.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Module support is disabled.
-- Version: 9.1.0
-- Build type: Release
-- CXX_STANDARD: 14
-- Performing Test has_std_14_flag
-- Performing Test has_std_14_flag - Success
-- Performing Test has_std_1y_flag
-- Performing Test has_std_1y_flag - Success
-- Required features: cxx_variadic_templates
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/recherma/.conan2/p/b/fmt720d236d6f119/b/build/Release

fmt/9.1.0: Running CMake.build()
fmt/9.1.0: RUN: cmake --build "/home/recherma/.conan2/p/b/fmt720d236d6f119/b/build/Release" -- -j20
[ 33%] Building CXX object CMakeFiles/fmt.dir/src/format.cc.o
[ 66%] Building CXX object CMakeFiles/fmt.dir/src/os.cc.o
[100%] Linking CXX shared library libfmt.so
[100%] Built target fmt

fmt/9.1.0: Package '57f9e5ecd18972fcac0b89aaa36e55a8fcd8e6d9' built
fmt/9.1.0: Build folder /home/recherma/.conan2/p/b/fmt720d236d6f119/b/build/Release
fmt/9.1.0: Generating the package
fmt/9.1.0: Packaging in folder /home/recherma/.conan2/p/b/fmt720d236d6f119/p
fmt/9.1.0: Calling package()
fmt/9.1.0: Running CMake.install()
fmt/9.1.0: RUN: cmake --install "/home/recherma/.conan2/p/b/fmt720d236d6f119/b/build/Release" --prefix "/home/recherma/.conan2/p/b/fmt720d236d6f119/p"
-- Install configuration: "Release"
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/lib/libfmt.so.9.1.0
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/lib/libfmt.so.9
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/lib/libfmt.so
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/args.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/chrono.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/color.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/compile.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/core.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/format.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/format-inl.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/os.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/ostream.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/printf.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/ranges.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/std.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/include/fmt/xchar.h
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/lib/cmake/fmt/fmt-config.cmake
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/lib/cmake/fmt/fmt-config-version.cmake
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/lib/cmake/fmt/fmt-targets.cmake
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/lib/cmake/fmt/fmt-targets-release.cmake
-- Installing: /home/recherma/.conan2/p/b/fmt720d236d6f119/p/lib/pkgconfig/fmt.pc

fmt/9.1.0: package(): Packaged 13 '.h' files
fmt/9.1.0: package(): Packaged 1 '.so' file: libfmt.so
fmt/9.1.0: package(): Packaged 1 '.0' file: libfmt.so.9.1.0
fmt/9.1.0: package(): Packaged 1 '.9' file: libfmt.so.9
fmt/9.1.0: package(): Packaged 1 '.rst' file: LICENSE.rst
fmt/9.1.0: Created package revision d8ee9d5a11f221c216fc84941b161a79
fmt/9.1.0: Package '57f9e5ecd18972fcac0b89aaa36e55a8fcd8e6d9' created
fmt/9.1.0: Full package reference: fmt/9.1.0#551bb6d903fc22780392707fed0efb18:57f9e5ecd18972fcac0b89aaa36e55a8fcd8e6d9#d8ee9d5a11f221c216fc84941b161a79
fmt/9.1.0: Package folder /home/recherma/.conan2/p/b/fmt720d236d6f119/p
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated:     'cpp_info.names' used in: fmt/9.1.0

======== Finalizing install (deploy, generators) ========
cli: Generating aggregated env files
cli: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
Install finished successfully

simon-rechermann avatar May 10 '24 09:05 simon-rechermann

Hi @simon-rechermann

Thanks for your question. This is expected, see for example in the starting tutorial in https://docs.conan.io/2/tutorial/consuming_packages/different_configurations.html, it uses:

--options=zlib/1.2.11:shared=True

And not -o shared=True, this option is only applied for the "consumer" project, for example it will work for the created package with conan create, but not for its dependencies.

Options are per-package, it is necessary to define to which package they apply. If you want all your dependencies as shared, please do -o *:shared=True.

Please try that and let us know.

memsharded avatar May 10 '24 09:05 memsharded

Hi @memsharded

Thanks for the explanation :) Everything works for me like you described it

simon-rechermann avatar May 13 '24 07:05 simon-rechermann