You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cnats package behaves a bit different than the most Conan packages when using the CMake generators, because it changes the name of the CMake target depending on the build_type setting and shared option. While one can work around this in a single configuration environment, this totally breaks the generated CMake find modules in a multi configuration environment.
Locally I fixed this by simply removing the line self.cpp_info.set_property("cmake_target_name", f"cnats::{self._nats_library_name}") from the recipe. However, this would break the package for other consumers. Therefore my question is, whether it would be possible to introduce an option to toggle this behaviour? Maybe it could be solved using components as well, but I am not sure about that.
Now the last executed command decides which cnats:: target wins in cnatsTargets.cmake, in this case, it is cnats::nats_staticd. However, find_package(cnats) now fails, because cnats-Target-release.cmake expects the common target to be called cnats::nats_static.
Logs
Click to expand log
conan install -r conancenter --requires cnats/3.9.1@ --generator CMakeDeps -pr=vs17_release
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=20
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=194
os=Windows
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=20
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=194
os=Windows
======== Computing dependency graph ========
Graph root
cli
Requirements
cnats/3.9.1#fc22ec0bf017a28878da6415953ddd35 - Cache
openssl/3.3.2#9f9f130d58e7c13e76bb8a559f0a6a8b - Cache
zlib/1.3.1#f52e03ae3d251dec704634230cd806a2 - Cache
Build requirements
nasm/2.16.01#d0aebbd20ccbb6ad9c9c753ab708098c - Cache
strawberryperl/5.32.1.1#707032463aa0620fa17ec0d887f5fe41 - Cache
Resolved version ranges
openssl/[>=1.1 <4]: openssl/3.3.2
zlib/[>=1.2.11 <2]: zlib/1.3.1
======== Computing necessary packages ========
zlib/1.3.1: Main binary package '0d6dd492a7d31822b2f2686ec67bbaef586416a3' missing
zlib/1.3.1: Checking 1 compatible configurations
zlib/1.3.1: Found compatible package '7bfde258ff4f62f75668d0896dbddedaa7480a0f': compiler.version=193
Requirements
cnats/3.9.1#fc22ec0bf017a28878da6415953ddd35:84b020effb8eb0d2cb4603e3ecd301b0478db25f#3cfca7e184517d8b121e904010cf10c8 - Cache
openssl/3.3.2#9f9f130d58e7c13e76bb8a559f0a6a8b:cd39cca4b275b2d92a30579fb1bb7f729cb6a6c5#c657cc0f25ec946d2d214815cf098600 - Cache
Build requirements
Skipped binaries
zlib/1.3.1, nasm/2.16.01, strawberryperl/5.32.1.1
======== Installing packages ========
openssl/3.3.2: Already installed! (1 of 2)
cnats/3.9.1: Already installed! (2 of 2)
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated: 'cpp_info.names' used in: openssl/3.3.2
WARN: deprecated: 'cpp_info.build_modules' used in: openssl/3.3.2
WARN: deprecated: 'env_info' used in: openssl/3.3.2
======== Finalizing install (deploy, generators) ========
cli: Writing generators to F:\source\test-nats
cli: Generator 'CMakeDeps' calling 'generate()'
cli: CMakeDeps necessary find_package() and targets for your CMakeLists.txt
find_package(cnats)
target_link_libraries(... cnats::nats_static)
cli: Generating aggregated env files
cli: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
Install finished successfully
conan install -r conancenter --requires cnats/3.9.1@ --generator CMakeDeps -pr=vs17_debug
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=20
compiler.runtime=dynamic
compiler.runtime_type=Debug
compiler.version=194
os=Windows
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=20
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=194
os=Windows
======== Computing dependency graph ========
Graph root
cli
Requirements
cnats/3.9.1#fc22ec0bf017a28878da6415953ddd35 - Cache
openssl/3.3.2#9f9f130d58e7c13e76bb8a559f0a6a8b - Cache
zlib/1.3.1#f52e03ae3d251dec704634230cd806a2 - Cache
Build requirements
nasm/2.16.01#d0aebbd20ccbb6ad9c9c753ab708098c - Cache
strawberryperl/5.32.1.1#707032463aa0620fa17ec0d887f5fe41 - Cache
Resolved version ranges
openssl/[>=1.1 <4]: openssl/3.3.2
zlib/[>=1.2.11 <2]: zlib/1.3.1
======== Computing necessary packages ========
Requirements
cnats/3.9.1#fc22ec0bf017a28878da6415953ddd35:344e7f956828c0e624644acf36d7c7be077c7ace#f24aaeb2660c859d6fdccd3ad9724952 - Cache
openssl/3.3.2#9f9f130d58e7c13e76bb8a559f0a6a8b:53065fe27a47749d08f63fb61d7b88b1bbdc5cc4#c1500469d4ee96781299ed6d8e96e275 - Cache
Build requirements
Skipped binaries
zlib/1.3.1, nasm/2.16.01, strawberryperl/5.32.1.1
======== Installing packages ========
openssl/3.3.2: Already installed! (1 of 2)
cnats/3.9.1: Already installed! (2 of 2)
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated: 'cpp_info.names' used in: openssl/3.3.2
WARN: deprecated: 'cpp_info.build_modules' used in: openssl/3.3.2
WARN: deprecated: 'env_info' used in: openssl/3.3.2
======== Finalizing install (deploy, generators) ========
cli: Writing generators to F:\source\test-nats
cli: Generator 'CMakeDeps' calling 'generate()'
cli: CMakeDeps necessary find_package() and targets for your CMakeLists.txt
find_package(cnats)
target_link_libraries(... cnats::nats_staticd)
cli: Generating aggregated env files
cli: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
Install finished successfully
CMake error:
CMake Error at test-nats/cnats-Target-release.cmake:66 (set_property):
[cmake] set_property could not find TARGET cnats::nats_static. Perhaps it has not
[cmake] yet been created.
The text was updated successfully, but these errors were encountered:
While I'm no particular fan of this pattern - the intention is such that somebody already using CMake doesn't have to make invasive changes to their build scripts to support Conan or to use Conan Center recipes.
I suspect the issue you are facing is because of the "debug" configuration cnats::nats_staticd this is not what the target should be called - will try to reproduce and fix!
Description
The cnats package behaves a bit different than the most Conan packages when using the CMake generators, because it changes the name of the CMake target depending on the build_type setting and shared option. While one can work around this in a single configuration environment, this totally breaks the generated CMake find modules in a multi configuration environment.
Locally I fixed this by simply removing the line
self.cpp_info.set_property("cmake_target_name", f"cnats::{self._nats_library_name}")
from the recipe. However, this would break the package for other consumers. Therefore my question is, whether it would be possible to introduce an option to toggle this behaviour? Maybe it could be solved using components as well, but I am not sure about that.Package and Environment Details
Conan profile
Profile vs17_debug:
[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=20
compiler.runtime=dynamic
compiler.runtime_type=Debug
compiler.version=194
os=Windows
Profile vs17_release:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=20
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=194
os=Windows
Steps to reproduce
conan install -r conancenter --generator CMakeDeps --requires cnats/3.9.1@ -pr=vs17_release
conan install -r conancenter --generator CMakeDeps --requires cnats/3.9.1@ -pr=vs17_debug
Now the last executed command decides which cnats:: target wins in cnatsTargets.cmake, in this case, it is cnats::nats_staticd. However, find_package(cnats) now fails, because cnats-Target-release.cmake expects the common target to be called cnats::nats_static.
Logs
Click to expand log
The text was updated successfully, but these errors were encountered: