I'm trying to build a program that has dependency on Eigen3 and SDL2.
I'm getting error while using cmake generator command.
Visual Studio 17 2022 is the default generator on my PC. I've checked this with cmake --help
command.
C:\vcpkg\scripts\buildsystems\vcpkg.cmake
is the location of my vcpkg cmake intergeration file is located.
I've installed bith Eigen3 and SDL2 dependency via vcpkg.
Build Command
cmake .. -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake"
cmake ..
I even tried
cmake .. "-DCMAKE_PREFIX_PATH=C:\vcpkg\installed\x64-windows\include\eigen3"
Error
CMake Error at CMakeLists.txt:6 (find_package):
Could not find a package configuration file provided by "Eigen3" (requested
version 3.3) 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.
-- Configuring incomplete, errors occurred!
CMake File
cmake_minimum_required(VERSION 3.5) project(AKFSFSimulation)
set(CMAKE_CXX_STANDARD 11)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
set(SRC_CPP
src/main.cpp
src/display.cpp
src/beacons.cpp
src/sensors.cpp
src/simulation.cpp
src/utils.cpp
src/kalmanfilter.cpp )
add_executable(${PROJECT_NAME}
${SRC_CPP}
)
target_link_libraries(${PROJECT_NAME}
SDL2
SDL2_ttf
Eigen3::Eigen
)
add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/data/ $<TARGET_FILE_DIR:${PROJECT_NAME}>)
Eigen Installation
λ .\vcpkg.exe install eigen3 Computing installation plan... The following packages are already installed:
eigen3:x64-windows -> 3.4.0#2 eigen3:x64-windows is already installed Total install time: 491 us eigen3 provides CMake targets:
# this is heuristically generated, and may not be correct
find_package(Eigen3 CONFIG REQUIRED)
target_link_libraries(main PRIVATE Eigen3::Eigen)
Eigen3 Installation Output
λ .\vcpkg.exe install eigen3
Computing installation plan...
The following packages are already installed:
eigen3:x64-windows -> 3.4.0#2
eigen3:x64-windows is already installed
Total install time: 344 us
eigen3 provides CMake targets:
# this is heuristically generated, and may not be correct
find_package(Eigen3 CONFIG REQUIRED)
target_link_libraries(main PRIVATE Eigen3::Eigen)
Eigen3Config.cmake
is located in the folder C:\vcpkg\installed\x64-windows\share\eigen3
.
Setting Eigen3_DIR
to <vcpkg-root>/installed/x64-windows/share/eigen3
solved the issue.
e.g. Set Eigen3_DIR
to c:/vcpkg/installed/x64-windows/share/eigen3
in my case.