From 4a15d2ba550802d28301ff09ea6fedb64b28a7fa Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 3 Nov 2024 10:33:32 +0100 Subject: [PATCH] Use CMAKE_CONFIGURE_DEPENDS when supported --- src/cmake_generator.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cmake_generator.cpp b/src/cmake_generator.cpp index 1dd021f..efcd7aa 100644 --- a/src/cmake_generator.cpp +++ b/src/cmake_generator.cpp @@ -761,7 +761,11 @@ void generate_cmake(const char *path, const parser::Project *parent_project) { cmd("set_property")("GLOBAL", "PROPERTY", "USE_FOLDERS", "ON").endl(); comment("Create a configure-time dependency on cmake.toml to improve IDE support"); - cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY"); + if (project.cmake_minimum_version(3, 0)) { + cmd("set_property")("DIRECTORY", "APPEND", "PROPERTY", "CMAKE_CONFIGURE_DEPENDS", "cmake.toml"); + } else { + cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY"); + } if (project.project_msvc_runtime != parser::msvc_last) { cmd("if")("NOT", "DEFINED", "CMAKE_MSVC_RUNTIME_LIBRARY"); @@ -785,12 +789,14 @@ void generate_cmake(const char *path, const parser::Project *parent_project) { create_file(cmkr_include, resources::cmkr); } } else { - // clang-format off comment("Create a configure-time dependency on cmake.toml to improve IDE support"); cmd("if")("CMKR_ROOT_PROJECT"); + if (project.cmake_minimum_version(3, 0)) { + cmd("set_property")("DIRECTORY", "APPEND", "PROPERTY", "CMAKE_CONFIGURE_DEPENDS", "cmake.toml"); + } else { cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY"); + } cmd("endif")().endl(); - // clang-format on } // TODO: remove support and replace with global compile-features