From bc69a512250b58c2b998bd49488acb34abdc73b3 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 26 Jun 2023 15:20:53 +0800 Subject: [PATCH 1/6] meson: Disallow default_library == 'both' on Visual Studio We need different defines/cflags for building static and shared builds of libsigc++, so we can't really support default_library = 'both' for libsigc++ without much retinkering. So, just disallow such builds at least for now. Also, save up whether we are attempting a static build in the Visual Studio build. --- meson.build | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/meson.build b/meson.build index e4630fe..3190d6e 100644 --- a/meson.build +++ b/meson.build @@ -43,6 +43,18 @@ cpp_compiler = meson.get_compiler('cpp') is_msvc = cpp_compiler.get_id() == 'msvc' python3 = find_program('python3', version: '>=3.5') +# MSVC: We currently do not support shared and static builds at the, +# same time, since we need different defines/cflags for proper +# linking. +if is_msvc + if get_option('default_library') == 'both' + error('-Ddefault_library=both is currently not supported for Visual Studio') + endif + is_msvc_static = get_option('default_library') == 'static' +else + is_msvc_static = false +endif + # Do we build from a git repository? # Suppose we do if and only if the meson.build file is tracked by git. cmd_py = ''' From caebcd51b703b0aa348142843532411f091ef78c Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 26 Jun 2023 15:22:10 +0800 Subject: [PATCH 2/6] build: Drop _WINDLL from sigc++config.h.[in|meson|cmake] ...and add a new check macro LIBSIGCXX_STATIC, to use the appropriate macros to build and link against libsigc++. Drop this from the build files as well. --- MSVC_NMake/config-msvc.mak | 2 +- sigc++/meson.build | 2 +- sigc++config.h.cmake | 6 ++++-- sigc++config.h.in | 4 +++- sigc++config.h.meson | 4 +++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak index 86ee18b..a8c5280 100644 --- a/MSVC_NMake/config-msvc.mak +++ b/MSVC_NMake/config-msvc.mak @@ -14,7 +14,7 @@ DEBUG_SUFFIX = -d DEBUG_SUFFIX = !endif -LIBSIGCPP_DEFINES = /DSIGC_BUILD /D_WINDLL +LIBSIGCPP_DEFINES = /DSIGC_BUILD SIGCPP_BASE_CFLAGS = /I.. /I. /I..\untracked\MSVC_NMake /std:c++17 /EHsc $(CFLAGS) diff --git a/sigc++/meson.build b/sigc++/meson.build index 9d9561f..3b3cfeb 100644 --- a/sigc++/meson.build +++ b/sigc++/meson.build @@ -74,7 +74,7 @@ extra_sigc_objects = [] # Make sure we are exporting the symbols from the DLL if is_msvc - extra_sigc_cppflags += ['-DSIGC_BUILD', '-D_WINDLL'] + extra_sigc_cppflags += ['-DSIGC_BUILD'] endif # Build the .rc file for Windows builds and link to it diff --git a/sigc++config.h.cmake b/sigc++config.h.cmake index 74d348a..2c7e943 100644 --- a/sigc++config.h.cmake +++ b/sigc++config.h.cmake @@ -16,7 +16,9 @@ # if defined(_MSC_VER) # define SIGC_MSC 1 # define SIGC_WIN32 1 -# define SIGC_DLL 1 +# ifndef LIBSIGCXX_STATIC +# define SIGC_DLL 1 +# endif # elif defined(__CYGWIN__) # define SIGC_CONFIGURE 1 # elif defined(__MINGW32__) @@ -54,7 +56,7 @@ #endif /* !SIGC_MSC */ #ifdef SIGC_DLL -# if defined(SIGC_BUILD) && defined(_WINDLL) +# ifdef SIGC_BUILD # define SIGC_API __declspec(dllexport) # elif !defined(SIGC_BUILD) # define SIGC_API __declspec(dllimport) diff --git a/sigc++config.h.in b/sigc++config.h.in index a82a86b..573bc36 100644 --- a/sigc++config.h.in +++ b/sigc++config.h.in @@ -16,7 +16,9 @@ #if defined(_MSC_VER) #define SIGC_MSC 1 #define SIGC_WIN32 1 +#ifndef LIBSIGCXX_STATIC #define SIGC_DLL 1 +#endif #elif defined(__CYGWIN__) #define SIGC_CONFIGURE 1 #elif defined(__MINGW32__) @@ -54,7 +56,7 @@ #endif /* !SIGC_MSC */ #ifdef SIGC_DLL -#if defined(SIGC_BUILD) && defined(_WINDLL) +#ifdef SIGC_BUILD #define SIGC_API __declspec(dllexport) #elif !defined(SIGC_BUILD) #define SIGC_API __declspec(dllimport) diff --git a/sigc++config.h.meson b/sigc++config.h.meson index 47cbd80..3027b26 100644 --- a/sigc++config.h.meson +++ b/sigc++config.h.meson @@ -19,7 +19,9 @@ #if defined(_MSC_VER) #define SIGC_MSC 1 #define SIGC_WIN32 1 +#ifndef LIBSIGCXX_STATIC #define SIGC_DLL 1 +#endif #elif defined(__CYGWIN__) #define SIGC_CONFIGURE 1 #elif defined(__MINGW32__) @@ -57,7 +59,7 @@ #endif /* !SIGC_MSC */ #ifdef SIGC_DLL -#if defined(SIGC_BUILD) && defined(_WINDLL) +#ifdef SIGC_BUILD #define SIGC_API __declspec(dllexport) #elif !defined(SIGC_BUILD) #define SIGC_API __declspec(dllimport) From 9ebcba45ccc89a29ca2acfcd34cdbc21c64cb5b1 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 26 Jun 2023 11:25:42 +0800 Subject: [PATCH 3/6] 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. --- MSVC_NMake/build-rules-msvc.mak | 39 +++++++++++++++++++------------- MSVC_NMake/config-msvc.mak | 19 ++++++++++++++++ MSVC_NMake/create-lists-msvc.mak | 37 +++++++++++++++++++++++++----- MSVC_NMake/info-msvc.mak | 8 ++++++- meson.build | 3 +++ sigc++/meson.build | 6 +++-- 6 files changed, 87 insertions(+), 25 deletions(-) diff --git a/MSVC_NMake/build-rules-msvc.mak b/MSVC_NMake/build-rules-msvc.mak index fe5a587..74e51d9 100644 --- a/MSVC_NMake/build-rules-msvc.mak +++ b/MSVC_NMake/build-rules-msvc.mak @@ -13,25 +13,25 @@ # $(CC)|$(CXX) $(cflags) /Fo$(destdir) /c @<< # $< # << -{..\sigc++\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.obj: +{..\sigc++\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\}.obj: @if not exist .\sigc++config.h if not exist ..\untracked\MSVC_NMake\sigc++config.h $(MAKE) /f Makefile.vc CFG=$(CFG) sigc++config.h @if not exist $(@D)\ md $(@D) $(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(@D)\ /Fd$(@D)\ /c @<< $< << -{..\sigc++\functors\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.obj: +{..\sigc++\functors\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\}.obj: @if not exist .\sigc++config.h if not exist ..\untracked\MSVC_NMake\sigc++config.h $(MAKE) /f Makefile.vc CFG=$(CFG) sigc++config.h @if not exist $(@D)\ md $(@D) $(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(@D)\ /Fd$(@D)\ /c @<< $< << -{.}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.res: +{.}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\}.res: @if not exist $(@D)\ md $(@D) rc /fo$@ $< -{..\untracked\MSVC_NMake\}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.res: +{..\untracked\MSVC_NMake\}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\}.res: @if not exist $(@D)\ md $(@D) rc /fo$@ $< @@ -42,13 +42,20 @@ $< # $(dependent_objects) # << # @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2 +!ifdef STATIC +$(LIBSIGC_LIB): $(libsigc_OBJS) + lib $(ARFLAGS) -out:$@ @<< +$(libsigc_OBJS) +<< +!else $(LIBSIGC_LIB): $(LIBSIGC_DLL) -$(LIBSIGC_DLL): $(sigc_dll_OBJS) +$(LIBSIGC_DLL): $(libsigc_OBJS) link /DLL $(LDFLAGS) /implib:$(LIBSIGC_LIB) -out:$@ @<< -$(sigc_dll_OBJS) +$(libsigc_OBJS) << @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2 +!endif # Rules for linking Executables # Format is as follows (the mt command is needed for MSVC 2005/2008 builds): @@ -65,13 +72,13 @@ clean: @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.ilk @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exp @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.lib - @-if exist vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests\*.obj - @-if exist vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests\*.pdb - @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-examples\*.obj - @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-examples\*.pdb - @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc\*.res - @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc\*.obj - @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc\*.pdb - @-if exist vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests rd vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests - @-rd vs$(VSVER)\$(CFG)\$(PLAT)\sigc-examples - @-rd vs$(VSVER)\$(CFG)\$(PLAT)\sigc + @-if exist vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR) del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR)\*.obj + @-if exist vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR) del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR)\*.pdb + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_EX_INTDIR)\*.obj + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_EX_INTDIR)\*.pdb + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\*.res + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\*.obj + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR)\*.pdb + @-if exist vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR) rd vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_TESTS_INTDIR) + @-rd vs$(VSVER)\$(CFG)\$(PLAT)\$(SIGC_EX_INTDIR) + @-rd vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_INTDIR) diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak index a8c5280..52c72a0 100644 --- a/MSVC_NMake/config-msvc.mak +++ b/MSVC_NMake/config-msvc.mak @@ -8,6 +8,16 @@ BASE_INCLUDES = /I$(PREFIX)\include LIBSIGC_MAJOR_VERSION = 3 LIBSIGC_MINOR_VERSION = 0 +!ifdef STATIC +LIBSIGC_INTDIR = sigc-static +SIGC_EX_INTDIR = sigc-examples-static +SIGC_TESTS_INTDIR = sigc-tests-static +!else +LIBSIGC_INTDIR = sigc +SIGC_EX_INTDIR = sigc-examples +SIGC_TESTS_INTDIR = sigc-tests +!endif + !if "$(CFG)" == "debug" || "$(CFG)" == "Debug" DEBUG_SUFFIX = -d !else @@ -18,6 +28,11 @@ LIBSIGCPP_DEFINES = /DSIGC_BUILD SIGCPP_BASE_CFLAGS = /I.. /I. /I..\untracked\MSVC_NMake /std:c++17 /EHsc $(CFLAGS) +# Define LIBSIGCXX_STATIC everywhere for static builds +!ifdef STATIC +SIGCPP_BASE_CFLAGS = $(SIGCPP_BASE_CFLAGS) /DLIBSIGCXX_STATIC +!endif + LIBSIGC_INT_SOURCES = $(sigc_sources_cc:/=\) LIBSIGC_INT_HDRS = $(sigc_public_h:/=\) @@ -35,8 +50,12 @@ LIBSIGC_LIBNAME = sigc-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBSIGC_MAJOR_VERSION)_$( LIBSIGC_DLLNAME = $(LIBSIGC_LIBNAME) !endif +!ifdef STATIC +LIBSIGC_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME)-static.lib +!else LIBSIGC_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_DLLNAME).dll LIBSIGC_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).lib +!endif # If your Boost libraries are built as DLLs, use BOOST_DLL=1 in your NMake command line !ifdef BOOST_DLL diff --git a/MSVC_NMake/create-lists-msvc.mak b/MSVC_NMake/create-lists-msvc.mak index 2691d88..0689c89 100644 --- a/MSVC_NMake/create-lists-msvc.mak +++ b/MSVC_NMake/create-lists-msvc.mak @@ -35,18 +35,40 @@ NULL= # For libsigc++ -!if [call create-lists.bat header sigc.mak sigc_dll_OBJS] +!if [call create-lists.bat header sigc.mak libsigc_OBJS] !endif -!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] +!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] !endif -!if [@call create-lists.bat file sigc.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc\sigc.res] +# No point linking in version resource for static builds +!ifndef STATIC +!if [@call create-lists.bat file sigc.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\$(LIBSIGC_INTDIR)\sigc.res] +!endif !endif !if [call create-lists.bat footer sigc.mak] !endif +!ifdef STATIC +# start of static executables +!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] +!endif + +!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] +!endif + +!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] +!endif + +!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] +!endif + +!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] +!endif +# end of static executables +!else +# start of shared executables !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] !endif @@ -56,13 +78,16 @@ NULL= !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] !endif -!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] +!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] +!endif + +!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] !endif -!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] +# end of shared executables !endif -!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] +!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] !endif !include sigc.mak diff --git a/MSVC_NMake/info-msvc.mak b/MSVC_NMake/info-msvc.mak index 30d1dba..76b2341 100644 --- a/MSVC_NMake/info-msvc.mak +++ b/MSVC_NMake/info-msvc.mak @@ -6,13 +6,15 @@ all-build-info: @echo Build info @echo --------- @echo Build Type: $(CFG) + @if not "$(STATIC)" == "" echo Library Build Type: static + @if "$(STATIC)" == "" echo Library Build Type: DLL help: @echo. @echo ============================== @echo Building libsigc++ Using NMake @echo ============================== - @echo nmake /f Makefile.vc CFG=[release^|debug] ^ + @echo nmake /f Makefile.vc CFG=[release^|debug] ^ ^ @echo. @echo Where: @echo ------ @@ -24,6 +26,10 @@ help: @echo where ^$(short_vs_ver) is 15 for VS 2017 and so on; and @echo ^$(platform) is Win32 for 32-bit builds and x64 for x64 builds. @echo. + @echo STATIC: Optional, enable to build static libsigc++. Define + @echo LIBSIGCXX_STATIC in the compiler flags to use the static build of + @echo libsigc++. + @echo. @echo ====== @echo A 'clean' target is supported to remove all generated files, intermediate @echo object files and binaries for the specified configuration. diff --git a/meson.build b/meson.build index 3190d6e..4777ed5 100644 --- a/meson.build +++ b/meson.build @@ -216,6 +216,9 @@ if is_msvc cpp_compiler.get_supported_arguments(disable_warnings_list), language: 'cpp' ) + if is_msvc_static + add_project_arguments(['-DLIBSIGCXX_STATIC'], language: 'cpp') + endif endif # Configure files diff --git a/sigc++/meson.build b/sigc++/meson.build index 3b3cfeb..d9c1231 100644 --- a/sigc++/meson.build +++ b/sigc++/meson.build @@ -80,8 +80,10 @@ endif # Build the .rc file for Windows builds and link to it if host_machine.system() == 'windows' windows = import('windows') - sigc_res = windows.compile_resources(sigc_rc) - extra_sigc_objects += sigc_res + if get_option('default_library') == 'shared' + sigc_res = windows.compile_resources(sigc_rc) + extra_sigc_objects += sigc_res + endif endif extra_include_dirs = ['..'] From 84703ab684bd2549011032250d3c659d6b6c6802 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 26 Jun 2023 11:56:39 +0800 Subject: [PATCH 4/6] NMake Makefiles: Accomodate static builds during "install" Copy the built DLL and PDB only if building a shared build, and copy the appropriate .lib file according to the build type. --- MSVC_NMake/install.mak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MSVC_NMake/install.mak b/MSVC_NMake/install.mak index f9f07e2..72b4402 100644 --- a/MSVC_NMake/install.mak +++ b/MSVC_NMake/install.mak @@ -7,9 +7,9 @@ install: all @if not exist $(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\adaptors\ @md $(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\adaptors @if not exist $(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\functors\ @md $(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\functors @if not exist $(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\tuple-utils\ @md $(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\tuple-utils - @copy /b vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).dll $(PREFIX)\bin - @copy /b vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).pdb $(PREFIX)\bin - @copy /b vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).lib $(PREFIX)\lib + @if "$(STATIC)" == "" copy /b $(LIBSIGC_DLL) $(PREFIX)\bin + @if "$(STATIC)" == "" copy /b $(LIBSIGC_DLL:.dll=.pdb) $(PREFIX)\bin + @copy /b $(LIBSIGC_LIB) $(PREFIX)\lib @copy "..\sigc++\sigc++.h" "$(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\" @for %h in ($(LIBSIGC_INT_HDRS)) do @copy "..\sigc++\%h" "$(PREFIX)\include\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\sigc++\%h" @if exist sigc++config.h copy "sigc++config.h" "$(PREFIX)\lib\sigc++-$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)\include\" From 364237ee6680a50b4d6a16e731e21cc8068af31f Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 26 Jun 2023 12:22:27 +0800 Subject: [PATCH 5/6] sigc++.pc.in: Set -DLIBSIGCXX_STATIC in cxxflags as needed Update the Meson build files to put in -DLIBSIGCXX_STATIC when we are building a static build of libsigc++. For the CMake and autotools build, this is not used. --- CMakeLists.txt | 1 + configure.ac | 2 ++ meson.build | 4 +++- sigc++.pc.in | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5741400..c4b291c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ set (SIGCXX_MICRO_VERSION 0) set (SIGCXX_API_VERSION 3.0) set (PACKAGE_VERSION ${SIGCXX_MAJOR_VERSION}.${SIGCXX_MINOR_VERSION}.${SIGCXX_MICRO_VERSION}) set (LIBSIGCPP_SOVERSION 0) +set (MSVC_STATIC_CXXFLAG "") option (SIGCXX_DISABLE_DEPRECATED "Disable deprecated" OFF) diff --git a/configure.ac b/configure.ac index 2256657..52237da 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,8 @@ AS_IF([test "x$enable_benchmark" = xyes],[ AX_BOOST_TIMER ]) +AC_SUBST(MSVC_STATIC_CXXFLAG, '') + AC_CONFIG_FILES([Makefile ${SIGCXX_MODULE_NAME}.pc:sigc++.pc.in ${SIGCXX_MODULE_NAME}-uninstalled.pc:sigc++-uninstalled.pc.in diff --git a/meson.build b/meson.build index 4777ed5..4c975d4 100644 --- a/meson.build +++ b/meson.build @@ -193,6 +193,7 @@ add_project_arguments(warning_flags, language: 'cpp') # MSVC: Ignore warnings that aren't really harmful, but make those # that should not be overlooked stand out. +static_cxxflag = '-DLIBSIGCXX_STATIC' if is_msvc disable_warnings_list = [ '/EHsc', # avoid warnings caused by exception handling model used @@ -217,7 +218,7 @@ if is_msvc language: 'cpp' ) if is_msvc_static - add_project_arguments(['-DLIBSIGCXX_STATIC'], language: 'cpp') + add_project_arguments(static_cxxflag, language: 'cpp') endif endif @@ -239,6 +240,7 @@ endif pkg_conf_data.set('SIGCXX_MAJOR_VERSION', sigcxx_major_version) pkg_conf_data.set('SIGCXX_MINOR_VERSION', sigcxx_minor_version) pkg_conf_data.set('SIGCXX_MICRO_VERSION', sigcxx_micro_version) +pkg_conf_data.set('MSVC_STATIC_CXXFLAG', is_msvc_static ? static_cxxflag : '') configure_file( input: 'sigc++.pc.in', diff --git a/sigc++.pc.in b/sigc++.pc.in index 16a5514..e162f2f 100644 --- a/sigc++.pc.in +++ b/sigc++.pc.in @@ -15,4 +15,4 @@ Description: Typesafe signal and callback system for C++ Version: @PACKAGE_VERSION@ URL: https://libsigcplusplus.github.io/libsigcplusplus/ Libs: -L${libdir} -lsigc-@SIGCXX_API_VERSION@ -Cflags: -I${includedir}/sigc++-@SIGCXX_API_VERSION@ -I${libdir}/sigc++-@SIGCXX_API_VERSION@/include +Cflags: -I${includedir}/sigc++-@SIGCXX_API_VERSION@ -I${libdir}/sigc++-@SIGCXX_API_VERSION@/include @MSVC_STATIC_CXXFLAG@ From c185ad24a3e865b4a07490096e6e8384239a7d40 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 26 Jun 2023 12:26:48 +0800 Subject: [PATCH 6/6] MSVC_NMake/README.txt: Mention about static builds --- MSVC_NMake/README.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MSVC_NMake/README.txt b/MSVC_NMake/README.txt index d3ba16f..5438335 100644 --- a/MSVC_NMake/README.txt +++ b/MSVC_NMake/README.txt @@ -45,6 +45,10 @@ PREFIX: Optional. Base directory of where the third-party headers, libraries $(X) is the short version of the Visual Studio used, as follows: 2017: 15 +STATIC: Optional. Set if building libsigc++ as a static library. Note that + for building items that use this static build, /DLIBSIGCXX_STATIC + must be passed into the compiler flags. + USE_COMPAT_LIBS: Build the sigc++ DLL and .lib with the filename 'sigc-vc150(d)-3_0' for all builds. This is for compatibility reasons, if re-building dependent code is not 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