Merge pull request #4290 from thxkiwi/PR_issue_4287

Problem: (Windows) /GL /LTCG breaks builds when the compiler/linker o…
This commit is contained in:
Luca Boccassi 2021-10-29 00:30:24 +01:00 committed by GitHub
commit bddd0bc690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 7 deletions

View File

@ -891,13 +891,6 @@ if(MSVC)
string(REGEX REPLACE "/Z.[^:]" "/Z7 " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE "/Z.[^:]" "/Z7 " CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
# Optimization flags. http://msdn.microsoft.com/en-us/magazine/cc301698.aspx
if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GL")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LTCG")
endif()
endif()
# -----------------------------------------------------------------------------
@ -1319,6 +1312,27 @@ if(MSVC)
VS_GLOBAL_RunCodeAnalysis true)
endfunction()
if(BUILD_SHARED)
# Whole Program Optimization flags. http://msdn.microsoft.com/en-us/magazine/cc301698.aspx
#
# "Finally, there's the subject of libraries. It's possible to create .LIB
# files with code in its IL form. The linker will happily work with these
# .LIB files. Be aware that these libraries will be tied to a specific
# version of the compiler and linker. If you distribute these libraries,
# you'll need to update them if Microsoft changes the format of IL in a
# future release."
#
# /GL and /LTCG can cause problems when libraries built with different
# versions of compiler are later linked into an executable while /LTCG is active.
# https://social.msdn.microsoft.com/Forums/vstudio/en-US/5c102025-c254-4f02-9a51-c775c6cc9f4b/problem-with-ltcg-when-building-a-static-library-in-vs2005?forum=vcgeneral
#
# For this reason, enable only when building a "Release" (e.g. non-DEBUG) DLL.
if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GL")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LTCG")
endif()
add_library(libzmq SHARED ${sources} ${public_headers} ${html-docs} ${readme-docs}
${CMAKE_CURRENT_BINARY_DIR}/NSIS.template.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
if(ENABLE_ANALYSIS)

15
RELICENSE/thxkiwi.md Normal file
View File

@ -0,0 +1,15 @@
# Permission to Relicense under MPLv2 or any other share-alike OSI approved license chosen by the current ZeroMQ BDFL
This is a statement by MICHAEL NGARIMU
that grants permission to relicense its copyrights in the libzmq C++
library (ZeroMQ) under the Mozilla Public License v2 (MPLv2) or any other
share-alike Open Source Initiative approved license chosen by the current
ZeroMQ BDFL (Benevolent Dictator for Life).
A portion of the commits made by the Github handle "thxkiwi", with
commit author "Michael Ngarimu <michael@thx.com>", are copyright of Michael Ngarimu.
This document hereby grants the libzmq project team to relicense libzmq,
including all past, present and future contributions of the author listed above.
Michael Ngarimu
2021/10/28