[vcpkg] Rewrite CMake build system to be more target-based (#12698)

* Change to using more target-focused cmake

* Add vcpkg_target_add_warning_options

* targetify the rest

* move the globs together

* Force-include pch.h on non-windows

* Rename VCPKGLIB_NON_PCH_* to VCPKGLIB_* in globs

* Remove `include "pch.h"`s

* missed a few lines

* fix build

* fix CMAKE_CURRENT_SOURCE_DIR

* try to fix VCPKG_REQUIRE_LINK_CXXFS

* change msvc-stl logic

* fix build

* CR

* clang-format

* Apply suggestions from code review

Thanks @ras0219!

Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com>
This commit is contained in:
nicole mazzuca 2020-08-10 12:32:34 -07:00 committed by GitHub
parent 481738beae
commit 895678db8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 313 additions and 397 deletions

View File

@ -1,161 +1,172 @@
cmake_minimum_required(VERSION 3.14)
project(vcpkg CXX)
include(cmake/utilities.cmake)
# ===============
# === Options ===
# ===============
include(CMakeDependentOption)
option(BUILD_TESTING "Option for enabling testing" ON)
option(VCPKG_DISABLE_METRICS "Option for disabling metrics" OFF)
option(VCPKG_ALLOW_APPLE_CLANG "Option for allowing apple clang, even versions that we don't know will work" OFF)
option(VCPKG_DEVELOPMENT_WARNINGS "Option for turning on all warnings" ON)
option(VCPKG_WARNINGS_AS_ERRORS "Set warnings to be errors" ${VCPKG_DEVELOPMENT_WARNINGS})
option(VCPKG_BUILD_FUZZING "Option for enabling vcpkg-fuzz support" OFF)
CMAKE_DEPENDENT_OPTION(VCPKG_BUILD_BENCHMARKING "Option for enabling benchmarking" OFF
"BUILD_TESTING" OFF)
if(WERROR)
message(DEPRECATION "-DWERROR is no longer a supported flag. It doesn't do anything.")
endif()
if(DEFINE_DISABLE_METRICS)
message(DEPRECATION "DEFINE_DISABLE_METRICS is now called VCPKG_DISABLE_METRICS.")
set(VCPKG_DISABLE_METRICS ${DEFINE_DISABLE_METRICS} CACHE BOOL "Option for disabling metrics" FORCE)
endif()
vcpkg_detect_compiler()
vcpkg_detect_standard_library()
vcpkg_detect_std_filesystem()
# ======================
# === Compiler Flags ===
# ======================
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
# either MSVC, or clang-cl
add_compile_options(-FC)
if (MSVC_VERSION GREATER 1900)
# Visual Studio 2017 or later
add_compile_options(-permissive- -utf-8)
endif()
if(VCPKG_DEVELOPMENT_WARNINGS)
string(REGEX REPLACE "[-/]W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_compile_options(-W4)
if(VCPKG_COMPILER STREQUAL "clang")
add_compile_options(-Wmissing-prototypes -Wno-missing-field-initializers)
else()
add_compile_options(-analyze)
endif()
endif()
if(VCPKG_WARNINGS_AS_ERRORS)
add_compile_options(-WX)
endif()
else()
if(VCPKG_DEVELOPMENT_WARNINGS)
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-redundant-move)
# GCC and clang have different names for the same warning
if(VCPKG_COMPILER STREQUAL "gcc")
add_compile_options(-Wmissing-declarations)
elseif(VCPKG_COMPILER STREQUAL "clang")
add_compile_options(-Wmissing-prototypes)
endif()
endif()
if(VCPKG_WARNINGS_AS_ERRORS)
add_compile_options(-Werror)
endif()
endif()
# ========================
# === System Libraries ===
# ========================
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
link_libraries(Threads::Threads)
add_compile_definitions(VCPKG_USE_STD_FILESYSTEM=$<BOOL:${VCPKG_USE_STD_FILESYSTEM}>)
if(VCPKG_REQUIRE_LINK_CXXFS)
if(VCPKG_STANDARD_LIBRARY STREQUAL "libstdc++")
link_libraries(stdc++fs)
elseif(VCPKG_STANDARD_LIBRARY STREQUAL "libc++")
link_libraries(c++fs)
endif()
endif()
if (MINGW)
add_compile_definitions(
UNICODE
_WIN32_WINNT=0x0601
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY=4
__fastfail=exit)
link_libraries(winhttp bcrypt version ole32 uuid)
endif()
# ===============
# === Targets ===
# ===============
add_compile_definitions(VCPKG_DISABLE_METRICS=$<BOOL:${VCPKG_DISABLE_METRICS}>)
include_directories(include)
file(GLOB_RECURSE VCPKGLIB_SOURCES CONFIGURE_DEPENDS src/vcpkg/*.cpp)
add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})
add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
if(WIN32 AND NOT VCPKG_DISABLE_METRICS)
add_executable(vcpkgmetricsuploader WIN32 src/vcpkgmetricsuploader.cpp $<TARGET_OBJECTS:vcpkglib>)
endif()
if (BUILD_TESTING)
file(GLOB_RECURSE VCPKGTEST_SOURCES CONFIGURE_DEPENDS src/vcpkg-test/*.cpp)
enable_testing()
add_executable(vcpkg-test ${VCPKGTEST_SOURCES} $<TARGET_OBJECTS:vcpkglib>)
add_test(NAME default COMMAND vcpkg-test --order rand --rng-seed time)
if (VCPKG_BUILD_BENCHMARKING)
target_compile_options(vcpkg-test PRIVATE -DCATCH_CONFIG_ENABLE_BENCHMARKING)
endif()
endif()
if(VCPKG_BUILD_FUZZING)
file(GLOB_RECURSE VCPKGFUZZ_SOURCES src/vcpkg-fuzz/*.cpp)
add_executable(vcpkg-fuzz ${VCPKGFUZZ_SOURCES} $<TARGET_OBJECTS:vcpkglib>)
endif()
find_program(CLANG_FORMAT clang-format)
if(CLANG_FORMAT)
file(GLOB_RECURSE VCPKG_FORMAT_SOURCES CONFIGURE_DEPENDS src/*.cpp include/pch.h include/vcpkg/*.h include/vcpkg-test/*.h)
add_custom_target(format COMMAND ${CLANG_FORMAT} -i -verbose ${VCPKG_FORMAT_SOURCES})
endif()
# ===========
# === PCH ===
# ===========
if(MSVC)
get_target_property(_srcs vcpkglib SOURCES)
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*")
set_property(SOURCE src/pch.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
endif()
set_source_files_properties(src/pch.cpp PROPERTIES COMPILE_FLAGS "/Ycpch.h")
target_sources(vcpkglib PRIVATE src/pch.cpp)
target_compile_options(vcpkglib PRIVATE /Yupch.h /FIpch.h /Zm200)
endif()
cmake_minimum_required(VERSION 3.14)
project(vcpkg CXX)
include(cmake/utilities.cmake)
# ===============
# === Options ===
# ===============
include(CMakeDependentOption)
option(BUILD_TESTING "Option for enabling testing" ON)
option(VCPKG_DISABLE_METRICS "Option for disabling metrics" OFF)
option(VCPKG_ALLOW_APPLE_CLANG "Option for allowing apple clang, even versions that we don't know will work" OFF)
option(VCPKG_DEVELOPMENT_WARNINGS "Option for turning on all warnings" ON)
option(VCPKG_WARNINGS_AS_ERRORS "Set warnings to be errors" ${VCPKG_DEVELOPMENT_WARNINGS})
option(VCPKG_BUILD_FUZZING "Option for enabling vcpkg-fuzz support" OFF)
CMAKE_DEPENDENT_OPTION(VCPKG_BUILD_BENCHMARKING "Option for enabling benchmarking" OFF
"BUILD_TESTING" OFF)
if(WERROR)
message(DEPRECATION "-DWERROR is no longer a supported flag. It doesn't do anything.")
endif()
if(DEFINE_DISABLE_METRICS)
message(DEPRECATION "DEFINE_DISABLE_METRICS is now called VCPKG_DISABLE_METRICS.")
set(VCPKG_DISABLE_METRICS ${DEFINE_DISABLE_METRICS} CACHE BOOL "Option for disabling metrics" FORCE)
endif()
# =============
# === Files ===
# =============
file(GLOB VCPKGLIB_SOURCES CONFIGURE_DEPENDS src/vcpkg/*.cpp)
file(GLOB VCPKGLIB_BASE_SOURCES CONFIGURE_DEPENDS src/vcpkg/base/*.cpp)
file(GLOB VCPKGLIB_INCLUDES CONFIGURE_DEPENDS include/vcpkg/*.h)
file(GLOB VCPKGLIB_BASE_INCLUDES CONFIGURE_DEPENDS include/vcpkg/base/*.h)
set(VCPKG_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.cpp)
set(VCPKGMETRICSUPLOADER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkgmetricsuploader.cpp)
file(GLOB VCPKG_TEST_SOURCES CONFIGURE_DEPENDS src/vcpkg-test/*.cpp)
file(GLOB VCPKG_TEST_INCLUDES CONFIGURE_DEPENDS include/vcpkg-test/*.h)
file(GLOB VCPKG_FUZZ_SOURCES CONFIGURE_DEPENDS src/vcpkg-fuzz/*.cpp)
# ========================
# === System detection ===
# ========================
vcpkg_detect_compiler()
vcpkg_detect_standard_library()
vcpkg_detect_std_filesystem()
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
string(REGEX REPLACE "[-/]W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
# ===============
# === Targets ===
# ===============
# === Target: vcpkglib ===
add_library(vcpkglib
${VCPKGLIB_BASE_SOURCES}
${VCPKGLIB_SOURCES}
${VCPKGLIB_BASE_INCLUDES}
${VCPKGLIB_INCLUDES})
target_include_directories(vcpkglib PUBLIC include)
vcpkg_target_add_warning_options(vcpkglib)
target_compile_definitions(vcpkglib PUBLIC
VCPKG_USE_STD_FILESYSTEM=$<BOOL:${VCPKG_USE_STD_FILESYSTEM}>)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(vcpkglib PRIVATE Threads::Threads)
if(VCPKG_CXXFS_LIBRARY)
target_link_libraries(vcpkglib PRIVATE ${VCPKG_CXXFS_LIBRARY})
endif()
if(MSVC)
get_target_property(_srcs vcpkglib SOURCES)
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*")
set_property(SOURCE src/pch.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
endif()
set_source_files_properties(src/pch.cpp PROPERTIES COMPILE_FLAGS "/Ycpch.h")
target_sources(vcpkglib PRIVATE src/pch.cpp)
target_compile_options(vcpkglib PRIVATE /Yupch.h /FIpch.h /Zm200)
else()
target_compile_options(vcpkglib PRIVATE -include "${CMAKE_CURRENT_SOURCE_DIR}/include/pch.h")
endif()
if (MINGW)
target_compile_definitions(vcpkglib
PUBLIC
UNICODE
_WIN32_WINNT=0x0601
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY=4
__fastfail=exit)
target_link_libraries(vcpkglib PUBLIC winhttp bcrypt version ole32 uuid)
endif()
# === Target: vcpkg ===
add_executable(vcpkg ${VCPKG_SOURCES})
target_link_libraries(vcpkg PRIVATE vcpkglib)
vcpkg_target_add_warning_options(vcpkg)
# === Target: vcpkgmetricsuploader ===
if(WIN32 AND NOT VCPKG_DISABLE_METRICS)
add_executable(vcpkgmetricsuploader WIN32 ${VCPKGMETRICSUPLOADER_SOURCES})
target_link_libraries(vcpkgmetricsuploader PRIVATE vcpkglib)
vcpkg_target_add_warning_options(vcpkgmetricsuploader)
endif()
# === Target: vcpkg-test ===
if (BUILD_TESTING)
enable_testing()
add_executable(vcpkg-test
${VCPKG_TEST_SOURCES}
${VCPKG_TEST_INCLUDES})
target_link_libraries(vcpkg-test PRIVATE vcpkglib)
vcpkg_target_add_warning_options(vcpkg-test)
add_test(NAME default COMMAND vcpkg-test --order rand --rng-seed time)
if (VCPKG_BUILD_BENCHMARKING)
target_compile_options(vcpkg-test PRIVATE -DCATCH_CONFIG_ENABLE_BENCHMARKING)
endif()
endif()
# === Target: vcpkg-fuzz ===
if(VCPKG_BUILD_FUZZING)
add_executable(vcpkg-fuzz ${VCPKG_FUZZ_SOURCES})
target_link_libraries(vcpkg-fuzz PRIVATE vcpkglib)
vcpkg_target_add_warning_options(vcpkg-fuzz)
endif()
# === Target: format ===
find_program(CLANG_FORMAT clang-format)
if(CLANG_FORMAT)
add_custom_target(format COMMAND ${CLANG_FORMAT} -i -verbose
${CMAKE_CURRENT_SOURCE_DIR}/src/pch.cpp
${VCPKGLIB_BASE_SOURCES}
${VCPKGLIB_NON_PCH_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/include/pch.h
${VCPKGLIB_BASE_INCLUDES}
${VCPKGLIB_NON_PCH_INCLUDES}
${VCPKG_SOURCES}
${VCPKGMETRICSUPLOADER_SOURCES}
${VCPKG_TEST_SOURCES}
${VCPKG_TEST_INCLUDES}
${VCPKG_FUZZ_SOURCES})
endif()

View File

@ -77,7 +77,7 @@ int main() {}
_VCPKG_STANDARD_LIBRARY_LIBCXX)
check_cxx_source_compiles([[
#include <ciso646>
#if !defined(_MSVC_STL_VERSION)
#if !defined(_MSVC_STL_VERSION) && !(defined(_MSC_VER) && _MSC_VER <= 1900)
#error "not MSVC stl"
#endif
int main() {}
@ -101,7 +101,7 @@ int main() {}
endif()
endfunction()
# Outputs to Cache: VCPKG_USE_STD_FILESYSTEM, VCPKG_REQUIRE_LINK_CXXFS
# Outputs to Cache: VCPKG_USE_STD_FILESYSTEM, VCPKG_CXXFS_LIBRARY
function(vcpkg_detect_std_filesystem)
vcpkg_detect_standard_library()
@ -129,10 +129,14 @@ int main() {}
int main() {}
]]
_VCPKG_USE_STD_FILESYSTEM)
if(_VCPKG_REQUIRE_LINK_CXXFS)
set(_VCPKG_CXXFS_LIBRARY "stdc++fs")
endif()
elseif(VCPKG_STANDARD_LIBRARY STREQUAL "libc++")
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
# AppleClang never requires (or allows) -lc++fs, even with libc++ version 8.0.0
set(_VCPKG_REQUIRE_LINK_CXXFS OFF)
set(_VCPKG_CXXFS_LIBRARY OFF)
else()
check_cxx_source_compiles([[
#include <ciso646>
@ -142,6 +146,10 @@ int main() {}
int main() {}
]]
_VCPKG_REQUIRE_LINK_CXXFS)
if(_VCPKG_REQUIRE_LINK_CXXFS)
set(_VCPKG_CXXFS_LIBRARY "c++fs")
endif()
endif()
# We don't support versions of libc++ < 7.0.0, and libc++ 7.0.0 has <filesystem>
@ -155,16 +163,16 @@ int main() {}
int main() {}"
_VCPKG_USE_STD_FILESYSTEM)
set(_VCPKG_REQUIRE_LINK_CXXFS OFF)
set(_VCPKG_CXXFS_LIBRARY OFF)
endif()
set(VCPKG_USE_STD_FILESYSTEM ${_VCPKG_USE_STD_FILESYSTEM}
CACHE BOOL
"Whether to use <filesystem>, as opposed to <experimental/filesystem>"
FORCE)
set(VCPKG_REQUIRE_LINK_CXXFS ${_VCPKG_REQUIRE_LINK_CXXFS}
CACHE BOOL
"Whether it's required to pass -l[std]c++fs in order to use <filesystem>"
set(VCPKG_CXXFS_LIBRARY ${_VCPKG_CXXFS_LIBRARY}
CACHE STRING
"Library to link (if any) in order to use <filesystem>"
FORCE)
if(VCPKG_USE_STD_FILESYSTEM)
@ -172,10 +180,54 @@ int main() {}
else()
set(msg "<experimental/filesystem>")
endif()
if(VCPKG_REQUIRE_LINK_CXXFS)
set(msg "${msg} with -l[std]c++fs")
if(VCPKG_CXXFS_LIBRARY)
set(msg "${msg} with -l${VCPKG_CXXFS_LIBRARY}")
endif()
message(STATUS "Detecting how to use the C++ filesystem library - ${msg}")
endif()
endfunction()
function(vcpkg_target_add_warning_options TARGET)
if(MSVC)
# either MSVC, or clang-cl
target_compile_options(${TARGET} PRIVATE -FC)
if (MSVC_VERSION GREATER 1900)
# Visual Studio 2017 or later
target_compile_options(${TARGET} PRIVATE -permissive- -utf-8)
endif()
if(VCPKG_DEVELOPMENT_WARNINGS)
target_compile_options(${TARGET} PRIVATE -W4)
if(VCPKG_COMPILER STREQUAL "clang")
target_compile_options(${TARGET} PRIVATE -Wmissing-prototypes -Wno-missing-field-initializers)
else()
target_compile_options(${TARGET} PRIVATE -analyze)
endif()
else()
target_compile_options(${TARGET} PRIVATE -W3)
endif()
if(VCPKG_WARNINGS_AS_ERRORS)
target_compile_options(${TARGET} PRIVATE -WX)
endif()
else()
if(VCPKG_DEVELOPMENT_WARNINGS)
target_compile_options(${TARGET} PRIVATE
-Wall -Wextra -Wpedantic
-Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-redundant-move)
# GCC and clang have different names for the same warning
if(VCPKG_COMPILER STREQUAL "gcc")
target_compile_options(${TARGET} PRIVATE -Wmissing-declarations)
elseif(VCPKG_COMPILER STREQUAL "clang")
target_compile_options(${TARGET} PRIVATE -Wmissing-prototypes)
endif()
endif()
if(VCPKG_WARNINGS_AS_ERRORS)
target_compile_options(${TARGET} PRIVATE -Werror)
endif()
endif()
endfunction()

View File

@ -1 +1,2 @@
#include "pch.h"
// This file intentionally left blank. It exists to be a target for pch compilation,
// but `#include "pch.h"` is already injected by the compiler.

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.process.h>
#include <vcpkg/archives.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/stringview.h>
#include <vcpkg/base/system.debug.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/chrono.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/cofffilereader.h>
#include <vcpkg/base/stringliteral.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/downloads.h>
#include <vcpkg/base/hash.h>
#include <vcpkg/base/system.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/enums.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/files.h>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/system.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/hash.h>
#include <vcpkg/base/strings.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/files.h>
#include <vcpkg/base/json.h>
#include <vcpkg/base/system.debug.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/machinetype.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/parse.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/lineinfo.h>
#include <vcpkg/base/stringview.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/system.debug.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/system.debug.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/unicode.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/parse.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/cache.h>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/chrono.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/buildenvironment.h>
namespace vcpkg

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/hash.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/span.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/commands.autocomplete.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/binarycaching.h>
#include <vcpkg/build.h>
#include <vcpkg/cmakevars.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/files.h>
#include <vcpkg/base/system.print.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/cache.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/graphs.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/system.print.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/build.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/files.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.process.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/commands.fetch.h>
namespace vcpkg::Commands::Fetch

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/json.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/hash.h>
#include <vcpkg/commands.hash.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/commands.list.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/commands.owns.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/sortedvector.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/commands.search.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/binarycaching.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/commands.version.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/commands.xvsinstances.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/files.h>
#include <vcpkg/base/graphs.h>
#include <vcpkg/base/strings.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>
@ -39,24 +37,24 @@ namespace vcpkg::Export::Chocolatey
const std::map<std::string, std::string>& packages_version,
const Options& chocolatey_options)
{
static constexpr auto CONTENT_TEMPLATE = R"(<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>@PACKAGE_ID@</id>
<version>@PACKAGE_VERSION@</version>
<authors>@PACKAGE_MAINTAINER@</authors>
<description><![CDATA[
@PACKAGE_DESCRIPTION@
]]></description>
<dependencies>
@PACKAGE_DEPENDENCIES@
</dependencies>
</metadata>
<files>
<file src="@EXPORTED_ROOT_DIR@\installed\**" target="installed" />
<file src="@EXPORTED_ROOT_DIR@\tools\**" target="tools" />
</files>
</package>
static constexpr auto CONTENT_TEMPLATE = R"(<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>@PACKAGE_ID@</id>
<version>@PACKAGE_VERSION@</version>
<authors>@PACKAGE_MAINTAINER@</authors>
<description><![CDATA[
@PACKAGE_DESCRIPTION@
]]></description>
<dependencies>
@PACKAGE_DEPENDENCIES@
</dependencies>
</metadata>
<files>
<file src="@EXPORTED_ROOT_DIR@\installed\**" target="installed" />
<file src="@EXPORTED_ROOT_DIR@\tools\**" target="tools" />
</files>
</package>
)";
auto package_version = packages_version.find(binary_paragraph.spec.name());
if (package_version == packages_version.end())
@ -81,68 +79,68 @@ namespace vcpkg::Export::Chocolatey
static std::string create_chocolatey_install_contents()
{
static constexpr auto CONTENT_TEMPLATE = R"###(
$ErrorActionPreference = 'Stop';
$packageName= $env:ChocolateyPackageName
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$rootDir = "$(Split-Path -parent $toolsDir)"
$installedDir = Join-Path $rootDir 'installed'
$whereToInstall = (pwd).path
$whereToInstallCache = Join-Path $rootDir 'install.txt'
Set-Content -Path $whereToInstallCache -Value $whereToInstall
Copy-Item $installedDir -destination $whereToInstall -recurse -force
static constexpr auto CONTENT_TEMPLATE = R"###(
$ErrorActionPreference = 'Stop';
$packageName= $env:ChocolateyPackageName
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$rootDir = "$(Split-Path -parent $toolsDir)"
$installedDir = Join-Path $rootDir 'installed'
$whereToInstall = (pwd).path
$whereToInstallCache = Join-Path $rootDir 'install.txt'
Set-Content -Path $whereToInstallCache -Value $whereToInstall
Copy-Item $installedDir -destination $whereToInstall -recurse -force
)###";
return CONTENT_TEMPLATE;
}
static std::string create_chocolatey_uninstall_contents(const BinaryParagraph& binary_paragraph)
{
static constexpr auto CONTENT_TEMPLATE = R"###(
$ErrorActionPreference = 'Stop';
$packageName= $env:ChocolateyPackageName
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$rootDir = "$(Split-Path -parent $toolsDir)"
$listFile = Join-Path $rootDir 'installed\vcpkg\info\@PACKAGE_FULLSTEM@.list'
$whereToInstall = $null
$whereToInstallCache = Join-Path $rootDir 'install.txt'
Get-Content $whereToInstallCache | Foreach-Object {
$whereToInstall = $_
}
$installedDir = Join-Path $whereToInstall 'installed'
Get-Content $listFile | Foreach-Object {
$fileToRemove = Join-Path $installedDir $_
if (Test-Path $fileToRemove -PathType Leaf) {
Remove-Item $fileToRemove
}
}
Get-Content $listFile | Foreach-Object {
$fileToRemove = Join-Path $installedDir $_
if (Test-Path $fileToRemove -PathType Container) {
$folderToDelete = Join-Path $fileToRemove *
if (-Not (Test-Path $folderToDelete))
{
Remove-Item $fileToRemove
}
}
}
$listFileToRemove = Join-Path $whereToInstall 'installed\vcpkg\info\@PACKAGE_FULLSTEM@.list'
Remove-Item $listFileToRemove
if (Test-Path $installedDir)
{
while (
$empties = Get-ChildItem $installedDir -recurse -Directory | Where-Object {
$_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0
}
) { $empties | Remove-Item }
}
static constexpr auto CONTENT_TEMPLATE = R"###(
$ErrorActionPreference = 'Stop';
$packageName= $env:ChocolateyPackageName
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$rootDir = "$(Split-Path -parent $toolsDir)"
$listFile = Join-Path $rootDir 'installed\vcpkg\info\@PACKAGE_FULLSTEM@.list'
$whereToInstall = $null
$whereToInstallCache = Join-Path $rootDir 'install.txt'
Get-Content $whereToInstallCache | Foreach-Object {
$whereToInstall = $_
}
$installedDir = Join-Path $whereToInstall 'installed'
Get-Content $listFile | Foreach-Object {
$fileToRemove = Join-Path $installedDir $_
if (Test-Path $fileToRemove -PathType Leaf) {
Remove-Item $fileToRemove
}
}
Get-Content $listFile | Foreach-Object {
$fileToRemove = Join-Path $installedDir $_
if (Test-Path $fileToRemove -PathType Container) {
$folderToDelete = Join-Path $fileToRemove *
if (-Not (Test-Path $folderToDelete))
{
Remove-Item $fileToRemove
}
}
}
$listFileToRemove = Join-Path $whereToInstall 'installed\vcpkg\info\@PACKAGE_FULLSTEM@.list'
Remove-Item $listFileToRemove
if (Test-Path $installedDir)
{
while (
$empties = Get-ChildItem $installedDir -recurse -Directory | Where-Object {
$_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0
}
) { $empties | Remove-Item }
}
)###";
std::string chocolatey_uninstall_content =
Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_FULLSTEM@", binary_paragraph.fullstem());

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/stringliteral.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/system.print.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/globalstate.h>
namespace vcpkg

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/binarycaching.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/commands.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/files.h>
#include <vcpkg/base/hash.h>
#include <vcpkg/base/system.print.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/hash.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/parse.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/paragraphparseresult.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/files.h>
#include <vcpkg/base/parse.h>
#include <vcpkg/base/system.debug.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/parse.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.print.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.debug.h>
#include <vcpkg/paragraphs.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/postbuildlint.buildtype.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/cofffilereader.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/system.print.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/expected.h>
#include <vcpkg/base/span.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/util.h>
#include <vcpkg/statusparagraph.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/statusparagraphs.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/checks.h>
#include <vcpkg/base/downloads.h>
#include <vcpkg/base/files.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/strings.h>
#include <vcpkg/triplet.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/commands.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/files.h>
#include <vcpkg/base/lazy.h>
#include <vcpkg/base/system.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/system.print.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/files.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/util.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/hash.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#include <vcpkg/base/strings.h>
#include <vcpkg/versiont.h>

View File

@ -1,5 +1,3 @@
#include "pch.h"
#if defined(_WIN32)
#include <vcpkg/base/sortedvector.h>

View File

@ -83,6 +83,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
</ItemDefinitionGroup>
@ -97,6 +98,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
</ItemDefinitionGroup>
@ -113,6 +115,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@ -132,6 +135,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>