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.

[question] LIB_DIRS variables in V1 have build type suffix (LIB_DIRS_RELEASE) in V2?

See original GitHub issue

This could be something very easy that I have overlooked. I wrote a simple conanfile.py using conans.ConanFile and conans.CMake as well as the generator cmake_find_package. My CMakeLists.txt had lines like this referencing other Conan packages in my requires:

find_package(foo REQUIRED)
include_directories(${foo_INCLUDE_DIRS})
link_directories(${foo_LIB_DIRS})

I use conan create. Upon converting this recipe to Conan V2 format using conan.ConanFile and conan.tools.cmake.CMake as well as the generators conan.tools.cmake.CMakeToolchain and conan.tools.cmake.CMakeDeps, I started getting linker errors that only went away when I updated my link_directories commands after realizing that the LIB_DIRS variables no longer existed but LIB_DIRS_RELEASE variables were there instead.

Although both versions of the recipe run CMake with CMAKE_BUILD_TYPE=Release, the suffix is only there when building from the V2 recipe. Is this difference documented anywhere?

Interestingly, for gtest I also had to change include_directories(${GTest_INCLUDE_DIRS}) to include_directories(${gtest_INCLUDE_DIRS_RELEASE}). Not only did the case change but the _RELEASE suffix is needed here whereas on my other dependencies it is only on LIB_DIRS. Is this behavior recipe-specific?

Conan 1.55.0

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
memshardedcommented, Dec 12, 2022

I’m not very experienced with CMake, but doing that worked, thanks!

Perfect, I am very happy that it worked! 😃

Yes, that is the idea of “modern CMake”, that is all about targets. Not needing to worry about individual properties like includedirs, libdirs, but the target includes all the related information for that specific library, including its includedirs.

0reactions
joshvazquez-amzncommented, Dec 12, 2022

I’m not very experienced with CMake, but doing that worked, thanks!

cmake_minimum_required(VERSION 3.16)
project(reproduction)

find_package(nng REQUIRED)

add_executable(reproduction)
target_link_libraries(reproduction PRIVATE nng::nng)
target_sources(reproduction PRIVATE main.cpp)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure build variants | Android Developers
This page shows you how you can configure build variants to create different versions of your app from a single project and how...
Read more >
How to change app name per Gradle build type - Stack Overflow
You can see that in this sample project, where I have a replacement for app_name in src/debug/res/values/strings.xml , which will be applied for...
Read more >
Android Build Types and Product Flavors - DigitalOcean
In this tutorial, we'll be discussing Android Build Types and Product Flavors. ... Now we have 3 build variants: android build type variants ......
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