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

Fix mingw build #108

Merged
merged 2 commits into from
Jul 9, 2020
Merged

Fix mingw build #108

merged 2 commits into from
Jul 9, 2020

Conversation

cloudwu
Copy link
Contributor

@cloudwu cloudwu commented Jul 9, 2020

I have tried to build RmiUI with mingw/gcc today, and I found

  1. The samples need link shlwapi, but https://github.com/mikke89/RmlUi/blob/master/Samples/shell/src/win32/ShellWin32.cpp#L37 only works for msvc.
  2. mingw/gcc has already defined the macro NOMINMAX.
  3. mingw/gcc has not defined the macro WIN32. (Only used in https://github.com/mikke89/RmlUi/blob/master/Samples/basic/treeview/src/FileSystem.cpp , and I guess using RMLUI_PLATFORM_WIN32 instead would be better ? )

This PR may fixes these issues.

@mikke89
Copy link
Owner

mikke89 commented Jul 9, 2020

Thank you for the PR!

Can I ask for these changes:

  • I'd prefer it if we replaced the WIN32 macro with RMLUI_PLATFORM_WIN32 as you suggest.
  • With the changed CMake configuration we should be able to remove #pragma lib.

We should probably update the Appveyor configuration to also test mingw, but we can do that later.

@rokups
Copy link
Contributor

rokups commented Jul 9, 2020

add_definitions(-DWIN32)

  • Never use add_definitions(), always use target_compile_definitions(). Seems like CMakeLists.txt could use a cleanup.
  • MinGW defines _WIN32, same as original windows SDK. _WIN32 should be used in some header to define RMLUI_PLATFORM_WIN32 if we want a nicer-looking define.

target_link_libraries(${NAME} shlwapi)

Could be improved by changing it to target_link_libraries(${NAME} PUBLIC shlwapi) to clearly state that targets linking to our library should also link to shlwapi.

@mikke89
Copy link
Owner

mikke89 commented Jul 9, 2020

  • Never use add_definitions(), always use target_compile_definitions(). Seems like CMakeLists.txt could use a cleanup.

Yeah, we have a lot of legacy baggage here. If anyone is up to the task... ;)

  • MinGW defines _WIN32, same as original windows SDK. _WIN32 should be used in some header to define RMLUI_PLATFORM_WIN32 if we want a nicer-looking define.

We already have this define, just need to make use of it in this case.

target_link_libraries(${NAME} shlwapi)

Could be improved by changing it to target_link_libraries(${NAME} PUBLIC shlwapi) to clearly state that targets linking to our library should also link to shlwapi.

To be clear, only the sample 'shell' uses this library. It should be sufficient to declare only on the shell target (with the PUBLIC clarifier) which would be preferable.

@cloudwu
Copy link
Contributor Author

cloudwu commented Jul 9, 2020

Done.

@mikke89 mikke89 merged commit 2981774 into mikke89:master Jul 9, 2020
@mikke89
Copy link
Owner

mikke89 commented Jul 9, 2020

Great one, thank you!

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