Skip to content

Commit

Permalink
Enable renaming the output shared binary (microsoft#1790)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Jul 2, 2021
1 parent 9acdf31 commit a08321b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ option(QUIC_TELEMETRY_ASSERTS "Enable telemetry asserts in release builds" OFF)
option(QUIC_USE_SYSTEM_LIBCRYPTO "Use system libcrypto if openssl TLS" OFF)
option(QUIC_DISABLE_POSIX_GSO "Disable GSO for systems that say they support it but don't" OFF)
set(QUIC_FOLDER_PREFIX "" CACHE STRING "Optional prefix for source group folders when using an IDE generator")
set(QUIC_LIBRARY_NAME "msquic" CACHE STRING "Override the output library name")

set(BUILD_SHARED_LIBS ${QUIC_BUILD_SHARED})

Expand Down
11 changes: 9 additions & 2 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ This script provides helpers for building msquic.
.PARAMETER ExtraArtifactDir
Add an extra classifier to the artifact directory to allow publishing alternate builds of same base library
.PARAMETER LibraryName
Renames the library to whatever is passed in
.EXAMPLE
build.ps1
Expand Down Expand Up @@ -179,7 +182,10 @@ param (
[switch]$UseSystemOpenSSLCrypto = $false,

[Parameter(Mandatory = $false)]
[string]$ExtraArtifactDir = ""
[string]$ExtraArtifactDir = "",

[Parameter(Mandatory = $false)]
[string]$LibraryName = "msquic"
)

Set-StrictMode -Version 'Latest'
Expand Down Expand Up @@ -340,6 +346,7 @@ function CMake-Generate {
if ($UseSystemOpenSSLCrypto) {
$Arguments += " -DQUIC_USE_SYSTEM_LIBCRYPTO=on"
}
$Arguments += " -DQUIC_LIBRARY_NAME=$LibraryName"
$Arguments += " ../../.."

CMake-Execute $Arguments
Expand Down Expand Up @@ -370,7 +377,7 @@ function CMake-Build {
CMake-Execute $Arguments

if ($IsWindows) {
Copy-Item (Join-Path $BuildDir "obj" $Config "msquic.lib") $ArtifactsDir
Copy-Item (Join-Path $BuildDir "obj" $Config "$LibraryName.lib") $ArtifactsDir
if ($SanitizeAddress -or ($PGO -and $Config -eq "Release")) {
Install-Module VSSetup -Scope CurrentUser -Force -SkipPublisherCheck
$VSInstallationPath = Get-VSSetupInstance | Select-VSSetupInstance -Latest -Require Microsoft.VisualStudio.Component.VC.Tools.x86.x64 | Select-Object -ExpandProperty InstallationPath
Expand Down
7 changes: 5 additions & 2 deletions src/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
# Licensed under the MIT License.

if(WIN32)
set(SOURCES winuser/dllmain.c winuser/msquic.rc $<TARGET_OBJECTS:MsQuicEtw_Resource>)
configure_file(winuser/msquic.rc.in ${CMAKE_CURRENT_BINARY_DIR}/msquic.rc )
configure_file(winuser/msquic.def.in ${CMAKE_CURRENT_BINARY_DIR}/msquic.def )
set(SOURCES winuser/dllmain.c ${CMAKE_CURRENT_BINARY_DIR}/msquic.rc $<TARGET_OBJECTS:MsQuicEtw_Resource>)
else()
set(SOURCES linux/init.c)
endif()

if(BUILD_SHARED_LIBS)
add_library(msquic SHARED ${SOURCES})
target_link_libraries(msquic PRIVATE core platform inc warnings)
set_target_properties(msquic PROPERTIES OUTPUT_NAME ${QUIC_LIBRARY_NAME})
else()
add_library(msquic_static STATIC static/empty.c)
target_link_libraries(msquic_static PRIVATE core platform inc)
Expand Down Expand Up @@ -203,7 +206,7 @@ if(WIN32)
target_link_libraries(msquic PUBLIC OneCoreUAP)
endif()
SET_TARGET_PROPERTIES(msquic
PROPERTIES LINK_FLAGS "/DEF:\"${CMAKE_CURRENT_SOURCE_DIR}/winuser/msquic.def\"")
PROPERTIES LINK_FLAGS "/DEF:\"${CMAKE_CURRENT_BINARY_DIR}/msquic.def\"")
elseif (CX_PLATFORM STREQUAL "linux")
SET_TARGET_PROPERTIES(msquic
PROPERTIES LINK_FLAGS "-Wl,--version-script=\"${CMAKE_CURRENT_SOURCE_DIR}/linux/exports.txt\"")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LIBRARY msquic
LIBRARY @QUIC_LIBRARY_NAME@

EXPORTS
MsQuicOpen
Expand Down
2 changes: 1 addition & 1 deletion src/bin/winuser/msquic.rc → src/bin/winuser/msquic.rc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

#define VER_FILETYPE VFT_DLL
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_ORIGINALFILENAME_STR "msquic.dll"
#define VER_ORIGINALFILENAME_STR "@QUIC_LIBRARY_NAME@.dll"

#include "msquic.ver"

0 comments on commit a08321b

Please sign in to comment.