Cygwin g++ for 'make depend'

25 views
Skip to first unread message

Gisle Vanem

unread,
Feb 12, 2024, 6:44:54 AMFeb 12
to wx-users
In my a GNU-makefile (targeting MSVC), I sometimes use a Cygwin 'g++'
to create dependencies. Like:
  DEP_CFLAGS = -MM $(filter -I% -D%, $(CFLAGS)) \
         --include $(OBJ_DIR)/config.h    \
          -DGCC_MAKE_DEPEND
depend:
   g++ $(DEP_CFLAGS) $(SOURCE) >> .depend.Windows
....

---------------

But when a wxWidget headers notice a '__GNUC__' and/or '__CYGWIN__' is involved,
it goes bananas with huge amounts of '#error' statements. 
So I just fake 'g++' into a MSVC-compiler in my generated
'$(OBJ_DIR)/config.h':
  #if defined(GCC_MAKE_DEPEND)
    #define _MSC_VER            1910
    #define _WX_CHKCONF_H_      1
    #define _WX_MSW_CHKCONF_H_  1
    #define __WXMSW__           1
  #endif
 ....
--------------

Is there a better way?

Vadim Zeitlin

unread,
Feb 12, 2024, 7:19:50 AMFeb 12
to wx-u...@googlegroups.com
On Mon, 12 Feb 2024 03:00:16 -0800 (PST) Gisle Vanem wrote:

GV> In my a GNU-makefile (targeting MSVC), I sometimes use a Cygwin 'g++'
GV> to create dependencies. Like:
GV> DEP_CFLAGS = -MM $(filter -I% -D%, $(CFLAGS)) \
GV> --include $(OBJ_DIR)/config.h \
GV> -DGCC_MAKE_DEPEND
GV> depend:
GV> g++ $(DEP_CFLAGS) $(SOURCE) >> .depend.Windows

Note that this is not going to work for anything conditionally-included
depending on the compiler used.

GV> But when a wxWidget headers notice a '__GNUC__' and/or '__CYGWIN__' is
GV> involved,
GV> it goes bananas with huge amounts of '#error' statements.

I guess it's due to filtering out -D__WXMSW__ from your CFLAGS above, why
do you do it?

GV> So I just fake 'g++' into a MSVC-compiler in my generated
GV> '$(OBJ_DIR)/config.h':
GV> #if defined(GCC_MAKE_DEPEND)
GV> #define _MSC_VER 1910
GV> #define WX CHKCONF H 1
GV> #define WX MSW CHKCONF H 1
GV> #define __WXMSW__ 1
GV> #endif
GV> ....
GV> --------------
GV>
GV> Is there a better way?

You could predefine the same symbols on command line, but it's still a
dirty hack, of course.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
https://www.tt-solutions.com/

Gisle Vanem

unread,
Feb 12, 2024, 8:17:45 AMFeb 12
to wx-users
>  I guess it's due to filtering out -D__WXMSW__ from your CFLAGS above

I don't. Did you notice the $(filter -%I -%D, $(CFLAGS))..?. And I use -FI./$(OBJ_DIR)/config.h for cl and clang-cl
and I really saw no need to add -D__WXMSW__ for those. But adding it seems to do no harm.
Hence my /$(OBJ_DIR)/config.h and depend hack is now:
  #define __WXMSW__        1
  #if defined(GCC_MAKE_DEPEND)
    #define _MSC_VER            1910
    #define _WX_CHKCONF_H_      1
    #define _WX_MSW_CHKCONF_H_  1
  #endif

Vadim Zeitlin

unread,
Feb 12, 2024, 8:21:20 AMFeb 12
to wx-u...@googlegroups.com
On Mon, 12 Feb 2024 05:17:45 -0800 (PST) 'Gisle Vanem' via wx-users wrote:

GV> and I really saw no need to add *-D__WXMSW__* for those.

This is not a compiler-specific switch, it selects the wxWidgets port
you're using and must be defined when building wxMSW. Please see

https://docs.wxwidgets.org/latest/plat_msw_install.html#msw_build_apps_other

for some other things definitions you have to use.
Reply all
Reply to author
Forward
0 new messages