Skip to content

Support static builds for Visual Studio #91

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

Merged
merged 6 commits into from
Jun 26, 2023

Conversation

fanc999-1
Copy link
Contributor

@fanc999-1 fanc999-1 commented Jun 26, 2023

Hi,

This attempts to address issue #90 by supporting static builds of libsigc++, where:

  • We do not make builds always shared for Visual Studio builds in sigc++config.h, although shared builds are still the default for Visual Studio builds.
  • Add a check macro LIBSIGXX_STATIC in the sigc++config.h.* files, to check whether we are going to use a static MSVC build.
  • Update the Meson and NMake build files to support static builds. Note that we do not support building shared and static builds in one shot (so, -Ddefault_library=both is explicitly not supported). The generated .pc file from static Visual Studio builds will define -DLIBSIGCXX_STATIC in the CXXFLAGS
  • Let people know that -DLIBSIGCXX_STATIC is required if attempting to build against a static libsigc++ build.

Fixes issue #90.

With blessings, thank you!

@fanc999-1
Copy link
Contributor Author

Hi,

For records:

  • This does not attempt to update the CMake build files, unless static builds will be supported there (it is set to build shared builds only), which is for another PR.
  • The other parts of the -mm stack do not support static builds at this point, still, as the base C library do not really support static builds officially. If this PR gets through, I will go ahead to update the libxml++ build files.

With blessings, and cheers!

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.
...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.
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.
Copy the built DLL and PDB only if building a shared build, and copy the
appropriate .lib file according to the build type.
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.
@kjellahl
Copy link
Contributor

If you still have permission to merge to libsigcplusplus, please do.
If not, I can merge this PR.

Can static builds be supported also for libsigc++2 (branch libsigc++-2-12)?
I see in the meson.build files that static builds are supported for libxml++5
(master branch) but not for the other libxml++ versions. Is that because the
other libxml++ versions depend on glibmm, and glibmm does not support static
builds with MSVC? No version of libsigc++ depends on glibmm. On the contrary,
glibmm depends on libsigc++.

@fanc999-1
Copy link
Contributor Author

Hi @kjellahl,

Sadly, I don't have the permissions... The PR for libsigc++-2.x is done in #92 (sorry, I forgot to make the title there clearer)-but like you said, the libxml++ don't support static builds due to glibmm, but anyways, for completeness sake I added support for libsigc++-2.x.

With blessings, than you!

@kjellahl kjellahl merged commit 9e7517a into libsigcplusplus:master Jun 26, 2023
@kjellahl kjellahl mentioned this pull request Jun 26, 2023
@fanc999-1 fanc999-1 deleted the msvc-static branch June 27, 2023 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants