Giter Site home page Giter Site logo

Comments (21)

0xlitf avatar 0xlitf commented on August 22, 2024 2

Thank you so much @memsharded @cristianadam , it is you who make Conan more excellent!

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024 1

We have added default compiler.runtime to conan_provider.cmake in #609.

It would be necessary:

  • To update your conan_provider.cmake
  • If QtCreator has it embedded or something, it would need an update too

I am closing this ticket as solved, but please do not hesitate to create a new ticket for any further issue or question. Many thanks!

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024

Hi @0xlitf

Thanks very much for your report.
I think this might be an issue of the cmake-conan wrapper, not Conan itself, so I am transferring this ticket to that repo.

from cmake-conan.

0xlitf avatar 0xlitf commented on August 22, 2024

@memsharded Thanks for the kind help

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024

Hi @0xlitf

I am having a look trying to understand where is the gap.
The cmake-conan code contains:

if(CMAKE_MSVC_RUNTIME_LIBRARY)
            if(CMAKE_MSVC_RUNTIME_LIBRARY MATCHES ".*DLL$")
                set(_COMPILER_RUNTIME "dynamic")
            else()
                set(_COMPILER_RUNTIME "static")
            endif()

So in theory it should be able to set the runtime too, I don't know why it is not working in your case. Lets try the following:

  • Can you please make sure you are using the latest conan_provider.cmake?
  • Can you share your CMakeLists.txt? Or at least parts of it, is it possible that you have a quite old cmake_minimum_required and CMAKE_MSVC_RUNTIME_LIBRARY is not set? You can debug this by adding a message() in the conan_provider.cmake code.

from cmake-conan.

0xlitf avatar 0xlitf commented on August 22, 2024

Hi @memsharded,
I checked my files as you pointed out, CMAKE_MSVC_RUNTIME_LIBRARY is null,
cmake_minimum_required(VERSION 3.27.7),

Things got mess up, because when I remove all the caches and settings of QtCreator(by deleting C:\Users\UserName\AppData\Local\QtProject C:\Users\UserName\AppData\Roaming\QtProject C:\Users\UserName\.conan2), and downgrade QtCreator to 11.0.3, conan to version 2.0.9, everything is ok even CMAKE_MSVC_RUNTIME_LIBRARY is empty.

Then I test QtCreator 12.0.0/12.0.1 + conan 2.0.16~conan 2.0.14, all of the cases failed with error I mentioned above.
I try to use QtCreator 11.0.3 + conan 2.0.16, error occurs with:

Install finished successfully
-- CMake-conan: CONAN_GENERATORS_FOLDER=C:\Users\UserName\Downloads\build-UsingSpdlog---QtCreator-11.0.3-Desktop_Qt_6_6_1_MSVC2019_64bit-Debug\conan-dependencies\build\conan
-- Configuring done (28.1s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/UserName/Downloads/build-UsingSpdlog---QtCreator-11.0.3-Desktop_Qt_6_6_1_MSVC2019_64bit-Debug/conan-dependencies/build
CMake Error at C:/Users/UserName/Downloads/build-UsingSpdlog---QtCreator-11.0.3-Desktop_Qt_6_6_1_MSVC2019_64bit-Debug/conan-dependencies/conan_paths.cmake:2 (list):
  Syntax error in cmake code at

    C:/Users/UserName/Downloads/build-UsingSpdlog---QtCreator-11.0.3-Desktop_Qt_6_6_1_MSVC2019_64bit-Debug/conan-dependencies/conan_paths.cmake:2

  when parsing string

    C:\Users\UserName\Downloads\build-UsingSpdlog---QtCreator-11.0.3-Desktop_Qt_6_6_1_MSVC2019_64bit-Debug\conan-dependencies\build\conan

  Invalid character escape '\U'.
Call Stack (most recent call first):
  C:/Users/UserName/Downloads/build-UsingSpdlog---QtCreator-11.0.3-Desktop_Qt_6_6_1_MSVC2019_64bit-Debug/.qtc/package-manager/auto-setup.cmake:151 (include)
  C:/Users/UserName/Downloads/build-UsingSpdlog---QtCreator-11.0.3-Desktop_Qt_6_6_1_MSVC2019_64bit-Debug/.qtc/package-manager/auto-setup.cmake:155 (qtc_auto_setup_conan)
  CMakeLists.txt:28 (project)


CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
CMake process exited with exit code 1.

Elapsed time: 00:29.

from cmake-conan.

0xlitf avatar 0xlitf commented on August 22, 2024

As of now, this problem still exists on me, but it can be bypassed:

  1. Downgrade QtCreator version to 11.0.3, the link is qtcreator 11.0.3
  2. remove .conan2 folder in C:\Users\UserName
  3. remove C:\Users\UserName\AppData\Local\QtProject C:\Users\UserName\AppData\Roaming\QtProject
  4. Downgrade conan to version 2.0.9

Then it works.

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024

Uhm, now I am little confused.

I see in the first trace that there was a message with:

CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$CONFIG:Debug:Debug>

But for some reason later the CMAKE_MSVC_RUNTIME_LIBRARY is empty. Maybe your CMakeLists.txt is doing something, could you please share your CMakeLists.txt?

from cmake-conan.

0xlitf avatar 0xlitf commented on August 22, 2024

@memsharded Sorry about that, I delete that code and forget to push.
image

This is the repo UsingSpdlog

It can be build at QtCreator 11.0.3 and conan 2.0.9 now.

CMakeLists.txt is simple:

cmake_minimum_required(VERSION 3.27.7)

get_filename_component(current_dir "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
string(REPLACE " " "" current_dir "${current_dir}")
string(REPLACE "-" "_" current_dir "${current_dir}")

set(CMAKE_VERBOSE_MAKEFILE ON)
message("CMake start \n\t directory name: ${current_dir}")

message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY ${CMAKE_MSVC_RUNTIME_LIBRARY}")

project("${current_dir}" VERSION 0.1 LANGUAGES CXX)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
find_package(spdlog REQUIRED)

message("CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
file(GLOB ${PROJECT_NAME_UPPER}_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
message("src: ${${PROJECT_NAME_UPPER}_SRC}")
add_executable(${PROJECT_NAME}
   ${${PROJECT_NAME_UPPER}_SRC}
)

target_include_directories(${PROJECT_NAME} PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/
)

target_link_libraries(${PROJECT_NAME}
    Qt${QT_VERSION_MAJOR}::Core
    spdlog::spdlog
)

include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

CMAKE_MSVC_RUNTIME_LIBRARY is null in QtCreator's General Messages:


Running C:\Qt\Tools\CMake_64\bin\cmake.exe -S C:/Users/UserName/Downloads/UsingSpdlog -B C:/Users/UserName/Downloads/build-UsingSpdlog-Desktop_Qt_6_6_1_MSVC2019_64bit_with_WebEngine-Release in C:\Users\UserName\Downloads\build-UsingSpdlog-Desktop_Qt_6_6_1_MSVC2019_64bit_with_WebEngine-Release.
CMake start 
	 directory name: UsingSpdlog
-- CMAKE_MSVC_RUNTIME_LIBRARY
-- Conan: Component target declared 'spdlog::spdlog'
-- Conan: Component target declared 'fmt::fmt'
CMAKE_CURRENT_SOURCE_DIR: C:/Users/UserName/Downloads/UsingSpdlog
src: C:/Users/UserName/Downloads/UsingSpdlog/main.cpp
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/UserName/Downloads/build-UsingSpdlog-Desktop_Qt_6_6_1_MSVC2019_64bit_with_WebEngine-Release
Elapsed time: 00:01.

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024

It might be some interaction with QtCreator maybe, we need to investigate this, but it might take a bit more.

You might be able to do some quick checks without QtCreator, just comment the Qt lines and call cmake from the command line, that could be useful information to understand what is happening

from cmake-conan.

0xlitf avatar 0xlitf commented on August 22, 2024

@memsharded Ok, thank you for taking the time to help me do this.

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024

Hi @0xlitf

Sorry, I am a bit confused, is the issue solved now? Why did you close the ticket? I commented that this needs more investigation, but if it is not working, it should remain in "open" state in Github.

Is the code that sets the MSVC_RUNTIME now pushed to the repo? If it is maybe we can try to reproduce.

from cmake-conan.

0xlitf avatar 0xlitf commented on August 22, 2024

@memsharded
Sorry, I misunderstand you.
This problem exists, and I am still working on this.

I push a conan_for_vs2022.bat which I used to generate .sln, it works fine.
Perhaps, it's a problem of QtCreator 12.0.x.

The code below is for test, it is useless:

option(STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" ON)

if (STATIC_WINDOWS_RUNTIME)
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
else()
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()

This error can be easily reproduced by UsingSpdlog under Qt6.6.1, QtCreator 12.0.1 and conan 2.0.9(or 2.0.16 with the same error).

from cmake-conan.

0xlitf avatar 0xlitf commented on August 22, 2024

@memsharded Hi, I do some logs, this is the difference between QtCreator 11.0.3(left) with 12.0.1(right) (conan version 2.0.9):
image

I can not trace what happend in this line execute_process(COMMAND ${CONAN_COMMAND} install ${CMAKE_SOURCE_DIR} ${CONAN_ARGS} ${ARGN} --format=json at 'function(conan_install)'

conan profile show -pr defaultshows:

Host profile:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows

Build profile:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows

but conan def print_profiles(profiles) no output when run cmake in QtCreator 12.0.1:

compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024

I am checking your project.

Your conan_provider.cmake is either broken or too old. Please update it to the latest one from https://github.com/conan-io/cmake-conan/blob/develop2/conan_provider.cmake

Then your https://github.com/0xlitf/UsingSpdlog/blob/main/conan_for_vs2022.bat code is not using the cmake-conan integration at all, but the "standard" and explicit conan install + cmake flow, so that removes the cmake-conan possible issues, but I guess that you still want to use this cmake-conan integration? Or maybe you would be good using conan install + cmake --preset modern flow?

If we want to do cmake-conan integration, I'd suggest start one at a time. Start with spdlog only first, no Qt at all, and lets try to make that work using the command line, that means, calling cmake on the command line, and it should manage to call Conan. I have tested it with the latest conan_provider.cmake and I managed it to install spdlog correctly. I am willing to collaborate on your Github project, but it would be good to define all the context constraints, goals, flows, because it seems there are a bit too many moving pieces at this moment and it is difficult to know where the issues come from. Thanks!

from cmake-conan.

0xlitf avatar 0xlitf commented on August 22, 2024

Thanks for help,
Replacing conan_provider.cmake did not solve it.
This problem is quite beyond me, so leave it to Qt Corporation.

Should I close this issue now? Or Close as not planned?

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024

As you wish.
I can perfectly help you to make it run in your repo without the QtCreator automatic thing, commands should be pretty straightforward, and if QtCreator is using CMake then it will probably work in QtCreator, just not using the QtCreator built-in automatic setup.

So feel free to close the issue or let me know if you still want to try to set the project up to work with Conan dependencies.

from cmake-conan.

cristianadam avatar cristianadam commented on August 22, 2024

Qt Creator uses the conan_provider.cmake from conan-io. It might not just be the latest version. I've opened up https://bugreports.qt.io/browse/QTCREATORBUG-30169

The fix was to forward CMAKE_MSVC_RUNTIME_LIBRARY to conan via the toolchain file used to configure the conan dependencies.

From what I have seen conan is expecting:

[cmake] ERROR: There are invalid packages:
[cmake] fmt/10.2.0: Invalid: 'settings.compiler.runtime' value not defined
[cmake] spdlog/1.12.0: Invalid: 'settings.compiler.runtime' value not defined

when compiled with MSVC. This only works if the user would explicitly set CMAKE_MSVC_RUNTIME_LIBRARY.

I think these packages should work on MSVC without having the user to set explicitly CMAKE_MSVC_RUNTIME_LIBRARY. I don't know if this is a conan issue with MSVC or if it's a spdlog/fmt package issue.

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024

Thanks @cristianadam for your feedback.

Indeed, Conan needs the compiler.runtime setting to be defined for dependencies, because such dependencies might use other build systems and the default to use dynamic is not always evident. So it is a required setting to install dependencies. The way that Conan understand the settings definitions defaults is that not defining things is not the same meaning as defining it with the default value, not defining a setting would mean that such setting doesn't apply, but when using msvc compiler a runtime will be used, either dynamic or static, but it is mandatory.

It is true that the cmake-conan integration requires at this moment it to be defined, so it is possible that we might want to consider also it not being defined as equivalent to define the dynamic runtime, I'll check with @jcar87 about this, thanks very much for the hints!

from cmake-conan.

0xlitf avatar 0xlitf commented on August 22, 2024

Hi @cristianadam, thanks.
Manually specify CMAKE_MSVC_RUNTIME_LIBRARY works fine after modified auto-setup.cmake Under your direction.
I will update the repo UsingSpdlog later.

from cmake-conan.

memsharded avatar memsharded commented on August 22, 2024

Trying to improve the default in #609

from cmake-conan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.