Add Ninja support

This commit is contained in:
codicodi 2017-02-03 17:16:13 +01:00
parent 761d56711e
commit 95af9aac7c
7 changed files with 43 additions and 15 deletions

View File

@ -1,3 +1,3 @@
Source: fmt
Version: 3.0.1-2
Version: 3.0.1-3
Description: Formatting library for C++. It can be used as a safe alternative to printf or as a fast alternative to IOStreams.

View File

@ -13,6 +13,7 @@ vcpkg_extract_source_archive(${ARCHIVE_FILE})
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DFMT_CMAKE_DIR=share/fmt
-DFMT_TEST=OFF

View File

@ -1,7 +1,7 @@
function(vcpkg_build_cmake)
cmake_parse_arguments(_bc "MSVC_64_TOOLSET;DISABLE_PARALLEL" "" "" ${ARGN})
set(MSVC_EXTRA_ARGS)
set(MSVC_EXTRA_ARGS /p:VCPkgLocalAppDataDisabled=true)
# Specifies the architecture of the toolset, NOT the architecture of the produced binary
if (_bc_MSVC_64_TOOLSET)
@ -12,9 +12,15 @@ function(vcpkg_build_cmake)
list(APPEND MSVC_EXTRA_ARGS "/m")
endif()
if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/build.ninja)
set(BUILD_ARGS -v) # verbose output
else()
set(BUILD_ARGS ${MSVC_EXTRA_ARGS})
endif()
message(STATUS "Build ${TARGET_TRIPLET}-rel")
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} --build . --config Release -- /p:VCPkgLocalAppDataDisabled=true ${MSVC_EXTRA_ARGS}
COMMAND ${CMAKE_COMMAND} --build . --config Release -- ${BUILD_ARGS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME build-${TARGET_TRIPLET}-rel
)
@ -22,7 +28,7 @@ function(vcpkg_build_cmake)
message(STATUS "Build ${TARGET_TRIPLET}-dbg")
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} --build . --config Debug -- /p:VCPkgLocalAppDataDisabled=true ${MSVC_EXTRA_ARGS}
COMMAND ${CMAKE_COMMAND} --build . --config Debug -- ${BUILD_ARGS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME build-${TARGET_TRIPLET}-dbg
)

View File

@ -1,6 +1,5 @@
find_program(vcpkg_configure_cmake_NINJA ninja)
function(vcpkg_configure_cmake)
cmake_parse_arguments(_csc "" "SOURCE_PATH;GENERATOR" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN})
cmake_parse_arguments(_csc "PREFER_NINJA" "SOURCE_PATH;GENERATOR" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN})
if(NOT VCPKG_PLATFORM_TOOLSET)
message(FATAL_ERROR "Vcpkg has been updated with VS2017 support, however you need to rebuild vcpkg.exe by re-running bootstrap.ps1\n powershell -exec bypass scripts\\bootstrap.ps1\n")
@ -8,14 +7,14 @@ function(vcpkg_configure_cmake)
if(_csc_GENERATOR)
set(GENERATOR ${_csc_GENERATOR})
elseif(_csc_PREFER_NINJA AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(GENERATOR "Ninja")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015 Win64")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015 ARM")
# elseif(NOT vcpkg_configure_cmake_NINJA MATCHES "NOTFOUND")
# set(GENERATOR "Ninja")
elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
set(GENERATOR "Visual Studio 14 2015")
elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140")
@ -36,6 +35,13 @@ function(vcpkg_configure_cmake)
elseif(TRIPLET_SYSTEM_ARCH MATCHES "arm")
set(GENERATOR "Visual Studio 15 2017 ARM" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141")
endif()
# If we use Ninja, make sure it's on PATH
if(GENERATOR STREQUAL "Ninja")
vcpkg_find_acquire_program(NINJA)
get_filename_component(NINJA_PATH ${NINJA} DIRECTORY)
set(ENV{PATH} "${NINJA_PATH};$ENV{PATH}")
endif()
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)

View File

@ -4,6 +4,7 @@ function(vcpkg_find_acquire_program VAR)
endif()
unset(NOEXTRACT)
unset(SUBDIR)
if(VAR MATCHES "PERL")
set(PROGNAME perl)
@ -63,6 +64,13 @@ function(vcpkg_find_acquire_program VAR)
set(URL "http://7-zip.org/a/7z1604.msi")
set(ARCHIVE "7z1604.msi")
set(HASH 556f95f7566fe23704d136239e4cf5e2a26f939ab43b44145c91b70d031a088d553e5c21301f1242a2295dcde3143b356211f0108c68e65eef8572407618326d)
elseif(VAR MATCHES "NINJA")
set(PROGNAME ninja)
set(SUBDIR "ninja-1.7.2")
set(PATHS ${DOWNLOADS}/tools/ninja/${SUBDIR})
set(URL "https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-win.zip")
set(ARCHIVE "ninja-win.zip")
set(HASH cccab9281b274c564f9ad77a2115be1f19be67d7b2ee14a55d1db1b27f3b68db8e76076e4f804b61eb8e573e26a8ecc9985675a8dcf03fd7a77b7f57234f1393)
else()
message(FATAL "unknown tool ${VAR} -- unable to acquire.")
endif()
@ -73,15 +81,15 @@ function(vcpkg_find_acquire_program VAR)
EXPECTED_HASH SHA512=${HASH}
SHOW_PROGRESS
)
file(MAKE_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME})
file(MAKE_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR})
if(DEFINED NOEXTRACT)
file(COPY ${DOWNLOADS}/${ARCHIVE} DESTINATION ${DOWNLOADS}/tools/${PROGNAME})
file(COPY ${DOWNLOADS}/${ARCHIVE} DESTINATION ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR})
else()
get_filename_component(ARCHIVE_EXTENSION ${ARCHIVE} EXT)
string(TOLOWER "${ARCHIVE_EXTENSION}" ARCHIVE_EXTENSION)
if(${ARCHIVE_EXTENSION} STREQUAL ".msi")
file(TO_NATIVE_PATH "${DOWNLOADS}/${ARCHIVE}" ARCHIVE_NATIVE_PATH)
file(TO_NATIVE_PATH "${DOWNLOADS}/tools/${PROGNAME}" DESTINATION_NATIVE_PATH)
file(TO_NATIVE_PATH "${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR}" DESTINATION_NATIVE_PATH)
execute_process(
COMMAND msiexec /a ${ARCHIVE_NATIVE_PATH} /qn TARGETDIR=${DESTINATION_NATIVE_PATH}
WORKING_DIRECTORY ${DOWNLOADS}
@ -89,7 +97,7 @@ function(vcpkg_find_acquire_program VAR)
else()
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${DOWNLOADS}/${ARCHIVE}
WORKING_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}
WORKING_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR}
)
endif()
endif()

View File

@ -1,7 +1,7 @@
function(vcpkg_install_cmake)
cmake_parse_arguments(_bc "MSVC_64_TOOLSET;DISABLE_PARALLEL" "" "" ${ARGN})
set(MSVC_EXTRA_ARGS)
set(MSVC_EXTRA_ARGS /p:VCPkgLocalAppDataDisabled=true)
# Specifies the architecture of the toolset, NOT the architecture of the produced binary
if (_bc_MSVC_64_TOOLSET)
@ -11,10 +11,16 @@ function(vcpkg_install_cmake)
if (NOT _bc_DISABLE_PARALLEL)
list(APPEND MSVC_EXTRA_ARGS "/m")
endif()
if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/build.ninja)
set(BUILD_ARGS -v) # verbose output
else()
set(BUILD_ARGS ${MSVC_EXTRA_ARGS})
endif()
message(STATUS "Package ${TARGET_TRIPLET}-rel")
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} --build . --config Release --target install -- /p:VCPkgLocalAppDataDisabled=true ${MSVC_EXTRA_ARGS}
COMMAND ${CMAKE_COMMAND} --build . --config Release --target install -- ${BUILD_ARGS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME package-${TARGET_TRIPLET}-rel
)
@ -22,7 +28,7 @@ function(vcpkg_install_cmake)
message(STATUS "Package ${TARGET_TRIPLET}-dbg")
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} --build . --config Debug --target install -- /p:VCPkgLocalAppDataDisabled=true ${MSVC_EXTRA_ARGS}
COMMAND ${CMAKE_COMMAND} --build . --config Debug --target install -- ${BUILD_ARGS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME package-${TARGET_TRIPLET}-dbg
)

View File

@ -17,6 +17,7 @@ vcpkg_extract_source_archive(${ARCHIVE})
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA # Disable this option if project cannot be built with Ninja
# OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2
# OPTIONS_RELEASE -DOPTIMIZE=1
# OPTIONS_DEBUG -DDEBUGGABLE=1