mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
cmake, ctest, cpack: Delay-load Windows system libraries
`cmake.exe`, `ctest.exe` and `cpack.exe` import several Windows system libraries directly, so the loader maps them, and the libraries they depend on, every time one of the tools starts. Many runs use none of them, including most `cmake -E` commands, which run many times in every build. When building with MSVC or clang-cl, link the three tools with `-DELAYLOAD` for these libraries so each one is loaded on first use. Issue: #28164
This commit is contained in:
1 parent
cfb3000e9e
commit
a14c8ff8ea
2 files changed
+15
No files matched your search
@@ -75,6 +75,8 @@ Fo = "Fo"
|
||||
ot = "ot"
|
||||
# Part of compiler executable name, e.g., `arm-unknown-nto-qnx6`, but also could be in a literal string.
|
||||
nto = "nto"
|
||||
# A Windows system library.
|
||||
secur = "secur"
|
||||
|
||||
[type.cpp.extend-identifiers]
|
||||
APPENDed = "APPENDed"
|
||||
|
||||
@@ -1445,6 +1445,19 @@ add_executable(cpack CPack/cpack.cxx)
|
||||
target_link_libraries(cpack PRIVATE CPackLib ManifestLib)
|
||||
list(APPEND _tools cpack)
|
||||
|
||||
if(MSVC)
|
||||
# Many runs of these tools, such as most "cmake -E" commands, use none
|
||||
# of these system libraries. Load them on first use instead of at
|
||||
# start-up.
|
||||
foreach(tool IN ITEMS cmake ctest cpack)
|
||||
foreach(dll IN ITEMS bcrypt crypt32 dbghelp iphlpapi ole32 oleaut32
|
||||
powrprof psapi secur32 shell32 user32 ws2_32)
|
||||
target_link_options(${tool} PRIVATE "-DELAYLOAD:${dll}.dll")
|
||||
endforeach()
|
||||
target_link_libraries(${tool} PRIVATE delayimp)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Curses GUI
|
||||
if(BUILD_CursesDialog)
|
||||
add_subdirectory(CursesDialog)
|
||||
|
||||
Reference in new issue
Block a user