Skip to content

Get ports working for android that use vcpkg_configure_make / vcpkg_install_make #15255

@Markus87

Description

@Markus87

Is your feature request related to a problem? Please describe.
I cant use vcpkg for android because a few ports(cairo/gettext/libiconv/...) that I need dont work for android.

Proposed solution
Lets try to get android working for ports of this type if it is possible.

Describe alternatives you've considered
For libiconv I made a cmake build instead that gets used for android, but configuring the headers is a real pain, not maintainable and very ugly.

Additional context
I tried a few things to get it to work (port was gettext):

Problem 1 - Backslash instead of slashes

Error

CMake Error at buildtrees/gettext/cmake-vars-arm64-android-rel.cmake.log:27 (set):
  Syntax error in cmake code at
    H:/DevTools/android-3rdParty/vcpkgFork/buildtrees/gettext/cmake-vars-arm64-android-rel.cmake.log:27
  when parsing string
    H:\DevTools\android-3rdParty\vcpkgFork\downloads\tools\powershell-core-7.0.3-windows;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0\;H:/DevTools/android-3rdParty/vcpkgFork/downloads/tools/winflexbison/0a14154bff-a8cf65db07;H:/DevTools/android-3rdParty/vcpkgFork/downloads/tools/ninja/1.10.1-windows;H:/DevTools/android-3rdParty/vcpkgFork/downloads/tools/ninja/1.10.1-windows

Proposed fix

diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt
index 45a53989b..395231fbd 100644
--- a/scripts/get_cmake_vars/CMakeLists.txt
+++ b/scripts/get_cmake_vars/CMakeLists.txt
@@ -73,7 +73,7 @@ foreach(VAR IN LISTS VCPKG_VARS_TO_CHECK)
 endforeach()

 foreach(_env IN LISTS VCPKG_ENV_VARS_TO_CHECK)
-    IF(WIN32)
+    IF(CMAKE_HOST_WIN32)
         string(REPLACE "\\" "/" ENV_${_env} "$ENV{${_env}}")
         string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"${ENV_${_env}}\")\n")
     else()

Problem 2 - clang.exe is not in path

Error - config.log

...
configure:4615: compile clang.exe --version >&5
/usr/share/automake-1.16/compile: line 307: exec: clang.exe: not found
...

Workaround - dont strip the path away from the tools(likely better to add compiler root to path,
ANDROID_TOOLCHAIN_ROOT is not set so not sure how to do that here)

diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake
index e7af4713c..b2be181b0 100644
--- a/scripts/cmake/vcpkg_configure_make.cmake
+++ b/scripts/cmake/vcpkg_configure_make.cmake
@@ -315,7 +315,11 @@ function(vcpkg_configure_make)
                   VCPKG_DETECTED_CMAKE_STRIP VCPKG_DETECTED_CMAKE_NM VCPKG_DETECTED_CMAKE_DLLTOOL VCPKG_DETECTED_CMAKE_RC_COMPILER)
         foreach(prog IN LISTS progs)
             if(${prog})
-                get_filename_component(${prog} "${${prog}}" NAME)
+				if(VCPKG_TARGET_IS_ANDROID)
+					message("${prog}=${${prog}}")
+				else()
+					get_filename_component(${prog} "${${prog}}" NAME)					
+				endif()
             endif()
         endforeach()
         if (_csc_AUTOCONFIG OR _csc_USE_WRAPPERS) # without autotools we assume a custom configure script which correctly handles cl and lib. Otherwise the port needs to set CC|CXX|AR and probably CPP

Problem 3 - unsupported option '-fPIC' for target 'x86_64-w64-windows-gnu'

Error - config.log

...
configure:4646: checking whether the C compiler works
configure:4668: compile H:/DevTools/android-ndk/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -g -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wformat -Werror=format-security -fPIC -O0 -fno-limit-debug-info -DANDROID -D_FORTIFY_SOURCE=2 -LH:/DevTools/android-3rdParty/vcpkgFork/installed/arm64-android/debug/lib -LH:/DevTools/android-3rdParty/vcpkgFork/installed/arm64-android/debug/lib/manual-link  conftest.c -latomic -lm >&5
clang: error: unsupported option '-fPIC' for target 'x86_64-w64-windows-gnu'
...

No solution - just removed fPIC for testing if it could work without - IN_TRY_COMPILE looks like it is supposed to work around the problem, no idea where to apply it

diff --git a/scripts/toolchains/android.cmake b/scripts/toolchains/android.cmake
index c721c2c42..9bcf60da0 100644
--- a/scripts/toolchains/android.cmake
+++ b/scripts/toolchains/android.cmake
@@ -42,7 +42,7 @@ if(NOT _VCPKG_ANDROID_TOOLCHAIN)
 set(_VCPKG_ANDROID_TOOLCHAIN 1)
 get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
 if(NOT _CMAKE_IN_TRY_COMPILE)
-    string(APPEND CMAKE_C_FLAGS " -fPIC ${VCPKG_C_FLAGS} ")
+    string(APPEND CMAKE_C_FLAGS " ${VCPKG_C_FLAGS} ") # " -fPIC ${VCPKG_C_FLAGS} "
     string(APPEND CMAKE_CXX_FLAGS " -fPIC ${VCPKG_CXX_FLAGS} ")
     string(APPEND CMAKE_C_FLAGS_DEBUG " ${VCPKG_C_FLAGS_DEBUG} ")
     string(APPEND CMAKE_CXX_FLAGS_DEBUG " ${VCPKG_CXX_FLAGS_DEBUG} ")

Problem 4 - Missing libraries

Error - config.log

configure:4646: checking whether the C compiler works
configure:4668: compile H:/DevTools/android-ndk/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -g -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wformat -Werror=format-security -O0 -fno-limit-debug-info -DANDROID -D_FORTIFY_SOURCE=2 -LH:/DevTools/android-3rdParty/vcpkgFork/installed/arm64-android/debug/lib -LH:/DevTools/android-3rdParty/vcpkgFork/installed/arm64-android/debug/lib/manual-link  conftest.c -latomic -lm >&5
/usr/bin/ld: cannot find crt2.o: No such file or directory
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -latomic
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lssp_nonshared
/usr/bin/ld: cannot find -lssp
/usr/bin/ld: cannot find -lmingw32
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_eh
/usr/bin/ld: cannot find -lmoldname
/usr/bin/ld: cannot find -lmingwex
/usr/bin/ld: cannot find -lmsvcrt
/usr/bin/ld: cannot find -ladvapi32
/usr/bin/ld: cannot find -lshell32
/usr/bin/ld: cannot find -luser32
/usr/bin/ld: cannot find -lkernel32
/usr/bin/ld: cannot find -lmingw32
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_eh
/usr/bin/ld: cannot find -lmoldname
/usr/bin/ld: cannot find -lmingwex
/usr/bin/ld: cannot find -lmsvcrt
/usr/bin/ld: cannot find crtend.o: No such file or directory

Fix/Workaround
At this point I am completely lost, it looks like it is trying to link windows libraries?


Metadata

Metadata

Assignees

Labels

category:community-tripletA PR or issue related to community triplets not officially validated by the vcpkg team.category:tool-updateThe issue is with build tool or build script, which requires update or should be executed correctly

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions