Compilation error with MSVC 19

Kornel Benko kornel at lyx.org
Wed Dec 30 15:06:15 UTC 2020


Am Wed, 30 Dec 2020 15:17:36 +0100
schrieb Thibaut Cuvelier <tcuvelier at lyx.org>:

> On Wed, 30 Dec 2020 at 09:01, Yuriy Skalko <yuriy.skalko at gmail.com> wrote:
> 
> > > Here is a newer version of the patch that does not use _HAS_CXX17, as it
> > > should not really be relied upon (
> > >
> > https://stackoverflow.com/questions/52379233/is-has-cxx17-marco-usable-in-custom-project-headers-to-enable-c17-language
> > ).
> >
> > I think the right way will be using only standard-compliant
> > "__cplusplus" in sources and adding the option "/Zc:__cplusplus" for
> > MSVC compiler in the build scripts so it handle __cplusplus in
> > standard-compliant way:
> >
> >
> > https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160
> >
> 
> It seems that it's not that easy to pass this flag through CMake, and the
> devs are not really willing to do something about it:
> https://gitlab.kitware.com/cmake/cmake/-/issues/18837

We can do it.  For instance add the flag in ./development/cmake/config.h.cmake
	#cmakedefine LYX_EXTRA_CXXFLAGS 1
	#if defined(LYX_EXTRA_CXXFLAGS)
		#define ${LYX_EXTRA_CXXFLAGS}
	#endif
Now you could use
	$ cmake ... -DLYX_EXTRA_CXXFLAGS=__cplusplus
and the resulting config.h will contain
	#define LYX_EXTRA_CXXFLAGS 1
	#if defined(LYX_EXTRA_CXXFLAGS)
		#define __cplusplus
	#endif

> I tried several things to get the flag at the right position through CMake,
> but I can't get it to work (using the technique of
> https://stackoverflow.com/questions/57102212/cannot-set-cplusplus-to-c17-standard-with-visual-studio-and-cmake
> / https://gitlab.kitware.com/cmake/cmake/-/issues/18837#note_722441 and
> https://peter.bloomfield.online/report-__cplusplus-correctly-with-cmake-and-visual-studio/).
> I'm attaching three attempts: the CMake variable CMAKE_CXX_FLAGS is
> modified but the new flag never appears anywhere.

	Kornel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: Digitale Signatur von OpenPGP
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20201230/0d5b0cf9/attachment-0001.asc>


More information about the lyx-devel mailing list