Skip to content

Add support for Visual Studio builds with Meson #49

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 3 commits into from
Dec 20, 2019

Conversation

fanc999
Copy link
Collaborator

@fanc999 fanc999 commented Dec 11, 2019

Hi,

These are some rather simple changes that are needed for the Meson build files to support builds using Visual Studio as well.

I will look at the 2.x branch in a few days time.

With blessings, thank you!

We need to make sure that SIGC_BUILD and _WINDLL are defined when
building the libsigc++ DLL, so that it gets build properly.
@kjellahl
Copy link
Contributor

if is_msvc and maintainer_mode
  error('Maintainer mode is not supported for Visual Studio builds.\nUse \'-Dmaintainer-mode=false\' to disable')
endif

Is it impossible or just difficult to install mm-common on Windows?
If it's at all possible to have a working mm-common-get command, it's not nice
to make it impossible for MSVC users to use mm-common-get. If you build from git
without letting mm-common-get copy files to the untracked/ directory, you can build
the libsigc++ library file and install it and the include files, but it will
be a limited build system. You can't build or install the documentation.
You can't create a tarball (ninja dist).

If it's possible to build sigc++-3 from git and have a working mm-common-get
command on Windows, I would suggest a less restricting test in meson.build.
Perhaps like so:

mm_common_get = find_program('mm-common-get', required: false)

if maintainer_mode and not mm_common_get.found()
  error('Maintainer mode requires the mm-common-get command.\nUse \'-Dmaintainer-mode=false\' or install the mm-common package, version 1.0.0 or higher.')
endif

@kjellahl
Copy link
Contributor

I've tested mm-common on Windows. I just installed Meson and Ninja, but no compiler.
I could install mm-common, so the mm-common-get command was available. I tested
libsigc++-3 with very incomplete meson.build files, where I commented out a lot of stuff.

Result: Meson finds mm-common-get, if it's in the search PATH. In maintainer-mode
it copies the files it's supposed to copy to the untracked/ directory.

I recommend

mm_common_get = find_program('mm-common-get', required: false)
if maintainer_mode and not mm_common_get.found()
  error('Maintainer mode requires the mm-common-get command.\n' +
        'Use \'-Dmaintainer-mode=false\' or install the mm-common package, version 1.0.0 or higher.')
endif

I noticed a strange problem with MSVC_NMake/meson.build.

SyntaxError: (unicode error) 'unicodeescape' codes can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

The error disappears if I change

'''.format(project_build_root / 'sigc++config.h', meson.current_build_dir())

to

'''.format(project_build_root / 'sigc++config.h', meson.current_build_dir() / '.')

meson.current_build_dir() uses backslash (\) as directory separator on Windows.
All backslashes are replaced by slashes (/) when / '.' is added.

I suppose you haven't noticed this. I've used Meson version 0.52.1 on Windows.

Instead of showing that 'mm-common-get' is not found, state that it is
required for maintainer-mode.
This avoids warnings and mis-compilations on certain system locales when
building on Visual Studio, in particular Chinese, Japanese and Korean
versions of Windows.
@fanc999
Copy link
Collaborator Author

fanc999 commented Dec 20, 2019

Hi @kjellahl,

Sorry for being quite late and inactive, as there were some things that I was caught up with. I made the changes that you suggested, and am looking at mm-common on how it can be built successfully on Visual Studio builds (disclaimer: please note the "builds", not "working").

Hmm, I was not able to re-produce the error you had in MSVC_NMake, even with Meson 0.52.1...

With blessings, thank you!

@kjellahl kjellahl merged commit 770456c into libsigcplusplus:kjellahl/sigc3-meson Dec 20, 2019
@kjellahl
Copy link
Contributor

I have merged this PR to kjellahl/sigc3-meson, and then merged kjellahl/sigc3-meson
in PR #48 to master and removed the kjellahl/sigc3-meson branch.

Hmm, I was not able to re-produce the error you had in MSVC_NMake, even with Meson 0.52.1...

Probably it's no real error. Perhaps my Windows computer lacks some necessary program
or DLL or something. I don't use it for program development.

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.

3 participants