Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Upgraded to QtCreator 9.0.0 and now CMake can't find boost? (QtCreator + CMAKE + VCPKG + Boost)

Upgraded to QtCreator 9.0.0 and now CMake can't find boost? (QtCreator + CMAKE + VCPKG + Boost)

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
7 Posts 3 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MRiedel
    wrote on last edited by
    #1

    I have a Qt Project that uses CMake and VCPKG. It used to work with vcpkg configuration through setting the CMAKE_TOOLCHAIN_FILE in the system environment.

    I updated to QtCreator 9.0.0 and deleted my build output folder and the CMakeLists.txt.user file. Opened the cmake project selected the same kit and now CMake can't find boost and doesn't seem to know about VCPKG at all.

    If I run CMake from a developer shell it works fine.

    I found that I can make it work in QtCreator by explicitly setting "-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake" in the "Additional CMake options in the initial configuration tab of the Project Build settings. Then I have to click "Re- configure with Initial Parameters". I'm not a fan of this because I'd have to instruct our team to do this for every project which will increase friction of using QtCreator more.

    It's possible that I'm remembering wrong, but my recollection is that QtCreator would work with VCPKG by pulling CMAKE_TOOLCHAIN_FILE from the system environment. Now that doesn't seem to happen.

    -----Output from non working cmake run-----
    Running C:\Program Files\CMake\bin\cmake.exe -S C:/Projects/ASIO_Client -B C:/Projects/Projects/build-ASIO_Client-Desktop_Qt_6_4_1_MSVC2022_64bit-Debug "-DCMAKE_GENERATOR:STRING=Ninja" "-DCMAKE_BUILD_TYPE:STRING=Debug" "-DQT_QMAKE_EXECUTABLE:FILEPATH=C:/Qt/6.4.1/msvc2019_64/bin/qmake.exe" "-DCMAKE_PREFIX_PATH:PATH=C:/Qt/6.4.1/msvc2019_64" "-DCMAKE_C_COMPILER:FILEPATH=C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.33.31629/bin/HostX64/x64/cl.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.33.31629/bin/HostX64/x64/cl.exe" "-DCMAKE_CXX_FLAGS_INIT:STRING=" in C:\Projects\build-ASIO_Client-Desktop_Qt_6_4_1_MSVC2022_64bit-Debug.
    -- The CXX compiler identification is MSVC 19.33.31629.0
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.33.31629/bin/HostX64/x64/cl.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- CMAKE_TOOLCHAIN_FILE = C:\vcpkg\scripts\buildsystems\vcpkg.cmake
    CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
    Could NOT find Boost (missing: Boost_INCLUDE_DIR system regex date_time)
    (Required is at least version "1.54.0")
    Call Stack (most recent call first):
    C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
    C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
    CMakeLists.txt:42 (find_package)

    -----Output when CMAKE_TOOL_CHAIN_FILE is explicitly specified----
    Running C:\Program Files\CMake\bin\cmake.exe -S C:/Projects/ASIO_Client -B C:/Projects/build-ASIO_Client-Desktop_Qt_6_4_1_MSVC2022_64bit-Debug "-DCMAKE_GENERATOR:STRING=Ninja" "-DCMAKE_BUILD_TYPE:STRING=Debug" "-DQT_QMAKE_EXECUTABLE:FILEPATH=C:/Qt/6.4.1/msvc2019_64/bin/qmake.exe" "-DCMAKE_PREFIX_PATH:PATH=C:/Qt/6.4.1/msvc2019_64" "-DCMAKE_C_COMPILER:FILEPATH=C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.33.31629/bin/HostX64/x64/cl.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.33.31629/bin/HostX64/x64/cl.exe" "-DCMAKE_CXX_FLAGS_INIT:STRING=" "-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake" in C:\Projects\build-ASIO_Client-Desktop_Qt_6_4_1_MSVC2022_64bit-Debug.
    -- The CXX compiler identification is MSVC 19.33.31629.0
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.33.31629/bin/HostX64/x64/cl.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- CMAKE_TOOLCHAIN_FILE = C:\vcpkg\scripts\buildsystems\vcpkg.cmake
    -- Found Boost: C:/vcpkg/installed/x64-windows/include (found suitable version "1.78.0", minimum required is "1.54.0") found components: system regex date_time
    -- Boost: 1.78.0
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - not found
    -- Found Threads: TRUE
    -- Performing Test HAVE_STDATOMIC
    -- Performing Test HAVE_STDATOMIC - Success
    -- Found WrapAtomic: TRUE
    -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
    -- Configuring done
    -- Generating done

    1 Reply Last reply
    0
    • cristian-adamC Offline
      cristian-adamC Offline
      cristian-adam
      wrote on last edited by
      #2

      Qt Creator 9 has changed the default value of Package manager auto setup to Disabled.

      Make sure to enable it like this:
      alt text

      I'll make sure to bring it back as Enabled in Qt Creator 10 by fixing the issue that caused it to be disabled in Qt Creator 9.

      1 Reply Last reply
      1
      • cristian-adamC Offline
        cristian-adamC Offline
        cristian-adam
        wrote on last edited by
        #3

        The feature has been documented https://www.qt.io/blog/qt-creator-cmake-package-manager-auto-setup

        1 Reply Last reply
        1
        • M Offline
          M Offline
          MRiedel
          wrote on last edited by
          #4

          Thanks for the replies. "Package manager auto setup" wasn't checked in my QtCreator setup. Enabling that option didn't help. I'm going to have to process the link/documentation from cristian-adam. That looks like it might help however I'm confused why (or even how) pulling "CMAKE_TOOLCHAIN_FILE" is no longer working.

          D 1 Reply Last reply
          0
          • M MRiedel

            Thanks for the replies. "Package manager auto setup" wasn't checked in my QtCreator setup. Enabling that option didn't help. I'm going to have to process the link/documentation from cristian-adam. That looks like it might help however I'm confused why (or even how) pulling "CMAKE_TOOLCHAIN_FILE" is no longer working.

            D Offline
            D Offline
            DerReisende
            wrote on last edited by
            #5

            @MRiedel I am using the following CMake code in my project to setup vcpkg and qt for my windows projects. With it you only need a VCPKG_ROOT environment var and toolchain will be configured automatically.
            Although I am primarily using CLion with that setup code I am able to also switch to Qt Creator when necessary. Hope this helps:

            cmake_minimum_required(VERSION 3.24)
            
            if (DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
                set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
                        CACHE STRING "")
            endif ()
            # set vcpkg target triplet to silence some warnings
            if (DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
                set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
            endif ()
            
            IF (WIN32)
                set(CMAKE_PREFIX_PATH C:\\Qt\\6.4.1\\msvc2019_64\\lib\\cmake)
            ENDIF (WIN32)
            

            project definition follows after...

            1 Reply Last reply
            0
            • cristian-adamC Offline
              cristian-adamC Offline
              cristian-adam
              wrote on last edited by
              #6

              @MRiedel CMake should work in Qt Creator in the same way it works from the command line.

              That being said, Qt Creator 9 introduced the notion of Configure Environment due to support of CMake presets.

              alt text

              If you were not aware of this distinction, you might have set the value in the build part, which is too late and CMake can't find vcpkg and nothing works.

              The auto-setup will set the CMAKE_TOOLCHAIN_FILE for you, but vcpkg needs to be in PATH.

              1 Reply Last reply
              0
              • cristian-adamC Offline
                cristian-adamC Offline
                cristian-adam
                wrote on last edited by
                #7

                I've decided to give it a try with https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/tests/manual/vcpkg

                Since CMAKE_TOOLCHAIN_FILE is taken into consideration from version 3.21 I've modified the CMakeLists.txt as:

                cmake_minimum_required(VERSION 3.21)
                
                message(STATUS "CMake version: ${CMAKE_VERSION}")
                message(STATUS "CMAKE_TOOLCHAIN_FILE: -D ${CMAKE_TOOLCHAIN_FILE} ENV: $ENV{CMAKE_TOOLCHAIN_FILE}")
                
                project(vcpkg-libfmt)
                
                find_package(fmt CONFIG REQUIRED)
                
                add_executable(vcpkg-libfmt main.cpp)
                target_link_libraries(vcpkg-libfmt PRIVATE fmt::fmt)
                
                install(TARGETS vcpkg-libfmt)
                

                And to my surprise I've got:

                -- CMake version: 3.22.1
                -- CMAKE_TOOLCHAIN_FILE: -D  ENV: c:\Projects\github\vcpkg\scripts\buildsystems\vcpkg.cmake
                

                Which means that CMake for some reason is not setting the value to CMAKE_TOOLCHAIN_FILE from the environment variable.

                Adding the line:

                file(TO_CMAKE_PATH "$ENV{CMAKE_TOOLCHAIN_FILE}" CMAKE_TOOLCHAIN_FILE)
                

                Results in proper project configuration:

                -- CMake version: 3.22.1
                -- CMAKE_TOOLCHAIN_FILE: -D c:/Projects/github/vcpkg/scripts/buildsystems/vcpkg.cmake  ENV: c:\Projects\github\vcpkg\scripts\buildsystems\vcpkg.cmake 
                -- Running vcpkg install
                Detecting compiler hash for triplet x64-windows...
                The following packages will be built and installed:
                    fmt[core]:x64-windows -> 7.1.3
                
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved