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.

CMake toolchain for integration with Conan using cmake-conan, cmake-conan-setup.

See original GitHub issue

Project Link

https://github.com/hwhsu1231/cmake-conan-setup

Introduction

Dear Conan Team,

This project is my Solution to the issue that I posted before:

I’ve already writen down the Motivation, Usage, Mechanism, Demonstration…etc in this project. Please take a look. First of all, it is required for conan_cmake_install() supporting --conf argument in this project. See more details on this PR:

However, this PR is not yet merged to the master branch even the develop branch for now. So I have to prepare a modified version of conan.cmake in this project. Hope this PR can be merged as soon as possible. Otherwise, an error due to including conan_toolchain.cmake when using non-default CMake generators might occur. For example, using MSVC compilers with Ninja generator:

Click to expand
F:\GitRepo\cmake-conan-setup>vcvarsall x64
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.19
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

F:\GitRepo\cmake-conan-setup>cmake --preset win32-msvc-x64-ninja-debug
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  CMAKE_CXX_COMPILER="cl.exe"
  CMAKE_C_COMPILER="cl.exe"
  CMAKE_INSTALL_PREFIX:PATH="F:/GitRepo/cmake-conan-setup/install/win32-msvc-x64-ninja-debug"
  CMAKE_PROJECT_INCLUDE_BEFORE="F:/GitRepo/cmake-conan-setup/cmake/conan-setup.cmake"

-- Downloading conan.cmake from https://github.com/conan-io/cmake-conan
-- The C compiler identification is MSVC 19.29.30146.0
-- The CXX compiler identification is MSVC 19.29.30146.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - 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: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped        
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Detected VS runtime: MDd
-- Conan: checking conan executable
-- Conan: Found program C:/Python/Python310/Scripts/conan.exe
-- Conan: Version found Conan version 1.53.0
-- Conan executing: C:/Python/Python310/Scripts/conan.exe install F:/GitRepo/cmake-conan-setup/conanfile.py --remote conancenter --install-folder F:/GitRepo/cmake-conan-setup/build/win32-msvc-x64-ninja-debug/conan-dependencies --output-folder F:/GitRepo/cmake-conan-setup/build/win32-msvc-x64-ninja-debug/conan-dependencies --build missing --settings arch=x86_64 --settings build_type=Debug --settings compiler=Visual Studio --settings compiler.version=16 --settings compiler.runtime=MDd  
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=Visual Studio
compiler.runtime=MDd
compiler.version=16
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

conanfile.py: Installing package
Requirements
    cli11/2.2.0 from 'conancenter' - Cache
    eigen/3.3.9 from 'conancenter' - Cache
    fmt/8.1.1 from 'conancenter' - Cache
Packages
    cli11/2.2.0:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
    eigen/3.3.9:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
    fmt/8.1.1:8ed2451fe8e6a2dd1b2f8bac3c035717ff9ddfa8 - Cache

Installing (downloading, building) binaries...
cli11/2.2.0: Already installed!
eigen/3.3.9: Already installed!
fmt/8.1.1: Already installed!
conanfile.py: Generator txt created conanbuildinfo.txt
conanfile.py: WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
conanfile.py: Generator 'CMakeToolchain' calling 'generate()'
conanfile.py: Preset 'default' added to CMakePresets.json. Invoke it manually using 'cmake --preset default'
conanfile.py: If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=F:\GitRepo\cmake-conan-setup\build\win32-msvc-x64-ninja-debug\conan-dependencies\conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW'
conanfile.py: WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
conanfile.py: Generator 'CMakeDeps' calling 'generate()'
conanfile.py: Aggregating env generators
conanfile.py: Generated conaninfo.txt
conanfile.py: Generated graphinfo
-- Configuring done
-- Generating done
-- Build files have been written to: F:/GitRepo/cmake-conan-setup/build/win32-msvc-x64-ninja-debug/conan-dependencies/build
-- Using Conan toolchain: F:/GitRepo/cmake-conan-setup/build/win32-msvc-x64-ninja-debug/conan-dependencies/conan_toolchain.cmake
CMake Error at CMakeLists.txt:2 (project):
  Generator

    Ninja

  does not support platform specification, but platform

    x64

  was specified.


-- Configuring incomplete, errors occurred!
See also "F:/GitRepo/cmake-conan-setup/build/win32-msvc-x64-ninja-debug/CMakeFiles/CMakeOutput.log".

It is because the default generator on Windows is Visual Studio generator. Therefore the conan_toolchain.cmake generated by CMakeToolchain will have the following two lines, which shouldn’t be specified when using Ninja generator.

set(CMAKE_GENERATOR_PLATFORM "x64" CACHE STRING "" FORCE)
set(CMAKE_GENERATOR_TOOLSET "v142" CACHE STRING "" FORCE)

Hope Conan Team take over this project

I’m willing to transfer this project if Conan Team thinks it is worth maintaining. Here are the reasons:

  • I haven’t mastered all the skills and techniques of Git/GitHub. So I’m afraid that I might mess up this project if someone do some PRs for it later.
  • I only test compilers on Windows platform. Since I have a little experience on Ubuntu and zero experience on MacOS, I’m not able to deal with the issues about other platforms (for now).
  • This project is a downstream project of cmake-conan, so it might have some upstream problems.
  • As a college student, I need to prepare a big exam in a few months. So I don’t have much time to debug this project later. (Most Important)

And my requests are:

  • Mark me as the Original Arthor of this project.
  • Add me as a collaborator.

Alternatively, if Conan Team wants to be collaborators of this project, then I can add them into this project.

If Conan Team has the willingness, please let me know. Thanks.

Haowei

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
czoidocommented, Nov 4, 2022

@saukijan,

I wanted to aplogize if my tone seemed combatibe, It was not the intention at all. I really wanted to know If I you had some issues I could help you with. Also, thanks a lot for your kind words regarding Conan, we try to do our best and we are very sorry if things break from time to time, I know it can be very frustrating. Regarding this project, as I said to @hwhsu1231 in the previous comment we will listen to all users feedback and try to offer the best solution we can come with, but sadly that will be after Conan 2.0 as we don’t have the resources now to tackle it.

Thanks a lot for your feedback.

0reactions
saukijancommented, Nov 4, 2022

sure @czoido, I opened issues both on conan-io and conan-center-index as well as contributed packages I also chimed in on existing issues, when relevant.

Regarding breaking changes, the artifactory migration comes to mind first. Sure it was not your fault, but it definitely was handled poorly. After that, the SSL certification issues, which caused the whole service outage, then pre v1.43 conan simply not working with the new conan-center, now this planned conan v2.0 changes and deprecation of cmake-conan and old cmake generators. It adds up and makes it harder than necessary to get conan adopted in-house as a standard tool, especially when we have to keep telling devs: “Oh it’s a conan issue, we know. Wait for the next conan update that should fix it” - it erodes trust in the tool as a whole and trust is already hard to build up.

Change is always hard and painful, I get that, but asking devs to have to keep changing their workflow to make a package manager work simply is ridiculous, especially when it comes out of the blue (though this is more of a personal problem of not keeping up with conan blogs)

I understand that conan.io folks have a lot on their plate and that you feel like the whole community is trying to pull you in different and contradicting directions. Conan project looks really great and the idea of it is of great value to the C++ community as a whole, but this combative tone really paints a bad picture of conan.io, a simple “Thanks for your work, we will look into it later” instead would go much further.

I want to love conan and help it grow into the defacto C++ package manager, but this whole affair makes me second guess that desire.

Read more comments on GitHub >

github_iconTop Results From Across the Web

hwhsu1231/cmake-conan-setup - GitHub
0. Motivation. This project aims to provide a NONINTRUSIVE way to integrate CMake with Conan using cmake-conan. It is because the typical usage...
Read more >
CMakeToolchain — conan 1.28.2 documentation
The CMakeToolchain can be used in the toolchain() method: from conans import ConanFile, CMake, CMakeToolchain class App(ConanFile): settings = "os", "arch", ...
Read more >
Conan Integration — ApprovalTests.cpp documentation
This example use Conan's cmake Generator. The conanfile.txt file lists the required libraries, and which generator to use (here, conan ):.
Read more >
Conan with cmake-conan missing conanbuild.conf
I am want to package a CMake project with conan. For that I use the following conanfile.py : import os from conans import...
Read more >
conan with modern cmake and namespacing : r/cpp - Reddit
I have gone through Mateusz Pusz's cmake/conan update in 2021 ... conan_paths , or for 2.0 with the new CMake toolchain without 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