diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 487595b0b0f..6e55c3c9a22 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -999,7 +999,6 @@ function(data_to_c add_custom_command( OUTPUT ${file_to} - COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path} COMMAND "$" ${file_from} ${file_to} DEPENDS ${file_from} datatoc) @@ -1026,7 +1025,6 @@ function(data_to_c_simple add_custom_command( OUTPUT ${_file_to} - COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path} COMMAND "$" ${_file_from} ${_file_to} DEPENDS ${_file_from} datatoc) @@ -1055,7 +1053,6 @@ function(glsl_to_c add_custom_command( OUTPUT ${_file_to} ${_file_meta} - COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path} COMMAND "$" ${_file_from} ${_file_tmp} ${_file_meta} COMMAND "$" ${_file_tmp} ${_file_to} DEPENDS ${_file_from} datatoc glsl_preprocess) diff --git a/source/blender/datatoc/datatoc.cc b/source/blender/datatoc/datatoc.cc index eac471f14ab..c741d35674f 100644 --- a/source/blender/datatoc/datatoc.cc +++ b/source/blender/datatoc/datatoc.cc @@ -10,6 +10,8 @@ #include #include #include +#include +#include // #define VERBOSE @@ -63,6 +65,19 @@ int main(int argc, char **argv) printf("Making C file <%s>\n", argv[2]); #endif + /* We make the required directories here rather than having the build system + * do the work for us, as having cmake do it leads to several thousand cmake + * instances being launched, leading to significant overhead, see pr #141404 + * for details. */ + std::filesystem::path parent_dir = std::filesystem::path(argv[2]).parent_path(); + std::error_code ec; + if (!std::filesystem::create_directories(parent_dir, ec)) { + if (ec) { + std::cerr << "Unable to create " << parent_dir << " : " << ec.message() << std::endl; + exit(1); + } + } + argv_len = int(strlen(argv[1])); for (i = 0; i < argv_len; i++) { if (argv[1][i] == '.') {