0

我为 Linaro 工具链编写 toolchain.cmake 文件。

include(CMakeForceCompiler)
set(CMAKE_CROSSCOMPILING   TRUE)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "armv7-a")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wno-psabi -frtti -fexceptions" )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wno-psabi -fexceptions" )
set(CMAKE_C_COMPILER /home/stranger/linaro/android-toolchain-eabi/bin/arm-linux-androideabi-gcc)
set(CMAKE_CXX_COMPILER /home/stranger/linaro/android-toolchain-eabi/bin/arm-linux-androideabi-g++)
CMAKE_FORCE_C_COMPILER("${CMAKE_C_COMPILER}" GNU)
CMAKE_FORCE_CXX_COMPILER("${CMAKE_CXX_COMPILER}" GNU)
set(CMAKE_FIND_ROOT_PATH  home/stranger/linaro/android-toolchain-eabi/arm-linux-androideabi)
include_directories( SYSTEM /home/stranger/android-ndk-r8/platforms/android-14/arch-arm/usr/include)
include_directories( SYSTEM /home/stranger/android-ndk-r8/sources/cxx-stl/gnu-libstdc++/include)
include_directories( SYSTEM /home/stranger/android-ndk-r8/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include)

我运行 cmake:

cmake -DBUILD_ANDROID=On -DCMAKE_TOOLCHAIN_FILE=<path to this toolchain.cmake>  -DCMAKE_BUILD_TYPE=Release <path to my cmake project>

但是在编译时,我有关于异常的错误,而不是在工具链文件中定义的编译器标志:

error: exception handling disabled, use -fexceptions to enable

据我了解我的 CMAKE_C_FLAGS_RELEASE,CMAKE_CXX_FLAGS_RELEASE 没有效果。为什么?

4

1 回答 1

2

问题解决了,我的错。我在主要项目中使用set(CMAKE_CXX_FLAGS "<flags>")反对。set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}<flags>"我很困惑,因为这个 CMakeLists.txt 适用于 android-cmake 和 Google-NDK(而不是所有 android-cmake 工具链标志都被拒绝)。

于 2012-06-17T07:52:27.260 回答