Index: cmake/modules/HandleLLVMOptions.cmake =================================================================== --- cmake/modules/HandleLLVMOptions.cmake +++ cmake/modules/HandleLLVMOptions.cmake @@ -354,10 +354,11 @@ append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) # Generate PDB even in release for profiling. - if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") + option(LLVM_ENABLE_PDB ON) + if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND LLVM_ENABLE_PDB) append("/Zi" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) - append("/DEBUG" CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) - endif (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") + append("/DEBUG /OPT:REF /OPT:ICF" CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) + endif() # /Zc:strictStrings is incompatible with VS12's (Visual Studio 2013's) # debug mode headers. Instead of only enabling them in VS2013's debug mode,