Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: MSVC lib names are too complex #4195

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1297,11 +1297,24 @@ option(BUILD_SHARED "Whether or not to build the shared object" ON)
option(BUILD_STATIC "Whether or not to build the static archive" ON)

if(MSVC)
option(ZMQ_MSVC_SHORT_LIB_NAMES "Use short lib names (e.g. libzmq.lib/dll, libzmq-static.lib) for MSVC" OFF)
if(ZMQ_MSVC_SHORT_LIB_NAMES)
set(ZMQ_SHARED_RELEASE_POSTFIX "")
set(ZMQ_SHARED_DEBUG_POSTFIX "d")
set(ZMQ_STATIC_RELEASE_POSTFIX "-static")
set(ZMQ_STATIC_DEBUG_POSTFIX "-staticd")
else()
set(ZMQ_SHARED_RELEASE_POSTFIX "${MSVC_TOOLSET}-mt-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}")
set(ZMQ_SHARED_DEBUG_POSTFIX "${MSVC_TOOLSET}-mt-gd-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}")
set(ZMQ_STATIC_RELEASE_POSTFIX "${MSVC_TOOLSET}-mt-s-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}")
set(ZMQ_STATIC_DEBUG_POSTFIX "${MSVC_TOOLSET}-mt-sgd-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}")
endif()

# Suppress linker warnings caused by #ifdef omission of file content.
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
set(PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(PDB_NAME
"lib${ZMQ_OUTPUT_BASENAME}${MSVC_TOOLSET}-mt-gd-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}")
"lib${ZMQ_OUTPUT_BASENAME}${ZMQ_SHARED_DEBUG_POSTFIX}")
function(enable_vs_guideline_checker target)
set_target_properties(
${target} PROPERTIES VS_GLOBAL_EnableCppCoreCheck true VS_GLOBAL_CodeAnalysisRuleSet CppCoreCheckRules.ruleset
Expand All @@ -1316,11 +1329,10 @@ if(MSVC)
set_target_properties(
libzmq
PROPERTIES PUBLIC_HEADER "${public_headers}"
RELEASE_POSTFIX "${MSVC_TOOLSET}-mt-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
RELWITHDEBINFO_POSTFIX
"${MSVC_TOOLSET}-mt-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
MINSIZEREL_POSTFIX "${MSVC_TOOLSET}-mt-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
DEBUG_POSTFIX "${MSVC_TOOLSET}-mt-gd-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
RELEASE_POSTFIX "${ZMQ_SHARED_RELEASE_POSTFIX}"
RELWITHDEBINFO_POSTFIX "${ZMQ_SHARED_RELEASE_POSTFIX}"
MINSIZEREL_POSTFIX "${ZMQ_SHARED_RELEASE_POSTFIX}"
DEBUG_POSTFIX "${ZMQ_SHARED_DEBUG_POSTFIX}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
COMPILE_DEFINITIONS "DLL_EXPORT"
OUTPUT_NAME "lib${ZMQ_OUTPUT_BASENAME}")
Expand All @@ -1334,12 +1346,10 @@ if(MSVC)
set_target_properties(
libzmq-static
PROPERTIES PUBLIC_HEADER "${public_headers}"
RELEASE_POSTFIX "${MSVC_TOOLSET}-mt-s-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
RELWITHDEBINFO_POSTFIX
"${MSVC_TOOLSET}-mt-s-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
MINSIZEREL_POSTFIX
"${MSVC_TOOLSET}-mt-s-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
DEBUG_POSTFIX "${MSVC_TOOLSET}-mt-sgd-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
RELEASE_POSTFIX "${ZMQ_STATIC_RELEASE_POSTFIX}"
RELWITHDEBINFO_POSTFIX "${ZMQ_STATIC_RELEASE_POSTFIX}"
MINSIZEREL_POSTFIX "${ZMQ_STATIC_RELEASE_POSTFIX}"
DEBUG_POSTFIX "${ZMQ_STATIC_DEBUG_POSTFIX}"
COMPILE_FLAGS "/DZMQ_STATIC"
OUTPUT_NAME "lib${ZMQ_OUTPUT_BASENAME}")
endif()
Expand Down