Suppose I have installed some library with vcpkg
and it's numerous dependencied (say cgal
). Now I want to compile some program against these libraries with CMake
.
How should I tell CMake
about all locations of all libraries I have downloaded? Including main library I have installed? I have only one setting in CMake
, called "source directory" which will point to my code. Where are settings for libraries?
D:\Users\ThirdPartyDesign\CGAL-5.0-examples\CGAL-5.0\examples\Triangulation_2
λ env | grep CMAKE
CMAKE_TOOLCHAIN_FILE=D:\Users\ThirdPartyDesign\vcpkg\scripts\buildsystems\vcpkg.cmake
D:\Users\ThirdPartyDesign\CGAL-5.0-examples\CGAL-5.0\examples\Triangulation_2
λ cmake .
CMake Warning at CMakeLists.txt:18 (find_package):
By not providing "FindCGAL.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "CGAL", but
CMake did not find one.
Could not find a package configuration file provided by "CGAL" with any of
the following names:
CGALConfig.cmake
cgal-config.cmake
Add the installation prefix of "CGAL" to CMAKE_PREFIX_PATH or set
"CGAL_DIR" to a directory containing one of the above files. If "CGAL"
provides a separate development package or SDK, be sure it has been
installed.
-- This program requires the CGAL library, and will not be compiled.
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Users/ThirdPartyDesign/CGAL-5.0-examples/CGAL-5.0/examples/Triangulation_2
The best way to use installed libraries with cmake is via the toolchain file scripts\buildsystems\vcpkg. cmake . To use this file, you simply need to add it onto your CMake command line as: -DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.
Normally you need to set; CMAKE_TOOLCHAIN_FILE
and VCPKG_TARGET_TRIPLET
.
Set VCPKG_TARGET_TRIPLET
to the vcpkg triplet that you are using. The default is x86-windows
Set CMAKE_TOOLCHAIN_FILE
to point to path_to_vcpkg\scripts\buildsystems\vcpkg.cmake
Then you can use cmake functions such as find_package
to find the required package.
see https://github.com/microsoft/vcpkg/blob/master/docs/examples/installing-and-using-packages.md#cmake-toolchain-file for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With