On Wed, 30 Dec 2020 at 16:06, Kornel Benko <kor...@lyx.org> wrote:

> Am Wed, 30 Dec 2020 15:17:36 +0100
> schrieb Thibaut Cuvelier <tcuvel...@lyx.org>:
>
> > On Wed, 30 Dec 2020 at 09:01, Yuriy Skalko <yuriy.ska...@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
>

Would it be possible to have a flag set by default for MSVC? It's not just
because it would look nice, it's for basically being able to build LyX,
it's a lot like adding libraries to link for MinGW or Cygwin
(src/CMakeLists.txt).

Also, it won't work if it's in the config.h file that's included
everywhere: it's a flag that must be passed when calling the compiler (and
I guess no sane compiler will let you redefine the macro __cplusplus
defined in the standard).
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to