-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve WinMain linking issues with CMake
- Loading branch information
1 parent
b1781f4
commit 77753c8
Showing
6 changed files
with
34 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ add_library(librw_skeleton | |
imgui/stb_textedit.h | ||
imgui/stb_truetype.h | ||
) | ||
add_library(librw::skeleton ALIAS librw_skeleton) | ||
|
||
set_target_properties(librw_skeleton | ||
PROPERTIES | ||
|
@@ -38,6 +37,20 @@ target_include_directories(librw_skeleton | |
$<INSTALL_INTERFACE:${LIBRW_INSTALL_INCLUDEDIR}/skeleton> | ||
) | ||
|
||
# HACK: When building with MinGW, it's necessary to link to libmingw32.a *before* the library | ||
# that provides WinMain. To work around this, an intermediate target is created when using MinGW | ||
# that specifies the correct linking order. | ||
# | ||
# TODO: Use SDL_main on platforms that require it | ||
if(MINGW AND LIBRW_PLATFORM_D3D9) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ccawley2011
Author
Contributor
|
||
add_library(librw_skeleton_main INTERFACE) | ||
find_library(MINGW32_LIBRARY NAMES mingw32) | ||
target_link_libraries(librw_skeleton_main INTERFACE ${MINGW32_LIBRARY} librw_skeleton) | ||
add_library(librw::skeleton ALIAS librw_skeleton_main) | ||
else() | ||
add_library(librw::skeleton ALIAS librw_skeleton) | ||
endif() | ||
|
||
if(LIBRW_INSTALL) | ||
install( | ||
FILES | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
#ifdef LIBRW_SDL2 | ||
|
||
#ifdef _WIN32 | ||
#define SDL_MAIN_HANDLED | ||
#endif | ||
#include <rw.h> | ||
#include "skeleton.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
#include <cstring> | ||
#include <cassert> | ||
|
||
#define SDL_MAIN_HANDLED | ||
#include <rw.h> | ||
|
||
using namespace std; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
#include <string.h> | ||
#include <assert.h> | ||
|
||
#define SDL_MAIN_HANDLED | ||
#include <rw.h> | ||
#include <args.h> | ||
|
||
|
What is your mingw toolchain? I'ld like to experiment with this.
mingw-w64 on Windows? Some mingw toolchain on Linux?