mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
CMakeAddFortranSubdirectory: Declare MinGW import libraries as byproducts
The MinGW external project produces the import libraries of the imported targets, but did not declare them, so Ninja failed with "missing and no known rule to make it". Declare them as byproducts, and pass --clean-first to the inner build when any of them is missing, since cleaning the outer project deletes them but the inner build would otherwise consider itself up to date and not relink. Closes: #28239
This commit is contained in:
1 parent
4e0fa8da34
commit
bf00790cfb
2 files changed
+17
-1
No files matched your search
@@ -237,6 +237,12 @@ function(cmake_add_fortran_subdirectory subdir)
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${${dir_var}}" ABSOLUTE)
|
||||
endif()
|
||||
endforeach()
|
||||
# list the import libraries produced by the external project so that
|
||||
# generators like Ninja know which rule creates them
|
||||
set(byproducts)
|
||||
foreach(lib IN LISTS libraries)
|
||||
list(APPEND byproducts "${library_dir}/lib${lib}.lib")
|
||||
endforeach()
|
||||
# create build and configure wrapper scripts
|
||||
_setup_mingw_config_and_build("${source_dir}" "${build_dir}")
|
||||
# create the external project
|
||||
@@ -248,6 +254,7 @@ function(cmake_add_fortran_subdirectory subdir)
|
||||
BUILD_COMMAND ${CMAKE_COMMAND}
|
||||
-P ${build_dir}/build_mingw.cmake
|
||||
BUILD_ALWAYS 1
|
||||
BUILD_BYPRODUCTS ${byproducts}
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
# create imported targets for all libraries
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
set(ENV{PATH} "@MINGW_PATH@\;$ENV{PATH}")
|
||||
execute_process(COMMAND "@CMAKE_COMMAND@" --build . )
|
||||
# rebuild from scratch if a byproduct was removed, e.g. by a clean of
|
||||
# the outer project, because the inner build would consider itself up to date
|
||||
set(byproducts "@byproducts@")
|
||||
set(clean_first "")
|
||||
foreach(byproduct IN LISTS byproducts)
|
||||
if(NOT EXISTS "${byproduct}")
|
||||
set(clean_first --clean-first)
|
||||
endif()
|
||||
endforeach()
|
||||
execute_process(COMMAND "@CMAKE_COMMAND@" --build . ${clean_first})
|
||||
Reference in new issue
Block a user