Skip to content

Commit 41b7d33

Browse files
fanc999-1kjellahl
authored andcommitted
build: Actually support MSVC static builds
Apply -DLIBSIGCXX_STATIC as appropriate when we request a static build to be done for the Meson and NMake builds, and skip building the version .rc file if a static build is requested. For the NMake builds, separate the build artifacts from the static and shared builds. The CMake builds are not updated here as it always assumes a shared build, nor are the autotools builds since it is not used for Visual Studio builds at all.
1 parent a23cdc4 commit 41b7d33

File tree

6 files changed

+87
-25
lines changed

6 files changed

+87
-25
lines changed

MSVC_NMake/build-rules-msvc.mak

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@
1313
# $(CC)|$(CXX) $(cflags) /Fo$(destdir) /c @<<
1414
# $<
1515
# <<
16-
{..\sigc++\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.obj:
16+
{..\sigc++\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\}.obj:
1717
@if not exist .\sigc++config.h if not exist ..\untracked\MSVC_NMake\sigc++config.h $(MAKE) /f Makefile.vc CFG=$(CFG) sigc++config.h
1818
@if not exist $(@D)\ md $(@D)
1919
$(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(@D)\ /Fd$(@D)\ /c @<<
2020
$<
2121
<<
2222

23-
{..\sigc++\functors\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.obj:
23+
{..\sigc++\functors\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\}.obj:
2424
@if not exist .\sigc++config.h if not exist ..\untracked\MSVC_NMake\sigc++config.h $(MAKE) /f Makefile.vc CFG=$(CFG) sigc++config.h
2525
@if not exist $(@D)\ md $(@D)
2626
$(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(@D)\ /Fd$(@D)\ /c @<<
2727
$<
2828
<<
2929

30-
{.}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.res:
30+
{.}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\}.res:
3131
@if not exist $(@D)\ md $(@D)
3232
rc /fo$@ $<
3333

34-
{..\untracked\MSVC_NMake\}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.res:
34+
{..\untracked\MSVC_NMake\}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\}.res:
3535
@if not exist $(@D)\ md $(@D)
3636
rc /fo$@ $<
3737

@@ -42,13 +42,20 @@ $<
4242
# $(dependent_objects)
4343
# <<
4444
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
45+
!ifdef STATIC
46+
$(LIBSIGC_LIB): $(libsigc_OBJS)
47+
lib $(ARFLAGS) -out:$@ @<<
48+
$(libsigc_OBJS)
49+
<<
50+
!else
4551
$(LIBSIGC_LIB): $(LIBSIGC_DLL)
4652

47-
$(LIBSIGC_DLL): $(sigc_dll_OBJS)
53+
$(LIBSIGC_DLL): $(libsigc_OBJS)
4854
link /DLL $(LDFLAGS) /implib:$(LIBSIGC_LIB) -out:$@ @<<
49-
$(sigc_dll_OBJS)
55+
$(libsigc_OBJS)
5056
<<
5157
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
58+
!endif
5259

5360
# Rules for linking Executables
5461
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
@@ -65,13 +72,13 @@ clean:
6572
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.ilk
6673
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exp
6774
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.lib
68-
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests\*.obj
69-
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests\*.pdb
70-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-examples\*.obj
71-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-examples\*.pdb
72-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc\*.res
73-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc\*.obj
74-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc\*.pdb
75-
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests rd vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests
76-
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\sigc-examples
77-
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\sigc
75+
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR) del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR)\*.obj
76+
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR) del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR)\*.pdb
77+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_EX_INTDIR)\*.obj
78+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_EX_INTDIR)\*.pdb
79+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\*.res
80+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\*.obj
81+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\*.pdb
82+
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR) rd vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR)
83+
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_EX_INTDIR)
84+
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)

MSVC_NMake/config-msvc.mak

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ BASE_INCLUDES = /I$(PREFIX)\include
88
LIBSIGC_MAJOR_VERSION = 3
99
LIBSIGC_MINOR_VERSION = 0
1010

11+
!ifdef STATIC
12+
LIBSIGC_INTDIR = sigc-static
13+
SIGC_EX_INTDIR = sigc-examples-static
14+
SIGC_TESTS_INTDIR = sigc-tests-static
15+
!else
16+
LIBSIGC_INTDIR = sigc
17+
SIGC_EX_INTDIR = sigc-examples
18+
SIGC_TESTS_INTDIR = sigc-tests
19+
!endif
20+
1121
!if "$(CFG)" == "debug" || "$(CFG)" == "Debug"
1222
DEBUG_SUFFIX = -d
1323
!else
@@ -18,6 +28,11 @@ LIBSIGCPP_DEFINES = /DSIGC_BUILD
1828

1929
SIGCPP_BASE_CFLAGS = /I.. /I. /I..\untracked\MSVC_NMake /std:c++17 /EHsc $(CFLAGS)
2030

31+
# Define LIBSIGCXX_STATIC everywhere for static builds
32+
!ifdef STATIC
33+
SIGCPP_BASE_CFLAGS = $(SIGCPP_BASE_CFLAGS) /DLIBSIGCXX_STATIC
34+
!endif
35+
2136
LIBSIGC_INT_SOURCES = $(sigc_sources_cc:/=\)
2237
LIBSIGC_INT_HDRS = $(sigc_public_h:/=\)
2338

@@ -35,8 +50,12 @@ LIBSIGC_LIBNAME = sigc-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBSIGC_MAJOR_VERSION)_$(
3550
LIBSIGC_DLLNAME = $(LIBSIGC_LIBNAME)
3651
!endif
3752

53+
!ifdef STATIC
54+
LIBSIGC_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME)-static.lib
55+
!else
3856
LIBSIGC_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_DLLNAME).dll
3957
LIBSIGC_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).lib
58+
!endif
4059

4160
# If your Boost libraries are built as DLLs, use BOOST_DLL=1 in your NMake command line
4261
!ifdef BOOST_DLL

MSVC_NMake/create-lists-msvc.mak

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,40 @@ NULL=
3535

3636
# For libsigc++
3737

38-
!if [call create-lists.bat header sigc.mak sigc_dll_OBJS]
38+
!if [call create-lists.bat header sigc.mak libsigc_OBJS]
3939
!endif
4040

41-
!if [for %c in ($(sigc_sources_cc)) do @if "%~xc" == ".cc" @call create-lists.bat file sigc.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc\%~nc.obj]
41+
!if [for %c in ($(sigc_sources_cc)) do @if "%~xc" == ".cc" @call create-lists.bat file sigc.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(LIBSIGC_INTDIR)\%~nc.obj]
4242
!endif
4343

44-
!if [@call create-lists.bat file sigc.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc\sigc.res]
44+
# No point linking in version resource for static builds
45+
!ifndef STATIC
46+
!if [@call create-lists.bat file sigc.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(LIBSIGC_INTDIR)\sigc.res]
47+
!endif
4548
!endif
4649

4750
!if [call create-lists.bat footer sigc.mak]
4851
!endif
4952

53+
!ifdef STATIC
54+
# start of static executables
55+
!if [for %d in (examples tests) do @call create-lists.bat header sigc.mak libsigc_%d & @(for %s in (..\%d\*.cc) do @if not "%~ns" == "testutilities" if not "%~ns" == "benchmark" call create-lists.bat file sigc.mak vs$(VSVER)\$(CFG)\$(PLAT)\%~ns-static.exe) & @call create-lists.bat footer sigc.mak]
56+
!endif
57+
58+
!if [call create-lists.bat header sigc.mak libsigc_benchmark & @for %s in (..\tests\benchmark.cc) do @(call create-lists.bat file sigc.mak vs$(VSVER)\$(CFG)\$(PLAT)\%~ns-static.exe) & @call create-lists.bat footer sigc.mak]
59+
!endif
60+
61+
!if [for %d in (examples tests) do @for %s in (..\%d\*.cc) do @if not "%~ns" == "benchmark" echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-%d-static\%~ns.obj: %s>>sigc.mak & @echo. @if not exist ^$(@D)\ md ^$(@D)>>sigc.mak & @echo. ^$(CXX) ^$(SIGCPP_CFLAGS) /Fo^$(@D)\ /Fd^$(@D)\ ^$** /c>>sigc.mak & @echo.>>sigc.mak]
62+
!endif
63+
64+
!if [for %s in (..\examples\*.cc) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns-static.exe: ^$(LIBSIGC_LIB) vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(SIGC_EX_INTDIR)\%~ns.obj>>sigc.mak & @echo. link ^$(LDFLAGS) ^$** /out:^$@>>sigc.mak & @echo.>>sigc.mak]
65+
!endif
66+
67+
!if [for %s in (..\tests\*.cc) do @if not "%~ns" == "testutilities" echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns-static.exe: ^$(LIBSIGC_LIB) vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(SIGC_TESTS_INTDIR)\%~ns.obj vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(SIGC_TESTS_INTDIR)\testutilities.obj>>sigc.mak & @echo. link ^$(LDFLAGS) ^$** /out:^$@>>sigc.mak & @echo.>>sigc.mak]
68+
!endif
69+
# end of static executables
70+
!else
71+
# start of shared executables
5072
!if [for %d in (examples tests) do @call create-lists.bat header sigc.mak libsigc_%d & @(for %s in (..\%d\*.cc) do @if not "%~ns" == "testutilities" if not "%~ns" == "benchmark" call create-lists.bat file sigc.mak vs$(VSVER)\$(CFG)\$(PLAT)\%~ns.exe) & @call create-lists.bat footer sigc.mak]
5173
!endif
5274

@@ -56,13 +78,16 @@ NULL=
5678
!if [for %d in (examples tests) do @for %s in (..\%d\*.cc) do @if not "%~ns" == "benchmark" echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-%d\%~ns.obj: %s>>sigc.mak & @echo. @if not exist ^$(@D)\ md ^$(@D)>>sigc.mak & @echo. ^$(CXX) ^$(SIGCPP_CFLAGS) /Fo^$(@D)\ /Fd^$(@D)\ ^$** /c>>sigc.mak & @echo.>>sigc.mak]
5779
!endif
5880

59-
!if [for %s in (..\tests\benchmark.cc) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-tests\%~ns.obj: %s>>sigc.mak & @echo. @if not exist ^$(@D)\ md ^$(@D)>>sigc.mak & @echo. ^$(CXX) ^$(SIGCPP_BENCHMARK_CFLAGS) /Fo^$(@D)\ /Fd^$(@D)\ ^$** /c>>sigc.mak & @echo.>>sigc.mak]
81+
!if [for %s in (..\examples\*.cc) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns.exe: ^$(LIBSIGC_LIB) vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(SIGC_EX_INTDIR)\%~ns.obj>>sigc.mak & @echo. link ^$(LDFLAGS) ^$** /out:^$@>>sigc.mak & @echo.>>sigc.mak]
82+
!endif
83+
84+
!if [for %s in (..\tests\*.cc) do @if not "%~ns" == "testutilities" echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns.exe: ^$(LIBSIGC_LIB) vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(SIGC_TESTS_INTDIR)\%~ns.obj vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(SIGC_TESTS_INTDIR)\testutilities.obj>>sigc.mak & @echo. link ^$(LDFLAGS) ^$** /out:^$@>>sigc.mak & @echo.>>sigc.mak]
6085
!endif
6186

62-
!if [for %s in (..\examples\*.cc) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns.exe: ^$(LIBSIGC_LIB) vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-examples\%~ns.obj>>sigc.mak & @echo. link ^$(LDFLAGS) ^$** /out:^$@>>sigc.mak & @echo.>>sigc.mak]
87+
# end of shared executables
6388
!endif
6489

65-
!if [for %s in (..\tests\*.cc) do @if not "%~ns" == "testutilities" echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns.exe: ^$(LIBSIGC_LIB) vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-tests\%~ns.obj vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-tests\testutilities.obj>>sigc.mak & @echo. link ^$(LDFLAGS) ^$** /out:^$@>>sigc.mak & @echo.>>sigc.mak]
90+
!if [for %s in (..\tests\benchmark.cc) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(SIGC_TESTS_INTDIR)\%~ns.obj: %s>>sigc.mak & @echo. @if not exist ^$(@D)\ md ^$(@D)>>sigc.mak & @echo. ^$(CXX) ^$(SIGCPP_BENCHMARK_CFLAGS) /Fo^$(@D)\ /Fd^$(@D)\ ^$** /c>>sigc.mak & @echo.>>sigc.mak]
6691
!endif
6792

6893
!include sigc.mak

MSVC_NMake/info-msvc.mak

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ all-build-info:
66
@echo Build info
77
@echo ---------
88
@echo Build Type: $(CFG)
9+
@if not "$(STATIC)" == "" echo Library Build Type: static
10+
@if "$(STATIC)" == "" echo Library Build Type: DLL
911

1012
help:
1113
@echo.
1214
@echo ==============================
1315
@echo Building libsigc++ Using NMake
1416
@echo ==============================
15-
@echo nmake /f Makefile.vc CFG=[release^|debug] ^<PREFIX=PATH^>
17+
@echo nmake /f Makefile.vc CFG=[release^|debug] ^<PREFIX=PATH^> ^<STATIC=1^>
1618
@echo.
1719
@echo Where:
1820
@echo ------
@@ -24,6 +26,10 @@ help:
2426
@echo where ^$(short_vs_ver) is 15 for VS 2017 and so on; and
2527
@echo ^$(platform) is Win32 for 32-bit builds and x64 for x64 builds.
2628
@echo.
29+
@echo STATIC: Optional, enable to build static libsigc++. Define
30+
@echo LIBSIGCXX_STATIC in the compiler flags to use the static build of
31+
@echo libsigc++.
32+
@echo.
2733
@echo ======
2834
@echo A 'clean' target is supported to remove all generated files, intermediate
2935
@echo object files and binaries for the specified configuration.

meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ if is_msvc
216216
cpp_compiler.get_supported_arguments(disable_warnings_list),
217217
language: 'cpp'
218218
)
219+
if is_msvc_static
220+
add_project_arguments(['-DLIBSIGCXX_STATIC'], language: 'cpp')
221+
endif
219222
endif
220223

221224
# Configure files

sigc++/meson.build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ endif
8080
# Build the .rc file for Windows builds and link to it
8181
if host_machine.system() == 'windows'
8282
windows = import('windows')
83-
sigc_res = windows.compile_resources(sigc_rc)
84-
extra_sigc_objects += sigc_res
83+
if get_option('default_library') == 'shared'
84+
sigc_res = windows.compile_resources(sigc_rc)
85+
extra_sigc_objects += sigc_res
86+
endif
8587
endif
8688

8789
extra_include_dirs = ['..']

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy