Skip to content

Commit 4a15d2b

Browse files
committed
Use CMAKE_CONFIGURE_DEPENDS when supported
1 parent 87c0295 commit 4a15d2b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/cmake_generator.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,11 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
761761
cmd("set_property")("GLOBAL", "PROPERTY", "USE_FOLDERS", "ON").endl();
762762

763763
comment("Create a configure-time dependency on cmake.toml to improve IDE support");
764-
cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY");
764+
if (project.cmake_minimum_version(3, 0)) {
765+
cmd("set_property")("DIRECTORY", "APPEND", "PROPERTY", "CMAKE_CONFIGURE_DEPENDS", "cmake.toml");
766+
} else {
767+
cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY");
768+
}
765769

766770
if (project.project_msvc_runtime != parser::msvc_last) {
767771
cmd("if")("NOT", "DEFINED", "CMAKE_MSVC_RUNTIME_LIBRARY");
@@ -785,12 +789,14 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
785789
create_file(cmkr_include, resources::cmkr);
786790
}
787791
} else {
788-
// clang-format off
789792
comment("Create a configure-time dependency on cmake.toml to improve IDE support");
790793
cmd("if")("CMKR_ROOT_PROJECT");
794+
if (project.cmake_minimum_version(3, 0)) {
795+
cmd("set_property")("DIRECTORY", "APPEND", "PROPERTY", "CMAKE_CONFIGURE_DEPENDS", "cmake.toml");
796+
} else {
791797
cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY");
798+
}
792799
cmd("endif")().endl();
793-
// clang-format on
794800
}
795801

796802
// TODO: remove support and replace with global compile-features

0 commit comments

Comments
 (0)