question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] CMakeToolchain: `BUILD_SHARED_LIBS` & `CMAKE_POSITION_INDEPENDENT_CODE` not honored if CMP0077 OLD (or not set) and turned as options in upstream CMakeLists

See original GitHub issue

Environment Details (include every applicable attribute)

  • Operating System+version: macOS Montery
  • Compiler+version: AppleCland 13
  • Conan version: 1.51.1
  • Python version: 3.9.13

Steps to reproduce (Include if Applicable)

A shared lib is created instead of a static lib, while it was working fine with the conan v1 flavor of this recipe. If CMAKE_POLICY_DEFAULT_CMP0077 is injected as a CMakeToolchain cache_variables (by the way this name is super misleading, since CMakeToolchain variables are CMake cache variables, and CMakeToolchain cache_variables are CMakePresets cacheVariables), static lib is properly created.

Explanation:

Logs (Executed commands with output) (Include/Attach if Applicable)

Click to expand log
Exporting package recipe
libccd/2.1 exports: File 'conandata.yml' found. Exporting it...
libccd/2.1 exports: Copied 1 '.yml' file: conandata.yml
libccd/2.1: The stored package has not changed
libccd/2.1: Using the exported files summary hash as the recipe revision: 754e548f10cd5c5a13b36bd666b79ac2
libccd/2.1: Exported revision: 754e548f10cd5c5a13b36bd666b79ac2
Configuration (profile_host):
[settings]
arch=x86_64
build_type=Debug
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13
os=Macos
[options]
libccd:shared=False
[build_requires]
[env]
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

Configuration (profile_build):
[settings]
arch=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13
os=Macos
[options]
[build_requires]
[env]
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

libccd/2.1: Forced build from source
libccd/2.1 (test package): Installing package
Requirements
    libccd/2.1 from 'conancenter' - Cache
Packages
    libccd/2.1:92958fbd7bb641f338e28ce02103bd2e6bd0c465 - Build

Installing (downloading, building) binaries...
libccd/2.1: Copying sources to build folder
libccd/2.1: Building your package in /Users/spaceim/.conan/data/libccd/2.1/_/_/build/92958fbd7bb641f338e28ce02103bd2e6bd0c465
libccd/2.1: Generator txt created conanbuildinfo.txt
libccd/2.1: Calling generate()
libccd/2.1: Aggregating env generators
libccd/2.1: Calling build()
libccd/2.1: CMake command: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="/Users/spaceim/.conan/data/libccd/2.1/_/_/build/92958fbd7bb641f338e28ce02103bd2e6bd0c465/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Debug" "/Users/spaceim/.conan/data/libccd/2.1/_/_/build/92958fbd7bb641f338e28ce02103bd2e6bd0c465/src"
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Using Conan toolchain: /Users/spaceim/.conan/data/libccd/2.1/_/_/build/92958fbd7bb641f338e28ce02103bd2e6bd0c465/build/generators/conan_toolchain.cmake
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:23 (option):
  Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
  --help-policy CMP0077" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  For compatibility with older versions of CMake, option is clearing the
  normal variable 'BUILD_SHARED_LIBS'.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Performing Test COMPILER_SUPPORTS_VISIBILITY
-- Performing Test COMPILER_SUPPORTS_VISIBILITY - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/spaceim/.conan/data/libccd/2.1/_/_/build/92958fbd7bb641f338e28ce02103bd2e6bd0c465/build/Debug
libccd/2.1: CMake command: cmake --build "/Users/spaceim/.conan/data/libccd/2.1/_/_/build/92958fbd7bb641f338e28ce02103bd2e6bd0c465/build/Debug" '--' '-j12'
[7/7] Creating library symlink src/libccd.2.dylib src/libccd.dylib
libccd/2.1: Package '92958fbd7bb641f338e28ce02103bd2e6bd0c465' built
libccd/2.1: Build folder /Users/spaceim/.conan/data/libccd/2.1/_/_/build/92958fbd7bb641f338e28ce02103bd2e6bd0c465/build/Debug
libccd/2.1: Generated conaninfo.txt
libccd/2.1: Generated conanbuildinfo.txt
libccd/2.1: Generating the package
libccd/2.1: Package folder /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465
libccd/2.1: Calling package()
libccd/2.1: Copied 1 file: BSD-LICENSE
libccd/2.1: CMake command: cmake --install "/Users/spaceim/.conan/data/libccd/2.1/_/_/build/92958fbd7bb641f338e28ce02103bd2e6bd0c465/build/Debug" --prefix "/Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465"
-- Install configuration: "Debug"
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/lib/ccd/ccd-config.cmake
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/lib/ccd/ccd-config-version.cmake
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/lib/pkgconfig/ccd.pc
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/share/doc/ccd/BSD-LICENSE
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/lib/libccd.2.0.dylib
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/lib/libccd.2.dylib
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/lib/libccd.dylib
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/include/ccd/ccd.h
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/include/ccd/compiler.h
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/include/ccd/ccd_export.h
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/include/ccd/quat.h
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/include/ccd/vec3.h
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/include/ccd/config.h
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/lib/ccd/ccd-targets.cmake
-- Installing: /Users/spaceim/.conan/data/libccd/2.1/_/_/package/92958fbd7bb641f338e28ce02103bd2e6bd0c465/lib/ccd/ccd-targets-debug.cmake
libccd/2.1 package(): Packaged 1 file: BSD-LICENSE
libccd/2.1 package(): Packaged 6 '.h' files
libccd/2.1 package(): Packaged 3 '.dylib' files: libccd.dylib, libccd.2.0.dylib, libccd.2.dylib
libccd/2.1 package(): Packaged 1 '.cmake' file: conan-official-libccd-targets.cmake
libccd/2.1: Package '92958fbd7bb641f338e28ce02103bd2e6bd0c465' created
libccd/2.1: Created package revision 945ad782be184094cd6378b52deaa4af

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
prince-chrismccommented, Oct 22, 2022
1reaction
jcar87commented, Aug 18, 2022

Hi @SpaceIm, @jwillikers for reporting this issue. We will work on a fix to address the case where a project treats this as global cache variables.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cmake_policy(SET CMP0077 NEW) not working correctly
Use the cmake_policy command to set the policy and suppress this warning. For compatibility with older versions of CMake, option is clearing ...
Read more >
How to force cmake to use the new version of CMP0077 ...
Setting the default value of that policy via set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) before the call to add_subdirectory that adds the date ...
Read more >
cmake-variables - man pages section 7 - Oracle Help Center
This variable will be set to true by CMake if the CMAKE_SYSTEM_NAME variable has been set manually (i.e. in a toolchain file or...
Read more >
dlib/CMakeLists.txt
In newer versions of CMake we can instead set CUDA_LINK_LIBRARIES_KEYWORD ... on dlib. if (NOT TARGET dlib) set (DLIB_ISO_CPP_ONLY_STR "Enable this if you ......
Read more >
Building a Dual Shared and Static Library with CMake
The end-user experience should not change when switching between these options and find_package . Only strict build requirements belong in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found