microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.18k stars 6.16k forks source link

CMake GUI can't find Eigen in vcpkg tree #2423

Open arbenede opened 6 years ago

arbenede commented 6 years ago

I am trying to build DSO (https://github.com/JakobEngel/dso) using CMake GUI and Visual Studio 2017. I built all DSO's dependencies using vcpkg. I followed the instructions saying to create the new CMake variable CMAKE_TOOLCHAIN_FILE = C:/vcpkg/scripts/buildsystems/vcpkg.cmake however for some reason CMake has trouble finding Eigen:

CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find Eigen3 (missing: EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) (Required is at least version "2.91.0") Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) cmake/FindEigen3.cmake:76 (find_package_handle_standard_args) C:/vcpkg/scripts/buildsystems/vcpkg.cmake:222 (_find_package) CMakeLists.txt:17 (find_package)

Any ideas? Thanks!

jasjuang commented 6 years ago

DSO has their own FindEigen3.cmake in the cmake folder that causes find_package to be called in module mode. If you delete their FindEigen3.cmake and use the Eigen3Config.cmake that comes with vcpkg it should work.

arbenede commented 6 years ago

I renamed FindEigen3.cmake in the cmake folder but I am still getting an error (see below). I thought that by setting CMAKE_TOOLCHAIN_FILE = C:/vcpkg/scripts/buildsystems/vcpkg.cmake the CMake GUI would automagically find everything but this does not seem to be the case...

CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:222 (_find_package): By not providing "FindEigen3.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Eigen3", but CMake did not find one.

Could not find a package configuration file provided by "Eigen3" with any of the following names:

Eigen3Config.cmake
eigen3-config.cmake

Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set "Eigen3_DIR" to a directory containing one of the above files. If "Eigen3" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): CMakeLists.txt:17 (find_package)

jasjuang commented 6 years ago

This looks like the toolchain file is not correctly loaded. Did you ever try building a minimal code that links to a small library (say tinyxml2) and verify that you can load the toolchain file correctly?

arbenede commented 6 years ago

No I have not tried that, also since I am no CMake expert... If you can point me to any sample code I will try to modify it to do what you suggested. Thanks!

ras0219-msft commented 6 years ago

Unfortunately, the toolchain file needs to be set during the first run! This is why the cmake-gui tool has a separate box for the "cross-compiler file"; see [1]. Basically, make sure you pick Cross-Compiling!

[1] https://stackoverflow.com/questions/29982505/setting-a-cross-compiler-file-using-the-cmake-gui