Skip to content

Commit

Permalink
[vcpkg_find_acquire_program] add version check for ninja (microsoft#1…
Browse files Browse the repository at this point in the history
…2895)

* [vcpkg_find_acquire_program] add version check for ninja

* Change VERSION to NINJA_VERSION

* Missed VERSION change

* some more corrections

* add missing PACKAGES parameter

* add osx hash

Co-authored-by: Wolfgang Stöggl <c72578@yahoo.de>

* Remove apt/brew package names

Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com>

* move supported around and disable it for freebsd

* fix small command hickup which does not matter for ninja

Co-authored-by: Wolfgang Stöggl <c72578@yahoo.de>
Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com>
  • Loading branch information
3 people authored and remz1337 committed Aug 23, 2020
1 parent 99e837d commit 3fc1c2f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
53 changes: 45 additions & 8 deletions scripts/cmake/vcpkg_find_acquire_program.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,30 @@ function(vcpkg_find_acquire_program VAR)
set(HASH f73b04e2d9f29d4393fde572dcf3c3f0f6fa27e747e5df292294ab7536ae24c239bf917689d71eb10cc49f6b9a4ace26d7c122ee887d93cc935f268c404e9067)
elseif(VAR MATCHES "NINJA")
set(PROGNAME ninja)
set(SUBDIR "ninja-1.10.0")
set(NINJA_VERSION 1.10.0)
set(SUBDIR "ninja-${NINJA_VERSION}")
set(_vfa_SUPPORTED ON)
if(CMAKE_HOST_WIN32)
set(ARCHIVE "ninja-win-${NINJA_VERSION}.zip")
set(PATHS "${DOWNLOADS}/tools/${SUBDIR}-windows")
list(APPEND PATHS "${DOWNLOADS}/tools/ninja/${SUBDIR}")
set(URL "https://github.com/ninja-build/ninja/releases/download/v${NINJA_VERSION}/ninja-win.zip")
set(HASH a196e243c53daa1df9d287af658d6d38d6b830b614f2d5704e8c88ffc61f179a533ae71cdb6d0d383d1559d65dacccbaaab270fb2a33aa211e5dba42ff046f97)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
set(ARCHIVE "ninja-mac-${NINJA_VERSION}.zip")
set(URL "https://github.com/ninja-build/ninja/releases/download/v${NINJA_VERSION}/ninja-mac.zip")
set(PATHS "${DOWNLOADS}/tools/${SUBDIR}-osx")
set(HASH 619a1924067a0b30fc5f8887f868d3ee5481838d2f0f158d031f7614a2a10b95a73d4a56b658d5d560283ebf809e2e536b968c6c01ff0108075c3f393f5780ba)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD")
set(PATHS "${DOWNLOADS}/tools/${SUBDIR}-freebsd")
set(_vfa_SUPPORTED OFF)
else()
set(ARCHIVE "ninja-linux-${NINJA_VERSION}.zip")
set(URL "https://github.com/ninja-build/ninja/releases/download/v${NINJA_VERSION}/ninja-linux.zip")
set(PATHS "${DOWNLOADS}/tools/${SUBDIR}-linux")
set(HASH ffb179ab8ea315167fcc99a8f13286e1363590185b18cf819cc73e09f2a7553790e9dc45fd1ccd0bd1d2dbf543aee3f6c0951cf9ce453a7168ffd2ac873cdd29)
endif()
set(BREW_PACKAGE_NAME "ninja")
set(APT_PACKAGE_NAME "ninja-build")
set(URL "https://github.com/ninja-build/ninja/releases/download/v1.10.0/ninja-win.zip")
set(ARCHIVE "ninja-win-1.10.0.zip")
set(HASH a196e243c53daa1df9d287af658d6d38d6b830b614f2d5704e8c88ffc61f179a533ae71cdb6d0d383d1559d65dacccbaaab270fb2a33aa211e5dba42ff046f97)
set(VERSION_CMD --version)
elseif(VAR MATCHES "NUGET")
set(PROGNAME nuget)
set(SUBDIR "5.5.1")
Expand Down Expand Up @@ -379,10 +387,36 @@ function(vcpkg_find_acquire_program VAR)
message(FATAL "unknown tool ${VAR} -- unable to acquire.")
endif()

macro(do_version_check)
if(VERSION_CMD)
_execute_process(
COMMAND ${${VAR}} ${VERSION_CMD}
WORKING_DIRECTORY ${DOWNLOADS}
OUTPUT_VARIABLE ${VAR}_VERSION_OUTPUT
)
string(STRIP "${${VAR}_VERSION_OUTPUT}" ${VAR}_VERSION_OUTPUT)
#TODO: REGEX MATCH case for more complex cases!
if(NOT ${VAR}_VERSION_OUTPUT VERSION_GREATER_EQUAL ${VAR}_VERSION)
message(STATUS "Found ${PROGNAME}('${${VAR}_VERSION_OUTPUT}') but at least version ${${VAR}_VERSION} is required! Trying to use internal version if possible!")
set(${VAR} "${VAR}-NOTFOUND" CACHE INTERNAL "")
else()
message(STATUS "Found external ${PROGNAME}('${${VAR}_VERSION_OUTPUT}').")
endif()
endif()
endmacro()

macro(do_find)
if(NOT DEFINED REQUIRED_INTERPRETER)
find_program(${VAR} ${PROGNAME} PATHS ${PATHS} NO_DEFAULT_PATH)
find_program(${VAR} ${PROGNAME})
if(NOT ${VAR})
find_program(${VAR} ${PROGNAME})
if(${VAR} AND NOT ${VAR}_VERSION_CHECKED)
do_version_check()
set(${VAR}_VERSION_CHECKED ON)
elseif(${VAR}_VERSION_CHECKED)
message(FATAL_ERROR "Unable to find ${PROGNAME} with min version of ${${VAR}_VERSION}")
endif()
endif()
else()
vcpkg_find_acquire_program(${REQUIRED_INTERPRETER})
find_file(SCRIPT_${VAR} ${SCRIPTNAME} PATHS ${PATHS} NO_DEFAULT_PATH)
Expand Down Expand Up @@ -456,8 +490,11 @@ function(vcpkg_find_acquire_program VAR)
LOGNAME ${VAR}-tool-post-install
)
endif()

unset(${VAR} CACHE)
do_find()
if(NOT ${VAR})
message(FATAL_ERROR "Unable to find ${VAR}")
endif()
endif()

set(${VAR} "${${VAR}}" PARENT_SCOPE)
Expand Down
2 changes: 1 addition & 1 deletion scripts/cmake/vcpkg_find_fortran.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function(vcpkg_find_fortran additional_cmake_args_out)
else()
message(FATAL_ERROR "Unknown architecture '${VCPKG_TARGET_ARCHITECTURE}' for MinGW Fortran build!")
endif()
vcpkg_acquire_msys(MSYS_ROOT "mingw-w64-${MSYS_TARGET}-gcc-fortran")
vcpkg_acquire_msys(MSYS_ROOT PACKAGES "mingw-w64-${MSYS_TARGET}-gcc-fortran")
set(MINGW_BIN "${MSYS_ROOT}/${MINGW_PATH}/bin")
vcpkg_add_to_path(PREPEND "${MINGW_BIN}")
list(APPEND ARGS_OUT -DCMAKE_GNUtoMS=ON
Expand Down

0 comments on commit 3fc1c2f

Please sign in to comment.