GSL is missing the cmake package version file. Therefore it is not possible in cmake to use package version checking as in find_package(Microsoft.GSL 3.0.1 CONFIG REQUIRED)
Repro (using vcpkg for ease)
- Setup a working vcpkg with VS2019, e.g. using your instructions at https://github.com/microsoft/gsl#building-gsl---using-vcpkg
vcpkg install ms-gsl
- Create your app's
CMakeLists.txt with the needed toolchain file
- Add to that
CMakeLists.txt the following: find_package(Microsoft.GSL 3.0.1 CONFIG REQUIRED)
Result
[cmake] CMake Error at C:/njs/vcpkg/scripts/buildsystems/vcpkg.cmake:329 (_find_package):
[cmake] Could not find a configuration file for package "Microsoft.GSL" that is
[cmake] compatible with requested version "3.0.1".
[cmake]
[cmake] The following configuration files were considered but not accepted:
[cmake]
[cmake] C:/njs/vcpkg/installed/x64-windows-static-md-v142-sdk81/share/Microsoft.GSL/Microsoft.GSLConfig.cmake, version: unknown
[cmake]
[cmake] Call Stack (most recent call first):
[cmake] CMakeLists.txt:164 (find_package)
[cmake] -- Configuring incomplete, errors occurred!```
Expected
No errors and a later successful compile using the GSL library.
Solution
Add package versioning information to the port as described in official cmake docs https://cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#package-version-file
Notes
No reasonable alternative other than to remove package version in find_package(). Otherwise, the alternative is to implement what is already built into cmake.
GSL is missing the cmake package version file. Therefore it is not possible in cmake to use package version checking as in
find_package(Microsoft.GSL 3.0.1 CONFIG REQUIRED)Repro (using vcpkg for ease)
vcpkg install ms-gslCMakeLists.txtwith the needed toolchain fileCMakeLists.txtthe following:find_package(Microsoft.GSL 3.0.1 CONFIG REQUIRED)Result
Expected
No errors and a later successful compile using the GSL library.
Solution
Add package versioning information to the port as described in official cmake docs https://cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#package-version-file
Notes
No reasonable alternative other than to remove package version in
find_package(). Otherwise, the alternative is to implement what is already built into cmake.