Skip to content
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

CMake translation missing Objective-C++ files in wxWidgets #8132

Closed
CoffeeFlux opened this issue Dec 26, 2020 · 7 comments
Closed

CMake translation missing Objective-C++ files in wxWidgets #8132

CoffeeFlux opened this issue Dec 26, 2020 · 7 comments
Labels
dependency:cmake Issues related to `dependency` with the `cmake` method OS:macos Issues specific to Apple Operating Systems like MacOS and iOS subprojects/wraps
Milestone

Comments

@CoffeeFlux
Copy link
Contributor

Attempting to build and link against wxWidgets on MacOS results in various linker errors. Looking up the symbols, they seem to be coming from the various objective-c++ .mm files in src/osx/cocoa. Compiling directly with CMake does seem to include those files.

Unfortunately, I don't have a minimal repro handy. If that's needed, please let me know and I can try to make one. I've uploaded meson.build, fileAPI.json and __CMake_build/cmake_trace.txt, but if there's anything else I can provide I'd be happy to since this is blocking.

cmake_objcpp_bug_logs.zip

CMake module invocation: https://github.com/TypesettingTools/Aegisub/blob/meson-vs2019/meson.build#L125

System:
MacOS 11.1
Python 3.9.1
Meson 0.56.0
CMake 3.19.2

@mensinda mensinda added dependency:cmake Issues related to `dependency` with the `cmake` method OS:macos Issues specific to Apple Operating Systems like MacOS and iOS subprojects/wraps labels Dec 26, 2020
@mensinda
Copy link
Member

It looks like you didn't add objcpp and objc to the languages in your project call. Could you please try adding these languages and check if this makes a difference?

mensinda added a commit to mensinda/meson that referenced this issue Dec 26, 2020
@mensinda mensinda added this to the 0.56.1 milestone Dec 26, 2020
@mensinda
Copy link
Member

Nevermind, this is an actual bug because CMake does not report all languages correctly when mixing languages...

Should be fixed with #8135.

mensinda added a commit to mensinda/meson that referenced this issue Dec 26, 2020
@CoffeeFlux
Copy link
Contributor Author

With the PR, it does appear to be picking up the .mm files but compilation fails due to what would appear to be missing header includes? Not totally sure if this is a separate issue or just the same bug, but I've uploaded fresh log files here for now.

cmake_objcpp_bug_logs_2.zip

Errors look like this (trimmed for brevity):

c++ -Isubprojects/wxWidgets/libcm_wxmono.dylib.p -Isubprojects/wxWidgets -I../subprojects/wxWidgets -I../subprojects/wxWidgets/src/regex -I../subprojects/wxWidgets/src/jpeg -I../subprojects/wxWidgets/src/png -I../subprojects/wxWidgets/src/tiff/libtiff -I../subprojects/wxWidgets/src/stc/scintilla/include -I../subprojects/wxWidgets/src/stc/scintilla/lexlib -I../subprojects/wxWidgets/src/stc/scintilla/src -I/Library/Frameworks/Mono.framework/Versions/6.4.0/include -Isubprojects/wxWidgets/__CMake_build/lib/wx/include/osx_cocoa-unicode-3.1 -I../subprojects/wxWidgets/__CMake_build/lib/wx/include/osx_cocoa-unicode-3.1 -I../subprojects/wxWidgets/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework -Isubprojects/wxWidgets/__CMake_build -I../subprojects/wxWidgets/__CMake_build -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/icu4c/include -flto -Xclang -fcolor-diagnostics -pipe -Wall -Winvalid-pch -Wnon-virtual-dtor -O2 -g -MD -MQ subprojects/wxWidgets/libcm_wxmono.dylib.p/src_osx_cocoa_utils_base.mm.o -MF subprojects/wxWidgets/libcm_wxmono.dylib.p/src_osx_cocoa_utils_base.mm.o.d -o subprojects/wxWidgets/libcm_wxmono.dylib.p/src_osx_cocoa_utils_base.mm.o -c ../subprojects/wxWidgets/src/osx/cocoa/utils_base.mm
In file included from ../subprojects/wxWidgets/src/osx/cocoa/utils_base.mm:11:
In file included from ../subprojects/wxWidgets/include/wx/wxprec.h:12:
../subprojects/wxWidgets/include/wx/defs.h:62:13: error: "No Target! You should use wx-config program for compilation flags!"
#           error "No Target! You should use wx-config program for compilation flags!"
            ^
In file included from ../subprojects/wxWidgets/src/osx/cocoa/utils_base.mm:18:
In file included from ../subprojects/wxWidgets/include/wx/app.h:19:
In file included from ../subprojects/wxWidgets/include/wx/event.h:22:
../subprojects/wxWidgets/include/wx/cursor.h:108:26: error: calling 'GetBusyCursor' with incomplete return type 'const wxCursor'
            wxSetCursor( wxBusyCursor::GetBusyCursor() );
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/wxWidgets/include/wx/utils.h:770:27: note: 'GetBusyCursor' declared here
    static const wxCursor GetBusyCursor();
                          ^
../subprojects/wxWidgets/include/wx/gdicmn.h:32:28: note: forward declaration of 'wxCursor'
class WXDLLIMPEXP_FWD_CORE wxCursor;
                           ^
In file included from ../subprojects/wxWidgets/src/osx/cocoa/utils_base.mm:18:
In file included from ../subprojects/wxWidgets/include/wx/app.h:19:
../subprojects/wxWidgets/include/wx/event.h:1921:14: error: field has incomplete type 'wxCursor'
    wxCursor m_cursor;
             ^
../subprojects/wxWidgets/include/wx/gdicmn.h:32:28: note: forward declaration of 'wxCursor'
class WXDLLIMPEXP_FWD_CORE wxCursor;
                           ^
In file included from ../subprojects/wxWidgets/src/osx/cocoa/utils_base.mm:18:
In file included from ../subprojects/wxWidgets/include/wx/app.h:19:

@mensinda
Copy link
Member

This looks like a different bug to me. Can you check if there are any differences in the compiler invocation compared to the cpp files (specifically include paths, defines)?

If there are no differences I would need a test case to debug this myself. Does not have to be minimal but it has to run on Linux...

@CoffeeFlux
Copy link
Contributor Author

There are indeed differences. For a while they're identical, but it seems the defines aren't getting passed down when compiling Objective-C++ files. That appears to cause the initial build error in include/wx/defs.h, which includes the following snippet:

#ifdef __cplusplus
/*  Make sure the environment is set correctly */
#   if defined(__WXMSW__) && defined(__X__)
#       error "Target can't be both X and MSW"
#   elif !defined(__WXMOTIF__) && \
         !defined(__WXMSW__)   && \
         !defined(__WXGTK__)   && \
         !defined(__WXOSX_COCOA__)   && \
         !defined(__WXOSX_IPHONE__)   && \
         !defined(__X__)       && \
         !defined(__WXDFB__)   && \
         !defined(__WXX11__)   && \
         !defined(__WXQT__)    && \
          wxUSE_GUI
#       ifdef __UNIX__
#           error "No Target! You should use wx-config program for compilation flags!"
#       else /*  !Unix */
#           error "No Target! You should use supplied makefiles for compilation!"
#       endif /*  Unix/!Unix */
#   endif
#endif /*__cplusplus*/

Sample invocations below:

c++ -Isubprojects/wxWidgets/libcm_wxmono.dylib.p -Isubprojects/wxWidgets -I../subprojects/wxWidgets -I../subprojects/wxWidgets/src/regex -I../subprojects/wxWidgets/src/jpeg -I../subprojects/wxWidgets/src/png -I../subprojects/wxWidgets/src/tiff/libtiff -I../subprojects/wxWidgets/src/stc/scintilla/include -I../subprojects/wxWidgets/src/stc/scintilla/lexlib -I../subprojects/wxWidgets/src/stc/scintilla/src -I/Library/Frameworks/Mono.framework/Versions/6.4.0/include -Isubprojects/wxWidgets/__CMake_build/lib/wx/include/osx_cocoa-unicode-3.1 -I../subprojects/wxWidgets/__CMake_build/lib/wx/include/osx_cocoa-unicode-3.1 -I../subprojects/wxWidgets/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework -Isubprojects/wxWidgets/__CMake_build -I../subprojects/wxWidgets/__CMake_build -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/icu4c/include -flto -Xclang -fcolor-diagnostics -pipe -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++11 -O2 -g -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.10 -Wno-ignored-attributes -pthread -DDLL_EXPORTS -DLINK_LEXERS -DNO_CXX11_REGEX -DSCI_LEXER -DWXBUILDING -DWXMAKINGDLL -DWXUSINGDLL -D_LIB -D_UNICODE -D__WXMAC__ -D__WXOSX_COCOA__ -D__WXOSX__ -D__WX__ -DwxUSE_BASE=1 -DwxUSE_GUI=1 -Dwxmono_EXPORTS -MD -MQ subprojects/wxWidgets/libcm_wxmono.dylib.p/src_unix_utilsunx.cpp.o -MF subprojects/wxWidgets/libcm_wxmono.dylib.p/src_unix_utilsunx.cpp.o.d -o subprojects/wxWidgets/libcm_wxmono.dylib.p/src_unix_utilsunx.cpp.o -c ../subprojects/wxWidgets/src/unix/utilsunx.cpp
c++ -Isubprojects/wxWidgets/libcm_wxmono.dylib.p -Isubprojects/wxWidgets -I../subprojects/wxWidgets -I../subprojects/wxWidgets/src/regex -I../subprojects/wxWidgets/src/jpeg -I../subprojects/wxWidgets/src/png -I../subprojects/wxWidgets/src/tiff/libtiff -I../subprojects/wxWidgets/src/stc/scintilla/include -I../subprojects/wxWidgets/src/stc/scintilla/lexlib -I../subprojects/wxWidgets/src/stc/scintilla/src -I/Library/Frameworks/Mono.framework/Versions/6.4.0/include -Isubprojects/wxWidgets/__CMake_build/lib/wx/include/osx_cocoa-unicode-3.1 -I../subprojects/wxWidgets/__CMake_build/lib/wx/include/osx_cocoa-unicode-3.1 -I../subprojects/wxWidgets/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework -Isubprojects/wxWidgets/__CMake_build -I../subprojects/wxWidgets/__CMake_build -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/icu4c/include -flto -Xclang -fcolor-diagnostics -pipe -Wall -Winvalid-pch -Wnon-virtual-dtor -O2 -g -MD -MQ subprojects/wxWidgets/libcm_wxmono.dylib.p/src_osx_cocoa_utils_base.mm.o -MF subprojects/wxWidgets/libcm_wxmono.dylib.p/src_osx_cocoa_utils_base.mm.o.d -o subprojects/wxWidgets/libcm_wxmono.dylib.p/src_osx_cocoa_utils_base.mm.o -c ../subprojects/wxWidgets/src/osx/cocoa/utils_base.mm

mensinda added a commit to mensinda/meson that referenced this issue Dec 29, 2020
@mensinda
Copy link
Member

OK, seems like this was not a different bug, but a side effect of my fix. Should be fixed now with the updated version of the PR.

@CoffeeFlux
Copy link
Contributor Author

CoffeeFlux commented Dec 29, 2020

Looks like that did the trick, thanks—I'm now able to successfully run off a local build! There's still some issue with CMake not reporting all the required frameworks correctly (it's missing Carbon, in this case), but that's separate and non-blocking since I can just add them to the final linker invocation at a higher level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency:cmake Issues related to `dependency` with the `cmake` method OS:macos Issues specific to Apple Operating Systems like MacOS and iOS subprojects/wraps
Projects
None yet
Development

No branches or pull requests

2 participants