I am trying to configure a CMakeLists.txt to include any external libraries. I have VSCode in Windows 10 compiling using g++. The compiler works. I have installed Poco (and others) using vcpkg to /src/vcpkg
. I created the following CMakeLists.txt
:
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_TOOLCHAIN_FILE "C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
# Add the directory where your packages are installed
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};C:/src/vcpkg/installed/x86-windows")
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
# Set the path to the Poco package configuration files
# set(Poco_DIR "C:/src/vcpkg/")
find_package(poco REQUIRED COMPONENTS Foundation JSON)
I have received various error stating that the PocoConfig.make
could not be found before the last attempt above. I now get the following error
[cmake] Could not find a configuration file for package "poco" that is compatible
[cmake] with requested version "".
[cmake]
[cmake] The following configuration files were considered but not accepted:
[cmake]
[cmake] C:/src/vcpkg/installed/x86-windows/share/poco/pocoConfig.cmake, version: 1.12.4 (32bit)
I thought this might be related to x64 vs x32 compatibility? So tried forcing with set(CMAKE_GENERATOR_PLATFORM "x86")
but this didn't help.
I have also downloaded the x64 library files using vcpkg and now have the following error:
[cmake] -- Found ZLIB: C:/src/vcpkg/installed/x64-windows/lib/zlib.lib (found version "1.2.13")
[cmake] CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
[cmake] Could NOT find PCRE2 (missing: PCRE2_LIBRARY)
[cmake] Call Stack (most recent call first):
[cmake] C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
[cmake] C:/src/vcpkg/installed/x64-windows/share/poco/FindPCRE2.cmake:94 (find_package_handle_standard_args)
[cmake] C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
[cmake] C:/src/vcpkg/installed/x64-windows/share/poco/PocoFoundationConfig.cmake:5 (find_dependency)
[cmake] C:/src/vcpkg/installed/x64-windows/share/poco/PocoConfig.cmake:35 (find_package)
[cmake] CMakeLists.txt:19 (find_package)
libs installed:
-a---- 30/05/2023 14:43 20424 pcre2-16.lib
-a---- 30/05/2023 14:43 20424 pcre2-32.lib
-a---- 30/05/2023 14:42 19974 pcre2-8.lib
-a---- 30/05/2023 14:43 2362 pcre2-posix.lib
I would appreciate some help point out why I am having such trouble with what should be a simple process.
Have tried the suggestions but still the same issues as below
[main] Configuring project: helloworld
[proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_TOOLCHAIN_FILE:STRING=c:/src/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=C:\msys64\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\msys64\mingw64\bin\g++.exe "-SC:/Users/phild/Documents/C++ Projects/helloworld" "-Bc:/Users/phild/Documents/C++ Projects/helloworld/build" -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 12.2.0
[cmake] -- The CXX compiler identification is GNU 12.2.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Found ZLIB: optimized;C:/src/vcpkg/installed/x64-windows/lib/zlib.lib;debug;C:/src/vcpkg/installed/x64-windows/debug/lib/zlibd.lib (found version "1.2.13")
[cmake] CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
[cmake] Could NOT find PCRE2 (missing: PCRE2_LIBRARY)
[cmake] Call Stack (most recent call first):
[cmake] C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
[cmake] C:/src/vcpkg/installed/x64-windows/share/poco/FindPCRE2.cmake:94 (find_package_handle_standard_args)
[cmake] C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake:853 (_find_package)
[cmake] C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
[cmake] C:/src/vcpkg/installed/x64-windows/share/poco/PocoFoundationConfig.cmake:5 (find_dependency)
[cmake] C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake:853 (_find_package)
[cmake] C:/src/vcpkg/installed/x64-windows/share/poco/PocoConfig.cmake:35 (find_package)
[cmake] C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake:853 (_find_package)
[cmake] CMakeLists.txt:13 (find_package)
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
PCRE2 library path is C:\src\vcpkg\installed\x64-windows\lib