I'm working through the tutorial set.
I started with Install and use packages with CMake and transitioned to this tutorial Create and publish packages. This package creation tutorial is not working.
The first observation I had was that the sha
returned by the first vcpkg install vcpkg-sample-library --overlay-ports=...
step doesn't match the sha
in the documentation.
Next, after updating the sha
the second vcpkg install vcpkg-sample-library --overlay-ports=...
doesn't compile anything on my system, but the example shows that something is compiled.
Then verifying with the helloworld
project fails during the cmake --preset=default
stage.
System information and details follow. It's long winded with all the steps to illusrate I did what the example says to do.
System Information
- Windows 11 Pro N (23H2 / 22631.3007)
- VS2017 (15.9.59), VS2019 (16.11.33) and VS2022 (17.8.4) are all installed
- cmake 3.23.1
- git 2.42.0.windows.2
Details
Install and Use Packages
c:\Users\rocha\Desktop\VCPKG-TEST>git clone https://github.com/microsoft/vcpkg.git
git clone https://github.com/microsoft/vcpkg.git
Cloning into 'vcpkg'...
Updating files: 100% (11074/11074), done.
c:\Users\rocha\Desktop\VCPKG-TEST>cd vcpkg
cd vcpkg
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg>bootstrap-vcpkg.bat
bootstrap-vcpkg.bat
Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2024-01-11/vcpkg.exe -> C:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\vcpkg.exe... done.
Validating signature... done.
vcpkg package management program version 2024-01-11-710a3116bbd615864eef5f9010af178034cb9b44
See LICENSE.txt for license information.
Telemetry
---------
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.
Read more about vcpkg telemetry at docs/about/privacy.md
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg>set "VCPKG_ROOT=%CD%"
set "VCPKG_ROOT=%CD%"
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg>set VCPKG_ROOT
set VCPKG_ROOT
VCPKG_ROOT=c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg>set "PATH=%PATH%;%VCPKG_ROOT%"
set "PATH=%PATH%;%VCPKG_ROOT%"
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg>set PATH
set PATH
PATH=C:\Program Files\Eclipse Adoptium\jdk-11.0.21.9-hotspot\bin;C:\Program Files\Python310\Scripts\;C:\Program Files\Python310\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Perforce\;C:\Program Files\IcedTeaWeb\WebStart\bin;C:\Program Files\CMake\bin;C:\Program Files (x86)\Graphviz2.38\bin;C:\Program Files\doxygen\bin;C:\Program Files\gs\gs9.52\bin;C:\Program Files\Git\cmd;C:\Users\rocha\AppData\Local\Microsoft\WindowsApps;C:\Users\rocha\AppData\Local\Programs\MiKTeX\miktex\bin\x64\;c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg>mkdir helloworld
mkdir helloworld
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg>cd helloworld
cd helloworld
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>vcpkg new --application
vcpkg new --application
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>vcpkg add port fmt
vcpkg add port fmt
Succeeded in adding ports to vcpkg.json file.
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>type vcpkg.json
type vcpkg.json
{
"dependencies": [
"fmt"
]
}
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>type CMakeLists.txt
type CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(HelloWorld)
find_package(fmt CONFIG REQUIRED)
add_executable(HelloWorld helloworld.cpp)
target_link_libraries(HelloWorld PRIVATE fmt::fmt)
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>type helloworld.cpp
type helloworld.cpp
#include <fmt/core.h>
int main()
{
fmt::print("Hello World!\n");
return 0;
}
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>type CMakePresets.json
type CMakePresets.json
{
"version": 3,
"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>cmake --preset=default
cmake --preset=default
Preset CMake variables:
CMAKE_TOOLCHAIN_FILE="c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg/scripts/buildsystems/vcpkg.cmake"
-- Building for: Visual Studio 17 2022
-- Running vcpkg install
Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)...
A suitable version of cmake was not found (required v3.27.1) Downloading portable cmake 3.27.1...
Downloading cmake...
https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-windows-i386.zip->C:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\downloads\cmake-3.27.1-windows-i386.zip
Downloading https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-windows-i386.zip
Extracting cmake...
Detecting compiler hash for triplet x64-windows...
A suitable version of powershell-core was not found (required v7.2.11) Downloading portable powershell-core 7.2.11...
Downloading powershell-core...
https://github.com/PowerShell/PowerShell/releases/download/v7.2.11/PowerShell-7.2.11-win-x86.zip->C:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\downloads\PowerShell-7.2.11-win-x86.zip
Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.2.11/PowerShell-7.2.11-win-x86.zip
Extracting powershell-core...
The following packages will be built and installed:
fmt:[email protected] -- C:\Users\rocha\AppData\Local\vcpkg\registries\git-trees\405156a2b01c91258bf66768ceb3ae75c1caba7f
* vcpkg-cmake:x64-windows@2023-05-04 -- C:\Users\rocha\AppData\Local\vcpkg\registries\git-trees\88a7058fc7fa73a9c4c99cfcae9d79e2abf87a5a
* vcpkg-cmake-config:x64-windows@2022-02-06#1 -- C:\Users\rocha\AppData\Local\vcpkg\registries\git-trees\8d54cc4f487d51b655abec5f9c9c3f86ca83311f
Additional packages (*) will be modified to complete this operation.
A suitable version of 7zip was not found (required v23.1.0) Downloading portable 7zip 23.1.0...
Downloading 7zip...
https://www.7-zip.org/a/7z2301-extra.7z->C:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\downloads\7z2301-extra.7z
Downloading https://www.7-zip.org/a/7z2301-extra.7z
Extracting 7zip...
Restored 3 package(s) from C:\Users\rocha\AppData\Local\vcpkg\archives in 64.6 ms. Use --debug to see more details.
Installing 1/3 vcpkg-cmake-config:x64-windows@2022-02-06#1...
Elapsed time to handle vcpkg-cmake-config:x64-windows: 4.79 ms
vcpkg-cmake-config:x64-windows package ABI: 20b02959c1badd0b0b2b18e80846b45687839ecb3ca822a7d65fb1b8142ed722
Installing 2/3 vcpkg-cmake:x64-windows@2023-05-04...
Elapsed time to handle vcpkg-cmake:x64-windows: 4.7 ms
vcpkg-cmake:x64-windows package ABI: c62da996a7b71d8c0f633c18ce2938d82903a191cc178cbee3722793543520d5
Installing 3/3 fmt:[email protected]...
Elapsed time to handle fmt:x64-windows: 13.5 ms
fmt:x64-windows package ABI: c87d6137cd1d670d2a0b4bae5d358af57d6c3f0973f0f38fe4e2780a971d4746
Total install time: 23.1 ms
The package fmt provides CMake targets:
find_package(fmt CONFIG REQUIRED)
target_link_libraries(main PRIVATE fmt::fmt)
# Or use the header-only version
find_package(fmt CONFIG REQUIRED)
target_link_libraries(main PRIVATE fmt::fmt-header-only)
-- Running vcpkg install - done
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.38.33134.0
-- The CXX compiler identification is MSVC 19.38.33134.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/rocha/Desktop/VCPKG-TEST/vcpkg/helloworld/build
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>cmake --build build
cmake --build build
MSBuild version 17.8.3+195e7f5a3 for .NET Framework
Checking Build System
Building Custom Rule C:/Users/rocha/Desktop/VCPKG-TEST/vcpkg/helloworld/CMakeLists.txt
helloworld.cpp
HelloWorld.vcxproj -> C:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld\build\Debug\HelloWorld.exe
Building Custom Rule C:/Users/rocha/Desktop/VCPKG-TEST/vcpkg/helloworld/CMakeLists.txt
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>build\Debug\HelloWorld.exe
build\Debug\HelloWorld.exe
Hello World!
Create and publish packages
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>cd ..
cd ..
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg>mkdir custom-overlay
mkdir custom-overlay
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg>cd custom-overlay
cd custom-overlay
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay>mkdir vcpkg-sample-library
mkdir vcpkg-sample-library
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay>type vcpkg-sample-library\vcpkg.json
type vcpkg-sample-library\vcpkg.json
{
"name": "vcpkg-sample-library",
"version": "1.0.0",
"homepage": "https://github.com/microsoft/vcpkg-docs/tree/cmake-sample-lib",
"description": "A sample C++ library designed to serve as a foundational example for a tutorial on packaging libraries with vcpkg.",
"license": "MIT",
"dependencies": [
{
"name" : "vcpkg-cmake",
"host" : true
},
{
"name" : "vcpkg-cmake-config",
"host" : true
},
"fmt"
]
}
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay>type vcpkg-sample-library\usage
type vcpkg-sample-library\usage
vcpkg-sample-library provides CMake targets:
find_package(my_sample_lib CONFIG REQUIRED)
target_link_libraries(main PRIVATE my_sample_lib::my_sample_lib)
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay>type vcpkg-sample-library\portfile.cmake
type vcpkg-sample-library\portfile.cmake
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Microsoft/vcpkg-docs
REF "${VERSION}"
SHA512 0 # This is a temporary value. We will modify this value in the next section.
HEAD_REF cmake-sample-lib
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME "my_sample_lib")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)
Deviation #1: Run the command so it fails and gives the Actual hash. The hash value does not match the example documentation
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay>vcpkg install vcpkg-sample-library --overlay-ports="%CD%"
vcpkg install vcpkg-sample-library --overlay-ports="%CD%"
warning: In the September 2023 release, the default triplet for vcpkg libraries changed from x86-windows to the detected host triplet (x64-windows). For the old behavior, add --triplet x86-windows . To suppress this message, add --triplet x64-windows .
Computing installation plan...
The following packages will be built and installed:
* fmt:[email protected]
* vcpkg-cmake:x64-windows@2023-05-04
* vcpkg-cmake-config:x64-windows@2022-02-06#1
vcpkg-sample-library:[email protected] -- c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay\vcpkg-sample-library
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
Restored 3 package(s) from C:\Users\rocha\AppData\Local\vcpkg\archives in 60.9 ms. Use --debug to see more details.
Installing 1/4 vcpkg-cmake:x64-windows@2023-05-04...
Elapsed time to handle vcpkg-cmake:x64-windows: 4.9 ms
vcpkg-cmake:x64-windows package ABI: c62da996a7b71d8c0f633c18ce2938d82903a191cc178cbee3722793543520d5
Installing 2/4 vcpkg-cmake-config:x64-windows@2022-02-06#1...
Elapsed time to handle vcpkg-cmake-config:x64-windows: 4.24 ms
vcpkg-cmake-config:x64-windows package ABI: 20b02959c1badd0b0b2b18e80846b45687839ecb3ca822a7d65fb1b8142ed722
Installing 3/4 fmt:[email protected]...
Elapsed time to handle fmt:x64-windows: 13.3 ms
fmt:x64-windows package ABI: c87d6137cd1d670d2a0b4bae5d358af57d6c3f0973f0f38fe4e2780a971d4746
Installing 4/4 vcpkg-sample-library:[email protected]...
Building vcpkg-sample-library:[email protected]...
-- Installing port from location: c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay\vcpkg-sample-library
-- Note: vcpkg-sample-library only supports static library linkage. Building static library.
-- Downloading https://github.com/Microsoft/vcpkg-docs/archive/1.0.0.tar.gz -> Microsoft-vcpkg-docs-1.0.0.tar.gz...
[DEBUG] To include the environment variables in debug output, pass --debug-env
[DEBUG] Trying to load bundleconfig from c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\vcpkg-bundle.json
[DEBUG] Failed to open: c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\vcpkg-bundle.json
[DEBUG] Bundle config: readonly=false, usegitregistry=false, embeddedsha=nullopt, deployment=Git, vsversion=nullopt
[DEBUG] Metrics enabled.
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Feature flag 'dependencygraph' unset
Downloading https://github.com/Microsoft/vcpkg-docs/archive/1.0.0.tar.gz
[DEBUG] Trying to hash C:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\downloads\Microsoft-vcpkg-docs-1.0.0.tar.gz.8732.part
[DEBUG] C:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\downloads\Microsoft-vcpkg-docs-1.0.0.tar.gz.8732.part has hash 3f206cc2fe61d9c97c82b30852e1e4e6df299d93f6159edd1e56c644fa03ccc4670f7681e356d0e3db898a74e099a1ec531821df5430a7b14d61c743c5aa8c30
error: Failed to download from mirror set
error: File does not have the expected hash:
url: https://github.com/Microsoft/vcpkg-docs/archive/1.0.0.tar.gz
File: C:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\downloads\Microsoft-vcpkg-docs-1.0.0.tar.gz.8732.part
Expected hash: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Actual hash: 3f206cc2fe61d9c97c82b30852e1e4e6df299d93f6159edd1e56c644fa03ccc4670f7681e356d0e3db898a74e099a1ec531821df5430a7b14d61c743c5aa8c30
[DEBUG] D:\a\_work\1\s\src\vcpkg\base\downloads.cpp(1029):
[DEBUG] Time in subprocesses: 0us
[DEBUG] Time in parsing JSON: 5us
[DEBUG] Time in JSON reader: 0us
[DEBUG] Time in filesystem: 1027us
[DEBUG] Time in loading ports: 0us
[DEBUG] Exiting after 588 ms (578117us)
CMake Error at scripts/cmake/vcpkg_download_distfile.cmake:32 (message):
Failed to download file with error: 1
If you are using a proxy, please check your proxy setting. Possible causes are:
1. You are actually using an HTTP proxy, but setting HTTPS_PROXY variable
to `https://address:port`. This is not correct, because `https://` prefix
claims the proxy is an HTTPS proxy, while your proxy (v2ray, shadowsocksr
, etc..) is an HTTP proxy. Try setting `http://address:port` to both
HTTP_PROXY and HTTPS_PROXY instead.
2. If you are using Windows, vcpkg will automatically use your Windows IE Proxy Settings
set by your proxy software. See https://github.com/microsoft/vcpkg-tool/pull/77
The value set by your proxy might be wrong, or have same `https://` prefix issue.
3. Your proxy's remote server is out of service.
If you've tried directly download the link, and believe this is not a temporary
download server failure, please submit an issue at https://github.com/Microsoft/vcpkg/issues
to report this upstream download server failure.
Call Stack (most recent call first):
scripts/cmake/vcpkg_download_distfile.cmake:270 (z_vcpkg_download_distfile_show_proxy_and_fail)
scripts/cmake/vcpkg_from_github.cmake:106 (vcpkg_download_distfile)
custom-overlay/vcpkg-sample-library/portfile.cmake:3 (vcpkg_from_github)
scripts/ports.cmake:170 (include)
error: building vcpkg-sample-library:x64-windows failed with: BUILD_FAILED
Elapsed time to handle vcpkg-sample-library:x64-windows: 651 ms
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+vcpkg-sample-library
You can submit a new issue at:
https://github.com/microsoft/vcpkg/issues/new?title=[vcpkg-sample-library]+Build+error+on+x64-windows&body=Copy+issue+body+from+C%3A%2FUsers%2Frocha%2FDesktop%2FVCPKG-TEST%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md
Update the SHA (Hash)
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay>type vcpkg-sample-library\portfile.cmake
type vcpkg-sample-library\portfile.cmake
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Microsoft/vcpkg-docs
REF "${VERSION}"
SHA512 3f206cc2fe61d9c97c82b30852e1e4e6df299d93f6159edd1e56c644fa03ccc4670f7681e356d0e3db898a74e099a1ec531821df5430a7b14d61c743c5aa8c30
HEAD_REF cmake-sample-lib
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME "my_sample_lib")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)
Deviation #2: running the install command again doesn't cause the code to compile. The example output shows that the code compiles, but my execution does not.
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay>vcpkg install vcpkg-sample-library --overlay-ports="%CD%"
vcpkg install vcpkg-sample-library --overlay-ports="%CD%"
warning: In the September 2023 release, the default triplet for vcpkg libraries changed from x86-windows to the detected host triplet (x64-windows). For the old behavior, add --triplet x86-windows . To suppress this message, add --triplet x64-windows .
Computing installation plan...
The following packages will be built and installed:
vcpkg-sample-library:[email protected] -- c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay\vcpkg-sample-library
Detecting compiler hash for triplet x64-windows...
Restored 1 package(s) from C:\Users\rocha\AppData\Local\vcpkg\archives in 22.3 ms. Use --debug to see more details.
Installing 1/1 vcpkg-sample-library:[email protected]...
Elapsed time to handle vcpkg-sample-library:x64-windows: 7.49 ms
vcpkg-sample-library:x64-windows package ABI: 9a45655de051c185fd1e6c3b77b815ae7fb674354c421ef83d72c1d1f04adee3
Total install time: 7.51 ms
vcpkg-sample-library provides CMake targets:
find_package(my_sample_lib CONFIG REQUIRED)
target_link_libraries(main PRIVATE my_sample_lib::my_sample_lib)
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\custom-overlay>cd ..\helloworld
cd ..\helloworld
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>type CMakeLists.txt
type CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(HelloWorld)
find_package(fmt CONFIG REQUIRED)
find_package(my_sample_lib CONFIG REQUIRED) # Add this line
add_executable(HelloWorld helloworld.cpp)
target_link_libraries(HelloWorld PRIVATE fmt::fmt)
target_link_libraries(HelloWorld PRIVATE my_sample_lib::my_sample_lib) # Add this line
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>type helloworld.cpp
type helloworld.cpp
#include "my_sample_lib.h" // Replace #include <fmt/core.h> with "my_sample_lib.h"
int main()
{
greet("World!"); // Replace fmt::print("Hello World!\n) with this line
return 0;
}
Deviation #3: Usage with the Hello World program fails
c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg\helloworld>cmake --preset=default
cmake --preset=default
Preset CMake variables:
CMAKE_TOOLCHAIN_FILE="c:\Users\rocha\Desktop\VCPKG-TEST\vcpkg/scripts/buildsystems/vcpkg.cmake"
-- Running vcpkg install
Detecting compiler hash for triplet x64-windows...
All requested packages are currently installed.
Total install time: 1.1 us
The package fmt provides CMake targets:
find_package(fmt CONFIG REQUIRED)
target_link_libraries(main PRIVATE fmt::fmt)
# Or use the header-only version
find_package(fmt CONFIG REQUIRED)
target_link_libraries(main PRIVATE fmt::fmt-header-only)
-- Running vcpkg install - done
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22631.
CMake Error at C:/Users/rocha/Desktop/VCPKG-TEST/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package):
Could not find a package configuration file provided by "my_sample_lib"
with any of the following names:
my_sample_libConfig.cmake
my_sample_lib-config.cmake
Add the installation prefix of "my_sample_lib" to CMAKE_PREFIX_PATH or set
"my_sample_lib_DIR" to a directory containing one of the above files. If
"my_sample_lib" provides a separate development package or SDK, be sure it
has been installed.
Call Stack (most recent call first):
CMakeLists.txt:6 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/rocha/Desktop/VCPKG-TEST/vcpkg/helloworld/build/CMakeFiles/CMakeOutput.log".