Vcpkg: proj4 fails to build on custom triplet

Created on 27 Oct 2019  路  7Comments  路  Source: microsoft/vcpkg

Describe the bug
There are hardcoded triplets in the portfile of proj4 from line 30 to 42, which causes the build to fail. Is there a vcpkg cmake variable that represents the current triplet?

Environment

  • OS: Windows 10
  • Compiler: Visual Studio 2017

To Reproduce
Steps to reproduce the behavior:

  1. Go to vcpkg/triplets and copy x64-windows.cmake and rename it into x64-windows-custom.cmake
  2. ./vcpkg install proj4:x64-windows-custom
  3. See error
The following packages will be built and installed:
    proj4[core,database]:x64-windows-custom
Starting package 1/1: proj4:x64-windows-custom
Building package proj4[core,database]:x64-windows-custom...
-- Using cached C:/dev/vcpkg/downloads/OSGeo-PROJ-6.2.0.tar.gz
-- Using source at C:/dev/vcpkg/buildtrees/proj4/src/6.2.0-36fd21991d
CMake Error at ports/proj4/portfile.cmake:37 (message):
  Proj4 database need to install sqlite3[tool]:x64-windows first.
Call Stack (most recent call first):
  scripts/ports.cmake:94 (include)


Error: Building package proj4:x64-windows-customfailed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: proj4:x64-windows-custom
  Vcpkg version: 2019.09.12-nohash

Additionally, attach any relevant sections from the log files above.

Expected behavior
Proj4 should install successfully in the case of custom triplet.

port-bug

All 7 comments

Proj4[database] needs to run sqlite3-bin.exe, and this sqlite3 tool must be non-arm/uwp.
In _VCPKG/ports/proj4/portfile.cmake_ L27-47:

if ("database" IN_LIST FEATURES)
    if (VCPKG_TARGET_IS_WINDOWS)
        set(BIN_SUFFIX .exe)
        if (VCPKG_TARGET_ARCHITECTURE STREQUAL arm)
            if (NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/sqlite3-bin.exe)
                message(FATAL_ERROR "Proj4 database need to install sqlite3[tool]:x86-windows first.")
            endif()
            set(SQLITE3_BIN_PATH ${CURRENT_INSTALLED_DIR}/../x86-windows/tools)
        elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL arm64 OR (VCPKG_TARGET_ARCHITECTURE STREQUAL x64 AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic))
            if (NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x64-windows/tools/sqlite3-bin.exe)
                message(FATAL_ERROR "Proj4 database need to install sqlite3[tool]:x64-windows first.")
            endif()
            set(SQLITE3_BIN_PATH ${CURRENT_INSTALLED_DIR}/../x64-windows/tools)
        else()
            set(SQLITE3_BIN_PATH ${CURRENT_INSTALLED_DIR}/tools)
        endif()
    else()
        set(BIN_SUFFIX)
        set(SQLITE3_BIN_PATH ${CURRENT_INSTALLED_DIR}/tools)
    endif()
endif()

Maybe we can improve this judgment.

Yes, I have sqlite3[tool] installed but it failed because of the hardcoded triplets. If vcpkg has a variable that represents the current triplet we should be able to solve this.

@jasjuang Can you replace L24-47 to:

if ("database" IN_LIST FEATURES)
    if (VCPKG_TARGET_IS_WINDOWS)
        set(BIN_SUFFIX .exe)
        if (VCPKG_TARGET_ARCHITECTURE MATCHES arm OR VCPKG_TARGET_ARCHITECTURE MATCHES uwp)
            if (VCPKG_TARGET_ARCHITECTURE MATCHES 64)
                if (NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x64-windows/tools/sqlite3-bin.exe)
                    message(FATAL_ERROR "Proj4 database need to install sqlite3[tool]:${TARGET_TRIPLET} first.")
                endif()
                set(SQLITE3_BIN_PATH ${CURRENT_INSTALLED_DIR}/../x64-windows/tools)
            else()
                if (NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x86-windows/tools/sqlite3-bin.exe)
                    message(FATAL_ERROR "Proj4 database need to install sqlite3[tool]:x86-windows first.")
                endif()
                set(SQLITE3_BIN_PATH ${CURRENT_INSTALLED_DIR}/../x86-windows/tools)
            endif()
        else()
            set(SQLITE3_BIN_PATH ${CURRENT_INSTALLED_DIR}/tools)
        endif()
    else()
        set(BIN_SUFFIX)
        set(SQLITE3_BIN_PATH ${CURRENT_INSTALLED_DIR}/tools)
    endif()
endif()

And test again?

Thanks.

I just tested it and it builds. But I don't understand why though, doesn't this line

if (NOT EXISTS ${CURRENT_INSTALLED_DIR}/../x64-windows/tools/sqlite3-bin.exe)

still checks whether it exists in the default triplet because of the hard coded x64-windows?

If your custom triplet does not belong to "arm" or "uwp", it should not check this path.
In arm/uwp, the default path used by x86 is _x86-windows/tools_. The default path used by x64 is _x64-windows_, because the sqlite3-bin.exe generated by sqlite3[tools] in arm/uwp is based on arm/uwp.

You are right. I realized my mistake shortly after. Looking forward to seeing the fix in master!

Hi @jasjuang, I've fixed it in #8763, please update vcpkg and rebuild proj4.

Thanks.

Was this page helpful?
0 / 5 - 0 ratings