conan-io / cmake-conan

CMake wrapper for conan C and C++ package manager
MIT License
820 stars 249 forks source link

MSVC unknown compiler version 1940 #653

Open RusuDevelopment opened 1 month ago

RusuDevelopment commented 1 month ago

What is your question?

Conan: Unknown MSVC compiler version [1940]

Have you read the CONTRIBUTING guide?

memsharded commented 1 month ago

Conan version? Do you have custom settings.yml? If so, please update them.

Please provide more details to reproduce that issue. What files, commands are you using? What is the full output?

RusuDevelopment commented 1 month ago

Conan version? Do you have custom settings.yml? If so, please update them.

Conan version -> 2.5.0 I don't have any custom settngs.yml, it's the default one.

-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045. CMake Error at src/conan.cmake:61 (message): Conan: Unknown MSVC compiler version [1940] Call Stack (most recent call first): src/conan.cmake:202 (_get_msvc_ide_version) src/conan.cmake:447 (_conan_detect_compiler) src/CMakeLists.txt:62 (conan_cmake_autodetect)

-- Configuring incomplete, errors occurred!

C:\Users\user\Desktop\Unitedtopia\server\build>cmake --build . MSBuild version 17.10.4+10fbfbf2e for .NET Framework MSBUILD : error MSB1009: Project file does not exist. Switch: ALL_BUILD.vcxproj

also used "cmake -G "Visual Studio 17 2022" to generate the project files but im getting same error " Conan: Unknown MSVC compiler version [1940]"

memsharded commented 1 month ago

So it seems you are using the cmake-conan integration, this wouldn't be a Conan issue, but a cmake-conan one Moving the ticket to that repo

RusuDevelopment commented 1 month ago

So it seems you are using the cmake-conan integration, this wouldn't be a Conan issue, but a cmake-conan one Moving the ticket to that repo

So i suppose someone else should reply right?

memsharded commented 1 month ago

It seems you are using an outdated cmake-conan version. Please make sure you are using the latest conan_provider.cmake and follow the instructions at: https://github.com/conan-io/cmake-conan, including passing the provider with -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=../conan_provider.cmake

RusuDevelopment commented 1 month ago

It seems you are using an outdated cmake-conan version. Please make sure you are using the latest conan_provider.cmake and follow the instructions at: https://github.com/conan-io/cmake-conan, including passing the provider with -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=../conan_provider.cmake

"Language 'CXX' is currently being enabled. Recursive call not allowed." while using the -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=../conan_provider.cmake

memsharded commented 1 month ago

Sorry, I don't know what you mean, or how you are getting that message. Can you please provide detailed and complete reproduction instructions? I'd need a minimal CMakeLists.txt to reproduce, the exact command you are using and the full output.

RusuDevelopment commented 1 month ago

Sorry, I don't know what you mean, or how you are getting that message. Can you please provide detailed and complete reproduction instructions? I'd need a minimal CMakeLists.txt to reproduce, the exact command you are using and the full output.

My CMakeLists.txt:

cmake_minimum_required(VERSION 3.24)

project(Buildo)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_BUILD_TYPE Debug)

add_subdirectory(src)
add_subdirectory(vendor)

The command im using: cmake -B build -S . -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=../conan_provider.cmake -DCMAKE_BUILD_TYPE=Release

Output:

-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
CMake Error: CMAKE_PROJECT_TOP_LEVEL_INCLUDES file does not exist: ../conan_provider.cmake
CMake Error at src/CMakeLists.txt:2 (project):
  Language 'CXX' is currently being enabled.  Recursive call not allowed.
memsharded commented 1 month ago

CMake Error: CMAKE_PROJECT_TOP_LEVEL_INCLUDES file does not exist: ../conan_provider.cmake

You need to provide the file

Also, the example is not complete, as we don't have the src or vendor CMakeLists.txt. Even if you pass it, we won't be able to reproduce because we don't have those files.

RusuDevelopment commented 1 month ago

CMake Error: CMAKE_PROJECT_TOP_LEVEL_INCLUDES file does not exist: ../conan_provider.cmake

You need to provide the file

Also, the example is not complete, as we don't have the src or vendor CMakeLists.txt. Even if you pass it, we won't be able to reproduce because we don't have those files.

Tell me what you need to be able to help me and i can send you

memsharded commented 1 month ago

It is explained in the readme: https://github.com/conan-io/cmake-conan

cmake-conan works with a CMake provider. You need to pass the right location to the provider.

RusuDevelopment commented 1 month ago

I did all of that just right now, i put the conan_provider.cmake text to CMakeLists.txt and conanfile.txt then i used this command:

cmake -B build -S . -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=C:\Users\user\Desktop\Unitedtopia\server\conan_provider.cmake -DCMAKE_BUILD_TYPE=Release

& i still get the same error as before

Output:

-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
CMake Error: CMAKE_PROJECT_TOP_LEVEL_INCLUDES file does not exist: ../conan_provider.cmake
CMake Error at src/CMakeLists.txt:2 (project):
  Language 'CXX' is currently being enabled.  Recursive call not allowed.

-- Configuring incomplete, errors occurred!

Also if i open the "src" folder wich contains conan.cmake, i still get the

CMake Error at conan.cmake:61 (message): Conan: Unknown MSVC compiler version [1940]
memsharded commented 1 month ago

Also if i open the "src" folder wich contains conan.cmake, i still get the

conan.cmake doesn't exist anymore, it shouldn't be a folder, it shouldn't be a file. The only file that should exist is the conan_provider.cmake.

I think there is still something else that is not being reported. If you are providing:

cmake -B build -S . -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=C:\Users\user\Desktop\Unitedtopia\server\conan_provider.cmake -DCMAKE_BUILD_TYPE=Release

The error message:

CMake Error: CMAKE_PROJECT_TOP_LEVEL_INCLUDES file does not exist: ../conan_provider.cmake

doesn't make sense. This is CMake, not Conan doing this, and CMake is just failing to find that file, so there is someone else somewhere setting CMAKE_PROJECT_TOP_LEVEL_INCLUDES

RusuDevelopment commented 1 month ago

Also if i open the "src" folder wich contains conan.cmake, i still get the

conan.cmake doesn't exist anymore, it shouldn't be a folder, it shouldn't be a file. The only file that should exist is the conan_provider.cmake.

I think there is still something else that is not being reported. If you are providing:

cmake -B build -S . -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=C:\Users\user\Desktop\Unitedtopia\server\conan_provider.cmake -DCMAKE_BUILD_TYPE=Release

The error message:

CMake Error: CMAKE_PROJECT_TOP_LEVEL_INCLUDES file does not exist: ../conan_provider.cmake

doesn't make sense. This is CMake, not Conan doing this, and CMake is just failing to find that file, so there is someone else somewhere setting CMAKE_PROJECT_TOP_LEVEL_INCLUDES

conan.cmake is a file, not a folder, i said it;s located in the "src" folder. One of the CMakeLists.txt has this ->

   include(${CMAKE_CURRENT_SOURCE_DIR}/conan.cmake)

If you sayin that this is because of CMake, what am i supposed to do?

memsharded commented 1 month ago

include(${CMAKE_CURRENT_SOURCE_DIR}/conan.cmake)

This is legacy Conan 1 integration, shouldn't be used anymore. The conan.cmake has been replaced by the conan_provider.cmake. This should be removed. You are mixing both Conan 1 and Conan 2 in the same project, this is not possible.

RusuDevelopment commented 1 month ago

include(${CMAKE_CURRENT_SOURCE_DIR}/conan.cmake)

This is legacy Conan 1 integration, shouldn't be used anymore. The conan.cmake has been replaced by the conan_provider.cmake. This should be removed. You are mixing both Conan 1 and Conan 2 in the same project, this is not possible.

It's an old project that i decided to continue.

So i figured something and i replace a few things. After using the command cmake -B build -S . -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=C:\Users\user\Desktop\Unitedtopia\server\build\cmake-conan/conan_provider.cmake -DCMAKE_BUILD_TYPE=Release

The output is now:

-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
CMake Error at src/conan_provider.cmake:636 (cmake_language):
  cmake_language Dependency providers can only be set as part of the first
  call to project().  More specifically,
  cmake_language(SET_DEPENDENCY_PROVIDER) can only be called while the first
  project() command processes files listed in
  CMAKE_PROJECT_TOP_LEVEL_INCLUDES.
Call Stack (most recent call first):
  src/CMakeLists.txt:44 (include)

-- Configuring incomplete, errors occurred!
memsharded commented 1 month ago

The error message indicates you are doing something else than passing -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES, you might have added an include() to it or something like that. Please provide full reproduction details, including all the CMakeLists.txt involved, otherwise it is not possible to help.

RusuDevelopment commented 1 month ago

The error message indicates you are doing something else than passing -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES, you might have added an include() to it or something like that. Please provide full reproduction details, including all the CMakeLists.txt involved, otherwise it is not possible to help.

CMakeLists.txt where conanfile.txt & conan_provider.cmake is located:

cmake_minimum_required(VERSION 3.30)

project(Buildo)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_BUILD_TYPE Debug)

add_subdirectory(src)
add_subdirectory(vendor)

vendor CMakeLists.txt:

add_subdirectory(enet)
add_subdirectory(dpp)
add_subdirectory(SFML-2.5.1)
add_subdirectory(cpp-httplib)

src CMakeLists.txt:

cmake_minimum_required(VERSION 3.28)
project(Buildo LANGUAGES CXX)

file(GLOB INCLUDE_FILES
    *.h
    **/*.h
    **/**/*.h
    **/**/**/*.h
    **/**/**/**/*.h)
file(GLOB SOURCE_FILES
    *.cpp
    **/*.cpp
    **/**/*.cpp
    **/**/**/*.cpp
    **/**/**/**/*.cpp)
add_executable(${PROJECT_NAME}
    ${INCLUDE_FILES}
    ${SOURCE_FILES}
)

if (MSVC)
    add_definitions(/EHsc)
else ()
    add_definitions(-fexceptions)
endif ()

set_target_properties(${PROJECT_NAME} PROPERTIES
    C_STANDARD 11
    CXX_STANDARD 23
    CXX_STANDARD_REQUIRED ON
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
    NOMINMAX
    WIN32_LEAN_AND_MEAN
    SPDLOG_FMT_EXTERNAL
    CPPHTTPLIB_OPENSSL_SUPPORT
)
set(CMAKE_BUILD_TYPE Debug)

if (CONAN_EXPORTED)
    include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
    conan_basic_setup()
else ()
    include(${CMAKE_CURRENT_SOURCE_DIR}/conan.cmake)
    conan_cmake_configure(REQUIRES
            fmt/9.0.0
            libcurl/8.1.2
            mariadb-connector-c/3.3.3
            sqlpp11/0.61
            magic_enum/0.9.2
            nlohmann_json/3.11.2
            spdlog/1.11.0
        GENERATORS cmake_find_package
        IMPORTS "bin, *.dll -> ./bin"
        OPTIONS
            fmt:shared=True
            openssl:shared=True
            libcurl:shared=True
            spdlog:shared=True
            mariadb-connector-c:shared=True)

    conan_cmake_autodetect(settings)
    conan_cmake_install(PATH_OR_REFERENCE .
        BUILD missing
        REMOTE conancenter
        SETTINGS ${settings})
endif ()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}")

find_package(fmt REQUIRED)
find_package(mariadb-connector-c REQUIRED)
find_package(Sqlpp11 REQUIRED)
find_package(magic_enum REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(spdlog REQUIRED)

target_include_directories(${PROJECT_NAME} PUBLIC 
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/enet/include
    ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/dpp/include
    ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/SFML-2.5.1/include
    ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/cpp-httplib
    ${sqlpp11_INCLUDE_DIRS}
)

target_link_libraries(${PROJECT_NAME} 
    enet
    dpp
    sfml-graphics
    fmt::fmt
    httplib::httplib
    mariadb-connector-c::mariadb-connector-c
    magic_enum::magic_enum
    nlohmann_json::nlohmann_json
    spdlog::spdlog
    ${sqlpp11_LIBRARIES}
)

Im not sure what exactly i should reproduce from -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES , i would appreciate if you could tell me?

memsharded commented 1 month ago
if (CONAN_EXPORTED)
    include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
    conan_basic_setup()
else ()
    include(${CMAKE_CURRENT_SOURCE_DIR}/conan.cmake)
    conan_cmake_configure(REQUIRES
            fmt/9.0.0
            libcurl/8.1.2
            mariadb-connector-c/3.3.3
            sqlpp11/0.61
            magic_enum/0.9.2
            nlohmann_json/3.11.2
            spdlog/1.11.0
        GENERATORS cmake_find_package
        IMPORTS "bin, *.dll -> ./bin"
        OPTIONS
            fmt:shared=True
            openssl:shared=True
            libcurl:shared=True
            spdlog:shared=True
            mariadb-connector-c:shared=True)

    conan_cmake_autodetect(settings)
    conan_cmake_install(PATH_OR_REFERENCE .
        BUILD missing
        REMOTE conancenter
        SETTINGS ${settings})
endif ()

this is the legacy thing that needs to be fully removed

I'd also remove the

cmake_minimum_required(VERSION 3.28)
project(Buildo LANGUAGES CXX)

In the src directory

RusuDevelopment commented 1 month ago

if (CONAN_EXPORTED)

    include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)

    conan_basic_setup()

else ()

    include(${CMAKE_CURRENT_SOURCE_DIR}/conan.cmake)

    conan_cmake_configure(REQUIRES

            fmt/9.0.0

            libcurl/8.1.2

            mariadb-connector-c/3.3.3

            sqlpp11/0.61

            magic_enum/0.9.2

            nlohmann_json/3.11.2

            spdlog/1.11.0

        GENERATORS cmake_find_package

        IMPORTS "bin, *.dll -> ./bin"

        OPTIONS

            fmt:shared=True

            openssl:shared=True

            libcurl:shared=True

            spdlog:shared=True

            mariadb-connector-c:shared=True)

    conan_cmake_autodetect(settings)

    conan_cmake_install(PATH_OR_REFERENCE .

        BUILD missing

        REMOTE conancenter

        SETTINGS ${settings})

endif ()

this is the legacy thing that needs to be fully removed

I'd also remove the


cmake_minimum_required(VERSION 3.28)

project(Buildo LANGUAGES CXX)

In the src directory

ok, i will try this later and come with a response

YoruAkio commented 1 month ago
if (CONAN_EXPORTED)

    include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)

    conan_basic_setup()

else ()

    include(${CMAKE_CURRENT_SOURCE_DIR}/conan.cmake)

    conan_cmake_configure(REQUIRES

            fmt/9.0.0

            libcurl/8.1.2

            mariadb-connector-c/3.3.3

            sqlpp11/0.61

            magic_enum/0.9.2

            nlohmann_json/3.11.2

            spdlog/1.11.0

        GENERATORS cmake_find_package

        IMPORTS "bin, *.dll -> ./bin"

        OPTIONS

            fmt:shared=True

            openssl:shared=True

            libcurl:shared=True

            spdlog:shared=True

            mariadb-connector-c:shared=True)

    conan_cmake_autodetect(settings)

    conan_cmake_install(PATH_OR_REFERENCE .

        BUILD missing

        REMOTE conancenter

        SETTINGS ${settings})

endif ()

this is the legacy thing that needs to be fully removed I'd also remove the


cmake_minimum_required(VERSION 3.28)

project(Buildo LANGUAGES CXX)

In the src directory

ok, i will try this later and come with a response

did you solve the problem?

mferrera commented 3 weeks ago

I was able to solve this for conan<2 like so:

YoruAkio commented 3 weeks ago

I was able to solve this for conan<2 like so:

Cool I'll try it then, Thx

edit:

The error was solved and now i can build perfectly thanks >_