今天编译meshlab,cmake-gui报错:
Could not find a package configuration file provided by "Eigen3" with any
of the following names:
Eigen3Config.cmake
eigen3-config.cmake
于是找了一下Eigen3Config.cmake到底是个什么东西,先说结果,最后其内容如下,
# This file exports the Eigen3::Eigen CMake target which should be passed to the
# target_link_libraries command.
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was Eigen3Config.cmake.in ########
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
endif()
endmacro()
####################################################################################
if (NOT TARGET eigen)
include ("${CMAKE_CURRENT_LIST_DIR}/Eigen3Targets.cmake")
endif ()
# Legacy variables, do *not* use. May be removed in the future.
set (EIGEN3_FOUND 1)
set (EIGEN3_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/UseEigen3.cmake")
set (EIGEN3_DEFINITIONS "")
set (EIGEN3_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include/eigen3")
set (EIGEN3_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/eigen3")
set (EIGEN3_ROOT_DIR "${PACKAGE_PREFIX_DIR}")
set (EIGEN3_VERSION_STRING "3.4.0")
set (EIGEN3_VERSION_MAJOR "3")
set (EIGEN3_VERSION_MINOR "4")
set (EIGEN3_VERSION_PATCH "0")
按照道理来说,eigen只是一个头文件库,不需要编译;于是搜索到这个地址,
c++ - Not found Eigen3_DIR when configuring a cmake project in Windows - Stack Overflow
大致意思是说,编译(不如说拷贝)还是必须的,步骤如下,
(1)Create a directory called "build" within your Eigen directory.
(2)Go to the build directory and do "cmake ..". This will create Visual Studio projects.
(3)Load the .sln using Visual Studio.
(4)Build the solution.
(5)Ensure that the project called INSTALL was built also.
看了一下,我下载下来的eigen3.4.0中确实有个CMakeLists.txt,于是用cmake-gui配置了一下,不过我不喜欢那个有空格的原始目录,在配置中把CMAKE_INSTALL_PREFIX改了,
CMAKE_INSTALL_PREFIX = C:/Eigen3 INCLUDE_INSTALL_DIR = include/eigen3
CMake-GUI通过configure + generate后,生成一个Eigen3.sln,打开,选择release模式,找到那个叫INSTALL的项目,直接右击选择“生成”,然后所需要的文件就拷贝到C:/Eigen3文件夹下了,那个cmake文件在这里,
C:\Eigen3\share\eigen3\cmake\Eigen3Config.cmake
然后,把meshLab的Eigen3_DIR地址设置成下面这个就OK了,
C:\Eigen3\share\eigen3\cmake\
现在我把C:\Eigen3打个包做了备份,以后重装系统就省掉上面这些步骤了。
本文结束