使用Xcode 9为iOS构建Ceres的问题

时间:2018-03-21 16:25:02

标签: ios xcode cmake ceres-solver

我正在尝试使用Xcode 9.2(9C40b)和CMake 3.11.0-rc3为iOS 10+构建Ceres 1.13.0。似乎CMake没有认识到Xcode 9提供的铿锵版本。这是怎么回事?看起来不像,因为旧版本的Ceres过去常常很好。

question似乎暗示CMake不支持AppleClang,这对我来说似乎很荒谬。这里有一个不同的团队使用CMake on macOS构建了大量的代码,只有Xcode提供的clang。

我也尝试修改Ceres iOS.cmake文件以按照SO答案的建议设置CMP0025策略,但没有区别。

更新

我注意到了一些事情。当CMake适用于其他构建时,它会将编译器正确识别为AppleClang 9.0.0.9000039。当它失败时,您可以看到下面的消息(它称之为" Clang")。在这两种情况下,它都在/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++标识CXX编译器。下面的输出显示了无法识别编译器的情况

$ cmake $CERES_DIR -DCMAKE_TOOLCHAIN_FILE=$CERES_DIR/cmake/iOS.cmake -DCXX11=ON -DLAPACK=OFF -DEIGEN_INCLUDE_DIR=$EIGEN_INCLUDE_DIR -DIOS_PLATFORM=OS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../
-- Building with Xcode version: 9.2
-- Configuring iOS build for platform: OS, architecture(s): arm64
-- Using C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Using CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-- Using libtool: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
-- Building for minimum iOS version: 11.2 (SDK version: 11.2)
-- Detected Ceres version: 1.13.0 from /Users/me/Projects/Clients/MyCompany/repo/thirdparty/ceres-solver-1.13.0/include/ceres/version.h
-- Building Ceres for iOS platform: OS
-- Building for iOS: Forcing use of miniglog instead of glog.
-- Building for iOS: SuiteSparse, CXSparse, LAPACK, gflags, and OpenMP are not available.
-- Building for iOS: Will not build examples.
-- No preference for use of exported Eigen CMake configuration set, and no hints for include directory provided. Defaulting to preferring an installed/exported Eigen CMake configuration if available.
-- Found installed version of Eigen: /usr/local/share/eigen3/cmake
-- Found Eigen version 3.3.4: /usr/local/include/eigen3

   ===============================================================
   Disabling the use of Eigen as a sparse linear algebra library.
   This does not affect the covariance estimation algorithm 
   which can still use the EIGEN_SPARSE_QR algorithm.
   ===============================================================

-- Building without LAPACK.
-- Building without SuiteSparse.
-- Building without CXSparse.
   ===============================================================
   Compiling without any sparse library: SuiteSparse, CXSparse 
   & Eigen (Sparse) are all disabled or unavailable.  No sparse 
   linear solvers (SPARSE_NORMAL_CHOLESKY & SPARSE_SCHUR)
   will be available when Ceres is used.
   ===============================================================
-- Google Flags disabled; no tests or tools will be built!
-- Compiling minimal glog substitute into Ceres.
-- Using minimal glog substitute (include): internal/ceres/miniglog
-- Max log level for minimal glog substitute: 2
-- Building without OpenMP (disabling multithreading).
-- Looking for C++ include unordered_map
-- Looking for C++ include unordered_map - found
-- Performing Test HAVE_UNORDERED_MAP_IN_STD_NAMESPACE
-- Performing Test HAVE_UNORDERED_MAP_IN_STD_NAMESPACE - Success
-- Found unordered_map/set in std namespace.
-- Looking for C++ include memory
-- Looking for C++ include memory - found
-- Performing Test HAVE_SHARED_PTR_IN_STD_NAMESPACE
-- Performing Test HAVE_SHARED_PTR_IN_STD_NAMESPACE - Success
-- Found shared_ptr in std namespace using <memory> header.
   ==============================================================
   Compiling Ceres using C++11.  This will result in a version 
   of Ceres that will require the use of C++11 in client code.
   ==============================================================
-- Building Ceres as a static library.
-- Enabling CERES_NO_LAPACK in Ceres config.h
-- Enabling CERES_NO_SUITESPARSE in Ceres config.h
-- Enabling CERES_NO_CXSPARSE in Ceres config.h
-- Enabling CERES_USE_CXX11 in Ceres config.h
-- Enabling CERES_NO_THREADS in Ceres config.h
-- Enabling CERES_STD_UNORDERED_MAP in Ceres config.h
CMake Error at cmake/AddCeresCXX11RequirementsToTarget.cmake:70 (target_compile_features):
  target_compile_features no known features for CXX compiler

  "Clang"

  version 9.0.0.9000039.
Call Stack (most recent call first):
  internal/ceres/CMakeLists.txt:223 (add_ceres_cxx11_requirements_to_target)


-- Do not build any example.
-- Configuring incomplete, errors occurred!
See also "/Users/me/Projects/Clients/MyCompany/repo/iOS/lib/ceres/build/CMakeFiles/CMakeOutput.log".

Xcode版本:

$ /usr/bin/clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

非常感谢指导。

1 个答案:

答案 0 :(得分:1)

啊,似乎我需要删除中间CMake文件。它感到困惑。这样做会使问题消失(还必须在iOS 11之前指定最低部署目标,或者找到一种方法告诉Ceres除了arm64之外不要构建任何东西)。