From 6e2690df61c76f956b98c45705f0670847aaff70 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 12 Mar 2019 09:31:13 -0700 Subject: [PATCH] Fix Android builds on Windows This PR fixes #927 --- CMakeLists.txt | 2 +- build/toolchain-aarch64-linux-android.cmake | 15 +++++++++++---- build/toolchain-arm7-linux-android.cmake | 15 +++++++++++---- build/toolchain-x86-linux-android.cmake | 15 +++++++++++---- build/toolchain-x86_64-linux-android.cmake | 15 +++++++++++---- 5 files changed, 45 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26a838934055..4098ea1ec01d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -318,7 +318,7 @@ function(get_resgen_vars ARCHIVE_DIR ARCHIVE_NAME) set(RESGEN_HEADER "${ARCHIVE_DIR}/${ARCHIVE_NAME}.h" PARENT_SCOPE) # Visual Studio makes it difficult to use assembly without using MASM. MASM doesn't support # the equivalent of .incbin, so on Windows we'll just tell resgen to output a C file. - if (WEBGL OR WIN32) + if (WEBGL OR WIN32 OR ANDROID_ON_WINDOWS) set(RESGEN_OUTPUTS "${OUTPUTS};${ARCHIVE_DIR}/${ARCHIVE_NAME}.c" PARENT_SCOPE) set(RESGEN_FLAGS -cx ${ARCHIVE_DIR} -p ${ARCHIVE_NAME} PARENT_SCOPE) set(RESGEN_SOURCE "${ARCHIVE_DIR}/${ARCHIVE_NAME}.c" PARENT_SCOPE) diff --git a/build/toolchain-aarch64-linux-android.cmake b/build/toolchain-aarch64-linux-android.cmake index 6b2c0eda56a2..515c8a80a3b7 100644 --- a/build/toolchain-aarch64-linux-android.cmake +++ b/build/toolchain-aarch64-linux-android.cmake @@ -33,15 +33,16 @@ set(TOOLCHAIN $ENV{ANDROID_HOME}/ndk-bundle/toolchains/llvm/prebuilt/${HOST_NAME # specify the cross compiler set(COMPILER_SUFFIX) +set(TOOL_SUFFIX) if(WIN32) set(COMPILER_SUFFIX ".cmd") - set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar.exe CACHE FILEPATH "Archiver") + set(TOOL_SUFFIX ".exe") endif() set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${ARCH}${API_LEVEL}-clang${COMPILER_SUFFIX}) set(CMAKE_CXX_COMPILER ${TOOLCHAIN}/bin/${ARCH}${API_LEVEL}-clang++${COMPILER_SUFFIX}) -set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar${COMPILER_SUFFIX}) -set(CMAKE_RANLIB ${TOOLCHAIN}/bin/${ARCH}-ranlib${COMPILER_SUFFIX}) -set(CMAKE_STRIP ${TOOLCHAIN}/bin/${ARCH}-strip${COMPILER_SUFFIX}) +set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar${TOOL_SUFFIX} CACHE FILEPATH "Archiver") +set(CMAKE_RANLIB ${TOOLCHAIN}/bin/${ARCH}-ranlib${TOOL_SUFFIX}) +set(CMAKE_STRIP ${TOOLCHAIN}/bin/${ARCH}-strip${TOOL_SUFFIX}) # where is the target environment set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/sysroot) @@ -64,3 +65,9 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie -static-libstdc set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++" CACHE STRING "Toolchain LDFLAGS") set(ANDROID TRUE) + +# we are compiling Android on Windows +set(ANDROID_ON_WINDOWS FALSE) +if(WIN32) + set(ANDROID_ON_WINDOWS TRUE) +endif() \ No newline at end of file diff --git a/build/toolchain-arm7-linux-android.cmake b/build/toolchain-arm7-linux-android.cmake index 7083cb55f0dd..a75d4337f855 100644 --- a/build/toolchain-arm7-linux-android.cmake +++ b/build/toolchain-arm7-linux-android.cmake @@ -34,15 +34,16 @@ set(TOOLCHAIN $ENV{ANDROID_HOME}/ndk-bundle/toolchains/llvm/prebuilt/${HOST_NAME # specify the cross compiler set(COMPILER_SUFFIX) +set(TOOL_SUFFIX) if(WIN32) set(COMPILER_SUFFIX ".cmd") - set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar.exe CACHE FILEPATH "Archiver") + set(TOOL_SUFFIX ".exe") endif() set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${ARCH}${API_LEVEL}-clang${COMPILER_SUFFIX}) set(CMAKE_CXX_COMPILER ${TOOLCHAIN}/bin/${ARCH}${API_LEVEL}-clang++${COMPILER_SUFFIX}) -set(CMAKE_AR ${TOOLCHAIN}/bin/${AR_ARCH}-ar${COMPILER_SUFFIX}) -set(CMAKE_RANLIB ${TOOLCHAIN}/bin/${AR_ARCH}-ranlib${COMPILER_SUFFIX}) -set(CMAKE_STRIP ${TOOLCHAIN}/bin/${AR_ARCH}-strip${COMPILER_SUFFIX}) +set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar${TOOL_SUFFIX} CACHE FILEPATH "Archiver") +set(CMAKE_RANLIB ${TOOLCHAIN}/bin/${ARCH}-ranlib${TOOL_SUFFIX}) +set(CMAKE_STRIP ${TOOLCHAIN}/bin/${ARCH}-strip${TOOL_SUFFIX}) # where is the target environment set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/sysroot) @@ -77,3 +78,9 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -march=armv7-a -Wl,- set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(ANDROID TRUE) + +# we are compiling Android on Windows +set(ANDROID_ON_WINDOWS FALSE) +if(WIN32) + set(ANDROID_ON_WINDOWS TRUE) +endif() diff --git a/build/toolchain-x86-linux-android.cmake b/build/toolchain-x86-linux-android.cmake index 99c914b07b00..16d2827dfe11 100644 --- a/build/toolchain-x86-linux-android.cmake +++ b/build/toolchain-x86-linux-android.cmake @@ -33,15 +33,16 @@ set(TOOLCHAIN $ENV{ANDROID_HOME}/ndk-bundle/toolchains/llvm/prebuilt/${HOST_NAME # specify the cross compiler set(COMPILER_SUFFIX) +set(TOOL_SUFFIX) if(WIN32) set(COMPILER_SUFFIX ".cmd") - set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar.exe CACHE FILEPATH "Archiver") + set(TOOL_SUFFIX ".exe") endif() set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${ARCH}${API_LEVEL}-clang${COMPILER_SUFFIX}) set(CMAKE_CXX_COMPILER ${TOOLCHAIN}/bin/${ARCH}${API_LEVEL}-clang++${COMPILER_SUFFIX}) -set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar${COMPILER_SUFFIX}) -set(CMAKE_RANLIB ${TOOLCHAIN}/bin/${ARCH}-ranlib${COMPILER_SUFFIX}) -set(CMAKE_STRIP ${TOOLCHAIN}/bin/${ARCH}-strip${COMPILER_SUFFIX}) +set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar${TOOL_SUFFIX} CACHE FILEPATH "Archiver") +set(CMAKE_RANLIB ${TOOLCHAIN}/bin/${ARCH}-ranlib${TOOL_SUFFIX}) +set(CMAKE_STRIP ${TOOLCHAIN}/bin/${ARCH}-strip${TOOL_SUFFIX}) # where is the target environment set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/sysroot) @@ -61,3 +62,9 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-warn-mismat set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(ANDROID TRUE) + +# we are compiling Android on Windows +set(ANDROID_ON_WINDOWS FALSE) +if(WIN32) + set(ANDROID_ON_WINDOWS TRUE) +endif() diff --git a/build/toolchain-x86_64-linux-android.cmake b/build/toolchain-x86_64-linux-android.cmake index 5e2bc103744e..78865f853d66 100644 --- a/build/toolchain-x86_64-linux-android.cmake +++ b/build/toolchain-x86_64-linux-android.cmake @@ -33,15 +33,16 @@ set(TOOLCHAIN $ENV{ANDROID_HOME}/ndk-bundle/toolchains/llvm/prebuilt/${HOST_NAME # specify the cross compiler set(COMPILER_SUFFIX) +set(TOOL_SUFFIX) if(WIN32) set(COMPILER_SUFFIX ".cmd") - set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar.exe CACHE FILEPATH "Archiver") + set(TOOL_SUFFIX ".exe") endif() set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${ARCH}${API_LEVEL}-clang${COMPILER_SUFFIX}) set(CMAKE_CXX_COMPILER ${TOOLCHAIN}/bin/${ARCH}${API_LEVEL}-clang++${COMPILER_SUFFIX}) -set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar${COMPILER_SUFFIX}) -set(CMAKE_RANLIB ${TOOLCHAIN}/bin/${ARCH}-ranlib${COMPILER_SUFFIX}) -set(CMAKE_STRIP ${TOOLCHAIN}/bin/${ARCH}-strip${COMPILER_SUFFIX}) +set(CMAKE_AR ${TOOLCHAIN}/bin/${ARCH}-ar${TOOL_SUFFIX} CACHE FILEPATH "Archiver") +set(CMAKE_RANLIB ${TOOLCHAIN}/bin/${ARCH}-ranlib${TOOL_SUFFIX}) +set(CMAKE_STRIP ${TOOLCHAIN}/bin/${ARCH}-strip${TOOL_SUFFIX}) # where is the target environment set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/sysroot) @@ -61,3 +62,9 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-warn-mismat set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(ANDROID TRUE) + +# we are compiling Android on Windows +set(ANDROID_ON_WINDOWS FALSE) +if(WIN32) + set(ANDROID_ON_WINDOWS TRUE) +endif()