From 1660e2536f2e4695d4d10be58ebe56ebfc1d43ca Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Fri, 30 Jun 2023 00:54:10 +0200 Subject: [PATCH] cmake: Add flags for reproducible builds on Windows Compiler and linker flags for reproducible builds on Windows were omitted from the recent CMake rework in error. This commit adds those flags back. --- cmake/windows/compilerconfig.cmake | 11 +++++++++-- cmake/windows/helpers.cmake | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmake/windows/compilerconfig.cmake b/cmake/windows/compilerconfig.cmake index 54f0e7c40..cd106609e 100644 --- a/cmake/windows/compilerconfig.cmake +++ b/cmake/windows/compilerconfig.cmake @@ -33,8 +33,15 @@ if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348) "Please download and install the most recent Windows SDK.") endif() +set(_obs_msvc_c_options /Brepro /MP /permissive- /Zc:__cplusplus /Zc:preprocessor) + +set(_obs_msvc_cpp_options /Brepro /MP /permissive- /Zc:__cplusplus /Zc:preprocessor) + add_compile_options( - /W3 /utf-8 "$<$:/MP>" "$<$:/MP>" + /W3 + /utf-8 + "$<$:${_obs_msvc_c_options}>" + "$<$:${_obs_msvc_cpp_options}>" "$<$:${_obs_clang_c_options}>" "$<$:${_obs_clang_cxx_options}>") @@ -42,7 +49,7 @@ add_compile_definitions(UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO $<$:_DEBUG>) add_link_options("$<$>:/OPT\:REF>" "$<$:/INCREMENTAL\:NO>" - "$<$:/INCREMENTAL\:NO>" "$<$:/OPT\:ICF>") + "$<$:/INCREMENTAL\:NO>" "$<$:/OPT\:ICF>" /Brepro) if(CMAKE_COMPILE_WARNING_AS_ERROR) add_link_options(/WX) diff --git a/cmake/windows/helpers.cmake b/cmake/windows/helpers.cmake index 432616b0b..cdd4fcacd 100644 --- a/cmake/windows/helpers.cmake +++ b/cmake/windows/helpers.cmake @@ -159,6 +159,7 @@ function(set_target_properties_obs target) set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target}) endif() + target_link_options(${target} PRIVATE "/PDBALTPATH:$") target_install_resources(${target}) endfunction()