1. 过程记录:
遇到报错:
CMAKE_SYSTEM_NAME is 'Android' but 'NVIDIA Nsight Tegra Visual Studio Edition' is not installed.
可加上解决:
-G "Unix Makefiles"
2. 交叉编译:windows下编译android
2.1 生成Makefile文件
cmake -G "Unix Makefiles"
-DCMAKE_TOOLCHAIN_FILE=android-cmake/android.toolchain.cmake
-DANDROID_NDK=E:/develop/android-ndk-r10e -DCMAKE_BUILD_TYPE=Release
-DANDROID_ABI="armeabi-v7a with NEON"
-DCMAKE_MAKE_PROGRAM="XX:/android-ndk-r10e/prebuilt/windows/bin/make.exe" ./
2.2 调用\cygwin\bin里面的make进行交叉编译(注意把cygwin\bin加入环境变量中):
make
3. mac下用cmake编译ios
下载一下ios-cmake的配置文件:
生成xcode工程命令行:
/Applications/CMake.app/Contents/bin/cmake
-DCMAKE_TOOLCHAIN_FILE=../ios-cmake/iOS.cmake
-DCMAKE_IOS_DEVELOPER_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/
-DCMAKE_IOS_SDK_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -GXcode
"CMakeLists.txt所在目录"
CMakeLists.txt中设置xcode工程的配置
if (APPLE)
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode")
set_xcode_property (CommonPlugin IPHONEOS_DEPLOYMENT_TARGET "8.3")
set_xcode_property (CommonPlugin CLANG_CXX_LANGUAGE_STANDARD "gnu++0x")
set_xcode_property (CommonPlugin CLANG_CXX_LIBRARY "libc++")
endif()
4.CMake中去除ZERO_CHECK
set(CMAKE_SUPPRESS_REGENERATION true)
5.CMake中,ALL_BUILD无法去除
6.CMake中为MacOS生成bundle文件
SET(MACOS_BUNDLE_BUNDLE_NAME NssCommonPlugin) # 设置bundle名字
SET_TARGET_PROPERTIES(NssCommonPlugin PROPERTIES BUNDLE TRUE) # 生成bundle
7.Unknown CMake command "set_xcode_property". 解决方法:
macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY}
${XCODE_VALUE})
endmacro (set_xcode_property)
4. CMake使用笔记:
cmake没有相关的clean指令,通常做法是cd进一个目录,然后用cmake生成工程到该目录,删除时,整个目录一并删除。
cmake使用默认编译器编译的方法:
命令行:cmake --build "cmake生成的工程目录" --config Release
windows下默认使用visutal studio,mac下使用xcode