image.png CMake options填写 -D变量名=变量值 image.png message(${BUILD_TYPE}) if(BUILD_TYPE STREQUAL arm) cmake_minimum_required(VERSION 3.4.1) message("is arm set version 3.12") set(CMAKE_C_FLAGS "-std=gnu99") set(CMAK
image.png
CMake options填写 -D变量名=变量值
image.png
message(${BUILD_TYPE})
if(BUILD_TYPE STREQUAL arm)
cmake_minimum_required(VERSION 3.4.1)
message("is arm set version 3.12")
set(CMAKE_C_FLAGS "-std=gnu99")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
message(${CMAKE_C_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
# 配置使用 NDK Standalone Toolchain 编译
set(NDK_STANDALONE_TOOLCHAIN E:/cross-c/ndk_toolchain)
set(CMAKE_SYSTEM_NAME AndroidARM)
set(CMAKE_SYSTEM_VERSION 3)
set(CMAKE_C_COMPILER ${NDK_STANDALONE_TOOLCHAIN}/bin/arm-linux-androideabi-gcc)
set(CMAKE_CXX_COMPILER ${NDK_STANDALONE_TOOLCHAIN}/bin/arm-linux-androideabi-g++)
set(CMAKE_FIND_ROOT_PATH ${NDK_STANDALONE_TOOLCHAIN})
# 使用 NDK 提供的头文件
#add_definitions("--sysroot=E:/android_source/android-4.1.1_r1/android-4.1.1_r1/prebuilts/ndk/android-ndk-r7/platforms/android-9/arch-arm")
add_definitions("--sysroot=${NDK_STANDALONE_TOOLCHAIN}/sysroot")
else()
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
set(CMAKE_CXX_STANDARD 11)
message("window set var")
endif()
project(MyApplication)
###WINDOW
message("start")
message("end")
option(Build_DEBUG "debug or release?" ON)
#set(CMAKE_C_COMPILER ${NDK_STANDALONE_TOOLCHAIN}/bin/arm-linux-androideabi-gcc)
aux_source_directory(src SOURCE_FILES)
add_executable(hello src/hello.c)
#add_executable(hello main.cpp test1.cpp test1.h)