Skip to content

meson: Add libxml2 cmake wrap #30

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 4 commits into from
Jun 27, 2022
Merged

Conversation

talisein
Copy link
Contributor

Adding a cmake wrap for libxml2 turned out to be a little more involved than the wrap-db, due to the cmake project being preconfigured to requiring several dependencies.

One design choice to be made: Do we want to only use the wrap on windows?

A github action run that shows this in use (along with #29) is at: https://github.com/talisein/libxmlplusplus/actions/runs/2544884141

@fanc999
Copy link
Collaborator

fanc999 commented Jun 23, 2022

Hi @talisein,

Thanks for the CMake fallback! Looks pretty much fine to me, albeit we can try to fine-tune the libxml CMake fallback on the third-party library search in another PR if we need to. I did have a few points that I thought I should point out.

With blessings, thank you!

@fanc999
Copy link
Collaborator

fanc999 commented Jun 23, 2022

Hi,

Also wondering, does Meson pass in the build type to CMake during the fallback, or do we have to specify one ourselves? This will matter because we may end up linking to different CRTs (i.e. Debug vs Release CRT), which can mean trouble.


Edit: It turns out that we do need to specify it.


Edit:

This is how I think things will work for that regard:

Meson                   CMake (via `-DCMAKE_BUILD_TYPE=xxx` on the command line)
=====                 ======
debug                   Debug (libxml2's default with the Ninja generator)
debugoptimized   RelWithDebInfo
release                  Release
minsize                 MinSizeRel

(Note that there is no clear direct mapping for the plain Meson build type--after checking the CMake docs, we can just forward the --buildtype= from Meson directly to CMake if it's debug or release, and feed in RelWithDebInfo for debugoptimized and feed in MinSizeRel for minsize builds, since they made it non-case-sensitive).

With blessings, thank you!

@kjellahl
Copy link
Collaborator

Is this PR ready for merging? Or are changes or additions required due to Chun-wei Fan's comments?

BTW, I tested building libxml2 as a subproject on a Linux system. I got an enormous
number of warnings of type

../subprojects/libxml2_cmake/HTMLtree.c:350:5: warning: too many arguments for format [-Wformat-extra-args]
  350 |     __xmlSimpleError(XML_FROM_OUTPUT, XML_ERR_NO_MEMORY, NULL, NULL, extra);
      |     ^~~~~~~~~~~~~~~~

../subprojects/libxml2_cmake/xmlschemas.c:6150:13: warning: too many arguments for format [-Wformat-extra-args]
 6150 |             val, NULL, NULL, NULL);
      |             ^~~

although the function calls look perfectly fine. If this does not happen on Windows,
it's not important. I don't think there's any need to build libxml2 as a subproject on Linux.

@talisein
Copy link
Contributor Author

Windows has a ton of warnings from libxml2 too; I turned off Werror for the subproject but kept it on for xml++ in my workflow.
I will address Chun-wei's comment today.

talisein added 2 commits June 23, 2022 10:17
From meson 0.51.0, cpp_eh defaults to /EHsc on windows. Passing it to
add_program_arguments() means downstream projects using cpp_eh=a will get
warnings.
@talisein
Copy link
Contributor Author

@fanc999 Are you sure it should be specified?
Here is the compile_commands.json when I pass CMAKE_BUILD_TYPE=release, meson's is release and b_ndebug=false
ccache cc -Isubprojects/libxml2_cmake/libLibXml2.so.p -Isubprojects/libxml2_cmake -I../subprojects/libxml2_cmake -Isubprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/include -I/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -fPIC -O3 -DNDEBUG -DLibXml2_EXPORTS '-DSYSCONFDIR=\"/usr/local/etc\"' -D_REENTRANT -MD -MQ subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -MF subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o.d -o subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -c ../subprojects/libxml2_cmake/buf.c

Here is when I pass CMAKE_BUILD_TYPE= but set the meson buildtype to release and b_ndebug=false
ccache cc -Isubprojects/libxml2_cmake/libLibXml2.so.p -Isubprojects/libxml2_cmake -I../subprojects/libxml2_cmake -Isubprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/include -I/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -fPIC -DLibXml2_EXPORTS '-DSYSCONFDIR=\"/usr/local/etc\"' -D_REENTRANT -MD -MQ subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -MF subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o.d -o subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -c ../subprojects/libxml2_cmake/buf.c

The difference is -O3 -fPIC -O3 -DNDEBUG from passing release to CMake vs -O3 -fPIC.

If I do not pass release to CMake, but set meson to release and set b_ndebug=true, then -DNDEBUG will appear.

tl;dr:
Passing CMAKE_BUILD_TYPE causes optimization options to be doubled, and meson's b_ndebug configuration parameter will be overridden in some cases.

1 more question Chen-wei! I've snuck in one more commit to this PR, removing /EHsc. Meson has cpp_eh option from meson 0.51.0 so this should be ok, but you have a lot more insight here. Let me know if its a problem.

@fanc999
Copy link
Collaborator

fanc999 commented Jun 24, 2022

Hi @talisein,

For my part, removing the /EHsc from the Meson build files seemed fine to me, since it is now enabled by default in the builds. I think for the CMake part when we use it to build libxml2, I was getting a warning when building with --buildtype=release or --buildtype=debugoptimized, saying:

cl : Command line warning D9025 : overriding '/MD' with '/MDd'

This means that release (or debugoptimized) builds of libxml++ will link to the release CRT but the dependent libxml2 will link to the debug CRT.

Did you try building with --buildtype=debugoptimized or --buildtype=debug? If the things look fine to you, we might need to only apply the -DCMAKE_BUILD_TYPE=... only on Visual Studio. Might look like a Meson issue...

With blessings, thank you!


Oh, as a side note, I think after this PR gets merged, I will move the dependency detection to use both pkg-config and CMake, instead of manually looking for the libxml2 and libraries, since CMake's built-in search mechanism actually does the manual libxml2 headers and .lib search for us.1

@talisein
Copy link
Contributor Author

talisein commented Jun 24, 2022

Are you using the ninja backend or the vs backend? I can look at how this looks on windows tomorrow, but for now here's the linux situation

With debug optimized, you can see -O2 -g -DNDEBUG gets added into the compile_command but everything else is the same.

./_build_MESON_debugoptimized_CMAKE_BUILD_TYPE_debugoptimized/compile_commands.json:    "command": "ccache cc -Isubprojects/libxml2_cmake/libLibXml2.so.p -Isubprojects/libxml2_cmake -I../subprojects/libxml2_cmake -Isubprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/include -I/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -fPIC -O2 -g -DNDEBUG -DLibXml2_EXPORTS '-DSYSCONFDIR=\"/usr/local/etc\"' -D_REENTRANT -MD -MQ subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -MF subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o.d -o subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -c ../subprojects/libxml2_cmake/buf.c",
./_build_MESON_debugoptimized_CMAKE_BUILD_TYPE_none/compile_commands.json:              "command": "ccache cc -Isubprojects/libxml2_cmake/libLibXml2.so.p -Isubprojects/libxml2_cmake -I../subprojects/libxml2_cmake -Isubprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/include -I/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -fPIC -DLibXml2_EXPORTS '-DSYSCONFDIR=\"/usr/local/etc\"' -D_REENTRANT -MD -MQ subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -MF subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o.d -o subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -c ../subprojects/libxml2_cmake/buf.c",

Here is debug for the sake of completeness, but it is the same situation, -g is passed twice.

./_build_MESON_debug_CMAKE_BUILD_TYPE_debug/compile_commands.json:    "command": "ccache cc -Isubprojects/libxml2_cmake/libLibXml2.so.p -Isubprojects/libxml2_cmake -I../subprojects/libxml2_cmake -Isubprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/include -I/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -fPIC -g -DLibXml2_EXPORTS '-DSYSCONFDIR=\"/usr/local/etc\"' -D_REENTRANT -MD -MQ subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -MF subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o.d -o subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -c ../subprojects/libxml2_cmake/buf.c",
./_build_MESON_debug_CMAKE_BUILD_TYPE_none/compile_commands.json:     "command": "ccache cc -Isubprojects/libxml2_cmake/libLibXml2.so.p -Isubprojects/libxml2_cmake -I../subprojects/libxml2_cmake -Isubprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/__CMake_build -I../subprojects/libxml2_cmake/include -I/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -fPIC -DLibXml2_EXPORTS '-DSYSCONFDIR=\"/usr/local/etc\"' -D_REENTRANT -MD -MQ subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -MF subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o.d -o subprojects/libxml2_cmake/libLibXml2.so.p/buf.c.o -c ../subprojects/libxml2_cmake/buf.c",

If you'd like a patch to try yourself, talisein/libxmlplusplus@d2a270c but I don't mind poking at it some more tomorrow.

@talisein
Copy link
Contributor Author

With RelWithDebInfo, we use flags /MD /Ob1 /DNDEBUG -MD
With no build type, we use flags /MD -MDd -D_DEBUG

MESON_debugoptimized_CMAKE_relwithdebinfo    "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/O2\" \"/Zi\" \"/DWIN32\" \"/D_WINDOWS\" \"/Ob1\" \"/DNDEBUG\" \"-MD\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",
MESON_debugoptimized_CMAKE_blank             "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/O2\" \"/Zi\" \"/DWIN32\" \"/D_WINDOWS\" \"-MDd\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"-D_DEBUG\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",

Same projects, but looking at libxml++ files there are no differences between the two as expected. It uses /MD

MESON_debugoptimized_CMAKE_relwithdebinfo    "command": "\"cl\" \"-Ilibxml++\\xml++-vc143-5.0-1.dll.p\" \"-I.\" \"-I..\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/EHsc\" \"/std:c++17\" \"/permissive-\" \"/O2\" \"/Zi\" \"/utf-8\" \"/wd4706\" \"/wd4244\" \"/wd4101\" \"/wd4267\" \"-DLIBXMLPP_BUILD=1\" \"-D_WINDLL\" \"/Fdlibxml++\\xml++-vc143-5.0-1.dll.p\\validators_validator.cc.pdb\" /Folibxml++/xml++-vc143-5.0-1.dll.p/validators_validator.cc.obj \"/c\" ../libxml++/validators/validator.cc",
MESON_debugoptimized_CMAKE_blank             "command": "\"cl\" \"-Ilibxml++\\xml++-vc143-5.0-1.dll.p\" \"-I.\" \"-I..\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/EHsc\" \"/std:c++17\" \"/permissive-\" \"/O2\" \"/Zi\" \"/utf-8\" \"/wd4706\" \"/wd4244\" \"/wd4101\" \"/wd4267\" \"-DLIBXMLPP_BUILD=1\" \"-D_WINDLL\" \"/Fdlibxml++\\xml++-vc143-5.0-1.dll.p\\validators_validator.cc.pdb\" /Folibxml++/xml++-vc143-5.0-1.dll.p/validators_validator.cc.obj \"/c\" ../libxml++/validators/validator.cc",

Looking at release,
With release build type, /MD /Ob2 /DNDEBUG -MD
With no build type, we use flags /MD -MDd -D_DEBUG

MESON_release_CMAKE_release    "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/O2\" \"/Gw\" \"/DWIN32\" \"/D_WINDOWS\" \"/Ob2\" \"/DNDEBUG\" \"-MD\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",
MESON_release_CMAKE_blank      "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/O2\" \"/Gw\" \"/DWIN32\" \"/D_WINDOWS\" \"-MDd\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"-D_DEBUG\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",

Conclusion:
Not passing CMAKE_BUILD_TYPE results in different C libraries being linked.
Passing CMAKE_BUILD_TYPE results in NDEBUG being passed regardless of b_ndebug
Maybe there is another CMake variable we can set?
Using CMAKE_MSVC_RUNTIME_LIBRARY we can get rid of duplicated /MD flags, but we still have at times conflicting levels of optimization specified

MESON_release_CMAKE_release                  "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/O2\" \"/Gw\" \"/DWIN32\" \"/D_WINDOWS\" \"/Ob2\" \"/DNDEBUG\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",
MESON_debug_CMAKE_debug                      "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MDd\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/Od\" \"/Zi\" \"/DWIN32\" \"/D_WINDOWS\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"-D_DEBUG\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",
MESON_debugoptimized_CMAKE_relwithdebinfo    "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/O2\" \"/Zi\" \"/DWIN32\" \"/D_WINDOWS\" \"/Ob1\" \"/DNDEBUG\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",

If we additionally add CMAKE_C_FLAGS, we are nearly at what we want. In the debug variant, CMAKE still insists on adding -D_DEBUG; meson doesn't seem to add this flag itself ever; the msvc documentation suggests the define is added automatically.

MESON_release_CMAKE_release                  "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/O2\" \"/Gw\" \"/DWIN32\" \"/D_WINDOWS\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",
MESON_debug_CMAKE_debug                      "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MDd\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/Od\" \"/Zi\" \"/DWIN32\" \"/D_WINDOWS\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"-D_DEBUG\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",
MESON_debugoptimized_CMAKE_relwithdebinfo    "command": "\"cl\" \"-Isubprojects\\libxml2_cmake\\LibXml2.dll.p\" \"-Isubprojects\\libxml2_cmake\" \"-I..\\subprojects\\libxml2_cmake\" \"-Isubprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\__CMake_build\" \"-I..\\subprojects\\libxml2_cmake\\include\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/W2\" \"/O2\" \"/Zi\" \"/DWIN32\" \"/D_WINDOWS\" \"-DHAVE_WIN32_THREADS\" \"-DLibXml2_EXPORTS\" \"-DSYSCONFDIR=\\\"C://etc\\\"\" \"-D_REENTRANT\" \"-DWIN32\" \"/Fdsubprojects\\libxml2_cmake\\LibXml2.dll.p\\buf.c.pdb\" /Fosubprojects/libxml2_cmake/LibXml2.dll.p/buf.c.obj \"/c\" ../subprojects/libxml2_cmake/buf.c",

I have added a commit to implement this last behavior. Ideally we could just leave CMAKE_BUILD_TYPE blank and simply set CMAKE_C_FLAGS, but that results in -D_DEBUG being passed to the non-debug library variant, and I don't want to guess if that has a side effect. So instead we need to set CMAKE_C_FLAGS_RELEASE etc

@kjellahl
Copy link
Collaborator

About all the compiler warnings:
I built libxml2 as a stand-alone project (not subproject). When building with
CMake, lots and lots of warnings are generated. When building with Autotools,
most warnings are suppressed with the gcc compiler option -Wno-format-extra-args.
You can continue to ignore the generated compiler warnings when you build libxml2 with CMake.

@kjellahl kjellahl merged commit 43acb9c into libxmlplusplus:master Jun 27, 2022
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