diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 0bd963751ce..76319bab9a6 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -392,9 +392,23 @@ function _get_configs_for_windows(package, configs, opt) elseif package:has_runtime("MDd") then table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL") end + + -- config about PDB if not opt._configs_str:find("CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY") then table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=pdb") end + -- shrink PDB file + -- ref: https://devblogs.microsoft.com/cppblog/shrink-my-program-database-pdb-file/ + if not opt._configs_str:find("CMAKE_EXE_LINKER_FLAGS") then + table.insert(configs, "-DCMAKE_EXE_LINKER_FLAGS=/opt:ref /opt:icf /pdbcompress") + end + if not opt._configs_str:find("CMAKE_SHARED_LINKER_FLAGS") then + table.insert(configs, "-DCMAKE_SHARED_LINKER_FLAGS=/opt:ref /opt:icf /pdbcompress") + end + if not opt._configs_str:find("CMAKE_STATIC_LINKER_FLAGS") then + table.insert(configs, "-DCMAKE_STATIC_LINKER_FLAGS=/opt:ref /opt:icf /pdbcompress") + end + _get_configs_for_generic(package, configs, opt) end