From 9d6897b57246a4142f2b43de9eb69d141ac1855b Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 24 Mar 2023 10:43:36 +0000 Subject: [PATCH] Suppress warnings related to DOWNLOAD_EXTRACT_TIMESTAMP --- src/cmake_generator.cpp | 28 +++++++++++++++++++++------- tests/cmake.toml | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/cmake_generator.cpp b/src/cmake_generator.cpp index cfa9807..d5b4db9 100644 --- a/src/cmake_generator.cpp +++ b/src/cmake_generator.cpp @@ -812,14 +812,20 @@ void generate_cmake(const char *path, const parser::Project *parent_project) { // clang-format off cmd("if")("CMKR_ROOT_PROJECT", "AND", "NOT", "CMKR_DISABLE_VCPKG"); cmd("include")("FetchContent"); - cmd("message")("STATUS", "Fetching vcpkg (" + version_name + ")..."); - cmd("FetchContent_Declare")("vcpkg", "URL", url); - // Not using FetchContent_MakeAvailable here in case vcpkg adds CMakeLists.txt - cmd("FetchContent_GetProperties")("vcpkg"); - cmd("if")("NOT", "vcpkg_POPULATED"); - cmd("FetchContent_Populate")("vcpkg"); - cmd("include")("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake"); + comment("Fix warnings about DOWNLOAD_EXTRACT_TIMESTAMP"); + // clang-format off + cmd("if")("POLICY", "CMP0135"); + cmd("cmake_policy")("SET", "CMP0135", "NEW"); cmd("endif")(); + // clang-format on + cmd("message")("STATUS", "Fetching vcpkg (" + version_name + ")..."); + cmd("FetchContent_Declare")("vcpkg", "URL", url); + // Not using FetchContent_MakeAvailable here in case vcpkg adds CMakeLists.txt + cmd("FetchContent_GetProperties")("vcpkg"); + cmd("if")("NOT", "vcpkg_POPULATED"); + cmd("FetchContent_Populate")("vcpkg"); + cmd("include")("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake"); + cmd("endif")(); cmd("endif")(); endl(); // clang-format on @@ -889,6 +895,14 @@ void generate_cmake(const char *path, const parser::Project *parent_project) { if (!project.contents.empty()) { cmd("include")("FetchContent").endl(); + if (!project.root()->vcpkg.enabled()) { + comment("Fix warnings about DOWNLOAD_EXTRACT_TIMESTAMP"); + // clang-format off + cmd("if")("POLICY", "CMP0135"); + cmd("cmake_policy")("SET", "CMP0135", "NEW"); + cmd("endif")(); + // clang-format on + } for (const auto &content : project.contents) { ConditionScope cs(gen, content.condition); diff --git a/tests/cmake.toml b/tests/cmake.toml index 6935a9a..cddec8f 100644 --- a/tests/cmake.toml +++ b/tests/cmake.toml @@ -51,4 +51,4 @@ condition = "msvc" name = "msvc-runtime" working-directory = "msvc-runtime" command = "$" -arguments = ["build"] \ No newline at end of file +arguments = ["build"]