Skip to content

Commit

Permalink
Windows|Cygwin: Fixed build and runtime issues
Browse files Browse the repository at this point in the history
Do not use SDL2main.lib since Cygwin handles the WinMain stuff for us.
Also default to hidden symbol visibility for everything, exporting only
the marked symbols.
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 279a311 commit 02b9ca6
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -37,6 +37,7 @@ precompiled.h.cpp
*.xcuserdatad
*.xcscmblueprint
.vscode
.vsbuild
compile_commands.json
/products
/debian
Expand Down
4 changes: 4 additions & 0 deletions doomsday/apps/client/src/main_client.cpp
Expand Up @@ -41,6 +41,8 @@
* another loop that continues handling events received by the application.
*/

#define SDL_MAIN_HANDLED

#include "clientapp.h"
#include "dd_loop.h"
#include "dd_version.h"
Expand All @@ -67,6 +69,8 @@ DE_EXTERN_C void GameKit_Init();
*/
int main(int argc, char **argv)
{
SDL_SetMainReady();

init_Foundation();
GameKit_Init();
int exitCode = 0;
Expand Down
3 changes: 0 additions & 3 deletions doomsday/cmake/FindSDL2Libs.cmake
Expand Up @@ -54,9 +54,6 @@ elseif (WIN32 OR CYGWIN)

# Define the target.
add_library (SDL2 INTERFACE)
if (CYGWIN)
target_link_libraries(SDL2 INTERFACE ${sdlRoot}/lib/${DE_ARCH}/SDL2main.lib)
endif ()
target_link_libraries (SDL2 INTERFACE ${SDL2_LIBRARY})

# Deduce the include directory.
Expand Down
4 changes: 4 additions & 0 deletions doomsday/cmake/PlatformCygwin.cmake
Expand Up @@ -20,3 +20,7 @@ if (CMAKE_COMPILER_IS_GNUCXX)
append_unique (CMAKE_CXX_FLAGS -Werror=return-type)
append_unique (CMAKE_CXX_FLAGS -fdiagnostics-color)
endif ()

# All symbols are hidden by default.
append_unique (CMAKE_C_FLAGS "-fvisibility=hidden")
append_unique (CMAKE_CXX_FLAGS "-fvisibility=hidden")
2 changes: 1 addition & 1 deletion doomsday/libs/core/include/de/libcore.h
Expand Up @@ -114,7 +114,7 @@
# define DE_PUBLIC __declspec(dllimport)
# endif
# define DE_NORETURN __declspec(noreturn)
#elif defined (MACOSX)
#elif defined (MACOSX) || defined(__CYGWIN__)
//# ifdef __LIBCORE__
# define DE_PUBLIC __attribute__((visibility("default")))
//# else
Expand Down
16 changes: 10 additions & 6 deletions doomsday/libs/core/include/de/liblegacy.h
Expand Up @@ -53,18 +53,22 @@

#include <de/libcore.h>

#if defined (DE_STATIC_LINK)
# define DE_ENTRYPOINT static
#else
# define DE_ENTRYPOINT DE_EXTERN_C DE_PUBLIC
#endif

#ifdef __cplusplus
# define DE_EXTERN_C extern "C"
#else
# define DE_EXTERN_C extern
#endif

#if defined (DE_STATIC_LINK)
# define DE_ENTRYPOINT static
#else
# ifdef _MSC_VER
# define DE_ENTRYPOINT DE_EXTERN_C __declspec(dllexport)
# else
# define DE_ENTRYPOINT DE_EXTERN_C DE_PUBLIC
# endif
#endif

#ifndef NDEBUG
# if !defined (_DEBUG)
# define _DEBUG 1
Expand Down
2 changes: 0 additions & 2 deletions doomsday/libs/core/src/data/info.cpp
Expand Up @@ -627,8 +627,6 @@ DE_PIMPL(Info)
String includePath;
String content = finder->findIncludedInfoSource(includeName, self(), &includePath);

LOG_MSG("Including: %s") << includePath;

Info included;
included.setImplicitBlockType(implicitBlockType);
included.setScriptBlocks(compose<StringList>(scriptBlockTypes.begin(),
Expand Down
10 changes: 8 additions & 2 deletions doomsday/libs/doomsday/include/doomsday/world/entitydef.h
Expand Up @@ -45,7 +45,12 @@ typedef struct mapentitypropertydef_s {
/**
* @ingroup world
*/
typedef struct LIBDOOMSDAY_PUBLIC mapentitydef_s {
typedef struct
#ifdef __cplusplus
LIBDOOMSDAY_PUBLIC
#endif
mapentitydef_s
{
/// Unique identifier associated with this entity.
int id;

Expand All @@ -56,7 +61,8 @@ typedef struct LIBDOOMSDAY_PUBLIC mapentitydef_s {
#ifdef __cplusplus
mapentitydef_s(int _id) : id(_id), numProps(0), props(0) {}
#endif
} MapEntityDef;
}
MapEntityDef;

#ifdef __cplusplus
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libs/gamekit/src/libgamekit.cpp
Expand Up @@ -19,14 +19,14 @@
//#include "gamekit/libgamekit.h"
#include <de/Extension>
#include <de/Log>
#include <de/liblegacy.h>

DE_EXTENSION(doom);
DE_EXTENSION(doom64);
DE_EXTENSION(heretic);
DE_EXTENSION(hexen);

DE_PUBLIC DE_EXTERN_C
void GameKit_Init()
DE_ENTRYPOINT void GameKit_Init()
{
LOG_AS("GameKit");
LOG_MSG("Initializing...");
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/gui/src/graphics/gltextureframebuffer.cpp
Expand Up @@ -261,9 +261,9 @@ void GLTextureFramebuffer::resize(Size const &newSize)

void GLTextureFramebuffer::resolveSamples()
{
//if (d->isMultisampled())
if (d->resolvedFbo.isReady())
{
DE_ASSERT(d->isMultisampled());
// Copy the framebuffer contents to the textures (that have no multisampling).
blit(d->resolvedFbo, ColorDepthStencil);
}
Expand Down
4 changes: 4 additions & 0 deletions doomsday/tests/test_glsandbox/main.cpp
Expand Up @@ -21,12 +21,16 @@

#include <de/GuiApp>
#include <de/LogBuffer>

#define SDL_MAIN_HANDLED
#include <SDL_main.h>

using namespace de;

DE_EXTERN_C int main(int argc, char **argv)
{
SDL_SetMainReady();

int exitCode = -1;
init_Foundation();
try
Expand Down

0 comments on commit 02b9ca6

Please sign in to comment.