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] CMakeDeps generates wrong Catch2Targets.cmake

See original GitHub issue

The following

import os
import sys
from conans import ConanFile, tools, CMake
from conan.tools.cmake import CMakeDeps
from conans.tools import Version

class BaseLibrary(ConanFile):
  name = "base-library"

  generators = "cmake_find_package_multi"
  default_options = {"fmt:shared": True}
  build_policy = "missing"  # if this package is build by default if missing.
  settings = "os", "compiler", "build_type", "arch"

  _cmake = None

  def requirements(self):
      self.requires("fmt/8.0.1")
      self.requires("catch2/2.13.7")

  def generate(self):
    tc = CMakeDeps(self)
    tc.generate()

with conan install /demo --install-folder /demo/conan --build missing --profile default --profile:build default --settings build_type=Release --settings compiler=clang --settings compiler.version=12 --settings compiler.libcxx=libstdc++

produces wrong CMake Scripts: Catch2Config.cmake does

# Load the debug and release library finders
include(${CMAKE_CURRENT_LIST_DIR}/Catch2Targets.cmake)
  ^ ##############################################  This line already properly sets Catch2::Catch2 by loading "Catch2-Target-release.cmake"

The next lines in Catch2Config.cmake now overwrite the target properties with non existent values.

# Assign target properties
set_property(TARGET Catch2::Catch2
             PROPERTY INTERFACE_LINK_LIBRARIES
             $<$<CONFIG:Debug>:${Catch2_LIBRARIES_TARGETS_DEBUG}
                                    ${Catch2_LINKER_FLAGS_DEBUG_LIST}>
             $<$<CONFIG:Release>:${Catch2_LIBRARIES_TARGETS_RELEASE}
                                    ${Catch2_LINKER_FLAGS_RELEASE_LIST}>
             $<$<CONFIG:RelWithDebInfo>:${Catch2_LIBRARIES_TARGETS_RELWITHDEBINFO}
                                    ${Catch2_LINKER_FLAGS_RELWITHDEBINFO_LIST}>
             $<$<CONFIG:MinSizeRel>:${Catch2_LIBRARIES_TARGETS_MINSIZEREL}
                                    ${Catch2_LINKER_FLAGS_MINSIZEREL_LIST}>)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
memshardedcommented, Sep 23, 2021

Yes, the thing is that we had some similar check some time ago, but we have already removed cmake_find_package_[multi] generators in develop2 branch, that is where we do most of our development now, and we mainly backport things to 1.X, so it seems that check has been lost in the process.

In any case, we are going to start pushing hard for new generators and Conan 2.0, so this shouldn’t be a big issue. Thanks for telling!

0reactions
gabyxcommented, Sep 27, 2021

Thanks a lto for that hint.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[bug] CMakeToolchain/CMakeDeps generates CMake ...
[bug] CMakeToolchain/CMakeDeps generates CMake warnings when dependency was already found via find_package #10132.
Read more >
CMake find_package for non-standard locations
To find dependencies in cmake build system I use find_package. ... Typically Catch2Targets.cmake package install files are generated when ...
Read more >
CMakeToolchain — conan 1.53.0 documentation
The CMakeToolchain is the toolchain generator for CMake. It will generate toolchain files that can be used in the command line invocation of...
Read more >
find_package can't find Find<lib>.cmake - Usage
I get the following error for a dependency fetched by Conan: CMake Error at /home/rince/MyApp/CMakeLists.txt:19 (find_package): By not ...
Read more >
Conan Package Manager in Practice - GitHub Pages
shared: False. [settings] ... Recipe is the instruction file to create a package ... from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps.
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