Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC unknown compiler version 1940 #653

Open
1 task done
RusuDevelopment opened this issue Jul 12, 2024 · 23 comments
Open
1 task done

MSVC unknown compiler version 1940 #653

RusuDevelopment opened this issue Jul 12, 2024 · 23 comments
Assignees

Comments

@RusuDevelopment
Copy link

What is your question?

Conan: Unknown MSVC compiler version [1940]

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Jul 12, 2024
@memsharded
Copy link
Member

memsharded commented Jul 12, 2024

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
Copy link
Author

RusuDevelopment commented Jul 12, 2024

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
Copy link
Member

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

@memsharded memsharded transferred this issue from conan-io/conan Jul 12, 2024
@RusuDevelopment
Copy link
Author

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

memsharded commented Jul 12, 2024

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
Copy link
Author

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
Copy link
Member

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

  • Need to put the conan_provider.cmake in the repo, typically close to the CMakeLists.txt
  • Put a conanfile with the dependencies
  • Pass the location to your conan_provider.cmake in the -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES

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

@RusuDevelopment
Copy link
Author

RusuDevelopment commented Jul 12, 2024

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link
Author

RusuDevelopment commented Jul 12, 2024

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
Copy link
Member

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
Copy link
Author

RusuDevelopment commented Jul 12, 2024

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
Copy link
Member

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
Copy link
Author

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
Copy link

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
Copy link

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

  • Store conan.cmake locally
  • Modify this condition:

    cmake-conan/conan.cmake

    Lines 58 to 59 in df0f64a

    elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1940)
    set(${result} 17 PARENT_SCOPE)

    to:
      elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1949)
  • This resolves MSCV_VERSIONS up to <1949 to Visual Studio 17. 1949 is chosen arbitrarily above 1940, the source of the error

@YoruAkio
Copy link

YoruAkio commented Aug 15, 2024

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

  • Store conan.cmake locally

  • Modify this condition:

    cmake-conan/conan.cmake

    Lines 58 to 59 in df0f64a

    elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1940)
    set(${result} 17 PARENT_SCOPE)

    to:

      elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1949)
  • This resolves MSCV_VERSIONS up to <1949 to Visual Studio 17. 1949 is chosen arbitrarily above 1940, the source of the error

Cool I'll try it then, Thx

edit:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants