从 CMake 3.8 升级到 3.14 时,我在项目中遇到问题。我已将其简化为以下问题。请注意,这project
是之前find_package
(相反我没有我所描述的问题)。
cmake_minimum_required(VERSION 3.2.1)
find_package(MPI REQUIRED)
project(Test CXX)).
当我使用 CMake 3.8 构建时,输出如下:
build3_8$ cmake ../source/
-- The CXX compiler identification is Intel 17.0.5.20170817
-- Check for working CXX compiler: (...)/linux/bin/intel64/icpc
-- Check for working CXX compiler: (...)/linux/bin/intel64/icpc -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: (...)/build3_8
使用 CMake 3.14,我得到以下输出:
build3_14$ cmake ../source/
CMake Error at (...)/CMake/3.14.0/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:211 (message):
No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()
Call Stack (most recent call first):
(...)/CMake/3.14.0/share/cmake-3.14/Modules/FindMPI.cmake:1672 (find_package_handle_standard_args)
CMakeLists.txt:3 (find_package)
-- Configuring incomplete, errors occurred!
我想知道为什么较新的 CMake 版本会发生这种情况(尽管 FindMPI.cmake 完全不同)?
另外,我能做些什么来解决这个问题?我需要编写自己的配置吗?
(我不能只改变 and 的顺序project
,find_package
因为包装器是为编译器创建的(不是我的选择,请不要怪我))