mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 13:37:49 +08:00
1d8f0acc9c
==== Changes Related to manifests ==== * Add the `manifests` feature flag * This only says whether we look for a `vcpkg.json` in the cwd, not whether we support parsing manifests (for ports, for example) * Changes to the manifests RFC * `"authors"` -> `"maintainers"` * `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags` * reserve `"core"` in addition to `"default"`, since that's already reserved for features * Add a small helper note about what identifiers must look like * `<license-string>`: SPDX v3.8 -> v3.9 * `"feature"."description"` is allowed to be an array of strings as well * `"version"` -> `"version-string"` for forward-compat with versions RFC * Add the `--feature-flags` option * Add the ability to turn off feature flags via passing `-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags` * Add CMake toolchain support for manifests * Requires either: * a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}` or `VCPKG_FEATURE_FLAGS` * Passing the `VCPKG_ENABLE_MANIFESTS` option * The toolchain will install your packages to `${VCPKG_MANIFEST_DIR}/vcpkg_installed`. * Add MSBuild `vcpkg integrate install` support for manifests * Requires `VcpkgEnableManifest` to be true * `vcpkg create` creates a port that has a `vcpkg.json` instead of a `CONTROL` * argparse, abseil, 3fd, and avisynthplus ports switched to manifest from CONTROL * Add support for `--x-manifest-root`, as well as code for finding it if not passed * Add support for parsing manifests! * Add a filesystem lock! ==== Important Changes which are somewhat unrelated to manifests ==== * Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}` * Add `PlatformExpression` type which takes the place of the old logic expression * Split the parsing of platform expressions from checking whether they're true or not * Eagerly parse PlatformExpressions as opposed to leaving them as strings * Add checking for feature flag consistency * i.e., if `-binarycaching` is passed, you shouldn't be passing `--binarysource` * Add the `Json::Reader` type which, with the help of user-defined visitors, converts JSON to your internal type * VcpkgArgParser: place the switch names into a constant as opposed to using magic constants * In general update the parsing code so that this ^ works * Add `Port-Version` fields to CONTROL files * This replaces the existing practice of `Version: <my-version>-<port-version>` ==== Smaller changes ==== * small drive-by cleanups to some CMake * `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` -> `${CURRENT_INSTALLED_DIR}` * Remove `-analyze` when compiling with clang-cl, since that's not a supported flag (vcpkg's build system) * Add a message about which compiler is detected by vcpkg's build system machinery * Fix `Expected::then` * Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a `strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`) * Add `Strings::strto` which converts strings to numeric types * Support built-in arrays and `StringView` for `Strings::join` * Add `operator<` and friends to `StringView` * Add `substr` to `StringView` * SourceParagraphParser gets some new errors
162 lines
5.3 KiB
CMake
162 lines
5.3 KiB
CMake
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()
|