Skip to content

Commit

Permalink
Windows|Cygwin: Build configuration and source tweaks for Cygwin
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 8ea084c commit 935c5f2
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 84 deletions.
2 changes: 1 addition & 1 deletion doomsday/cmake/Arch.cmake
Expand Up @@ -4,7 +4,7 @@ set (_bits)

if (ARCH_BITS EQUAL 64)
add_definitions (-DDE_64BIT_HOST=1 -D__64BIT__=1)
if (WIN32)
if (WIN32 OR CYGWIN)
set (DE_ARCH x64)
else ()
set (DE_ARCH x86_64)
Expand Down
14 changes: 8 additions & 6 deletions doomsday/cmake/Config.cmake
Expand Up @@ -31,16 +31,18 @@ set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "client")
if (NOT DE_SDK_DIR STREQUAL "")
list (APPEND CMAKE_PREFIX_PATH "${DE_SDK_DIR}/${DE_INSTALL_LIB_DIR}")
endif ()
list (APPEND CMAKE_PREFIX_PATH "${DE_DISTRIB_DIR}/../deps/products")
list (APPEND CMAKE_MODULE_PATH "${DE_DISTRIB_DIR}/../deps/products/lib/cmake/assimp-4.1")
list (APPEND CMAKE_PREFIX_PATH "${DE_DEPENDS_DIR}/products")
list (APPEND CMAKE_MODULE_PATH "${DE_DEPENDS_DIR}/products/lib/cmake/assimp-4.1")

if (WIN32)
set (MSYS2_LIBS_DIR "" CACHE PATH "msys2-libs directory")
endif ()
# if (WIN32)
# set (MSYS2_LIBS_DIR "" CACHE PATH "msys2-libs directory")
# endif ()

# Platform-Specific Configuration --------------------------------------------

if (IOS)
if (CYGWIN)
include (PlatformCygwin)
elseif (IOS)
include (PlatformiOS)
elseif (APPLE)
include (PlatformMacx)
Expand Down
1 change: 1 addition & 0 deletions doomsday/cmake/Directories.cmake
Expand Up @@ -17,6 +17,7 @@ if (APPLE OR WIN32)
else ()
set_path (DE_DISTRIB_DIR /usr)
endif ()
set (DE_DEPENDS_DIR "${DE_SOURCE_DIR}/../distrib/deps")
set (DE_EXTERNAL_SOURCE_DIR "${DE_SOURCE_DIR}/external")
set (DE_API_DIR "${DE_SOURCE_DIR}/apps/api")
set (DE_SDK_DIR "" CACHE PATH "Location of the Doomsday SDK to use for compiling")
Expand Down
2 changes: 1 addition & 1 deletion doomsday/cmake/FindFMOD.cmake
Expand Up @@ -40,7 +40,7 @@ if (FMOD_FMOD_H AND NOT TARGET fmodex)
elseif (APPLE)
set (fmodLib "${fmodApi}/lib/libfmod.dylib")
set (fmodInstLib ${fmodLib})
elseif (WIN32)
elseif (WIN32 OR CYGWIN)
if (ARCH_BITS EQUAL 64)
set (fmodLib "${fmodApi}/lib/fmod64_vc.lib")
set (fmodInstLib "${fmodApi}/lib/fmod64.dll")
Expand Down
43 changes: 27 additions & 16 deletions doomsday/cmake/FindSDL2Libs.cmake
Expand Up @@ -16,22 +16,26 @@ if (TARGET SDL2)
return ()
endif ()

if (PKG_CONFIG_FOUND AND NOT IOS)
if (PKG_CONFIG_FOUND AND (NOT IOS) AND (NOT CYGWIN))
if (NOT TARGET SDL2)
add_pkgconfig_interface_library (SDL2 OPTIONAL sdl2)
# add_pkgconfig_interface_library (SDL2_ttf OPTIONAL SDL2_ttf)
add_pkgconfig_interface_library (SDL2_mixer OPTIONAL SDL2_mixer)
endif ()

elseif (WIN32)
elseif (WIN32 OR CYGWIN)
# Try to locate SDL2 from the local system (assuming Windows).
set (_oldPath ${SDL2_LIBRARY})
file (GLOB _hints ${SDL2_DIR}/SDL2* $ENV{DENG_DEPEND_PATH}/SDL2*)
find_library (SDL2_LIBRARY SDL2
PATHS ${SDL2_DIR}
HINTS ${_hints} ENV DENG_DEPEND_PATH
PATH_SUFFIXES lib/${DE_ARCH} lib
)
if (CYGWIN)
# Assume it has been set manually.
set (SDL2_LIBRARY ${SDL2_DIR}/lib/${DE_ARCH}/SDL2.lib)
else ()
file (GLOB _hints ${SDL2_DIR}/SDL2* $ENV{DENG_DEPEND_PATH}/SDL2*)
find_library (SDL2_LIBRARY SDL2
PATHS ${SDL2_DIR}
HINTS ${_hints} ENV DENG_DEPEND_PATH
PATH_SUFFIXES lib/${DE_ARCH} lib
)
endif ()
mark_as_advanced (SDL2_LIBRARY)
if (NOT SDL2_LIBRARY)
message (FATAL_ERROR "SDL2 not found. Set the SDL2_DIR variable to help locate it.\n")
Expand All @@ -48,19 +52,26 @@ elseif (WIN32)
get_filename_component (_libDir ${SDL2_LIBRARY} DIRECTORY)
get_filename_component (_incDir ${_libDir}/../../include REALPATH)

# message (STATUS "SDL2 include dir: ${_incDir}")
# message (STATUS "SDL2 library dir: ${_libDir}")

target_include_directories (SDL2 INTERFACE ${_incDir})
deng_install_library (${_libDir}/SDL2.dll)

# Also attempt to locate SLD2_mixer.
set (_oldPath ${SDL_MIXER_LIBRARY})
file (GLOB _hints ${SDL2_DIR}/SDL2_mixer* ${SDL2_MIXER_DIR}/SDL2_mixer*
$ENV{DENG_DEPEND_PATH}/SDL2_mixer*
if (CYGWIN)
set (SDL2_MIXER_LIBRARY ${SDL2_MIXER_DIR}/lib/${DE_ARCH}/SDL2_mixer.lib)
else ()
file (GLOB _hints ${SDL2_DIR}/SDL2_mixer* ${SDL2_MIXER_DIR}/SDL2_mixer*
$ENV{DENG_DEPEND_PATH}/SDL2_mixer*
)
find_library (SDL2_MIXER_LIBRARY SDL2_mixer
PATHS ${SDL2_DIR} ${SDL2_MIXER_DIR}
HINTS ${_hints} ENV DENG_DEPEND_PATH
PATH_SUFFIXES lib/${DE_ARCH} lib
)
find_library (SDL2_MIXER_LIBRARY SDL2_mixer
PATHS ${SDL2_DIR} ${SDL2_MIXER_DIR}
HINTS ${_hints} ENV DENG_DEPEND_PATH
PATH_SUFFIXES lib/${DE_ARCH} lib
)
endif ()
mark_as_advanced (SDL2_MIXER_LIBRARY)
if (NOT _oldPath STREQUAL SDL2_MIXER_LIBRARY)
message (STATUS "Found SDL2_mixer: ${SDL2_MIXER_LIBRARY}")
Expand Down
6 changes: 3 additions & 3 deletions doomsday/cmake/Macros.cmake
Expand Up @@ -183,7 +183,7 @@ function (deng_filter_platform_sources outName)
set (filtered YES)
endif ()
elseif ("${fn}" MATCHES ".*_x11\\..*") # X11 specific files
if (APPLE OR NOT UNIX)
if (APPLE OR CYGWIN OR NOT UNIX)
set (filtered YES)
endif ()
endif ()
Expand Down Expand Up @@ -770,14 +770,14 @@ endfunction (deng_install_tool)
# Not applicable to macOS because libraries are not installed but instead
# bundled with the applicatino.
macro (deng_install_library library)
if (UNIX_LINUX)
if (UNIX_LINUX AND NOT CYGWIN)
string (REGEX REPLACE "(.*)\\.so" "\\1-*.so" versioned ${library})
file (GLOB _links ${library}.* ${versioned})
install (FILES ${library} ${_links}
DESTINATION ${DE_INSTALL_PLUGIN_DIR}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE
)
elseif (MINGW)
elseif (CYGWIN OR MINGW)
message (STATUS "Library will be installed: ${library}")
install (PROGRAMS ${library} DESTINATION bin)
elseif (MSVC)
Expand Down
18 changes: 18 additions & 0 deletions doomsday/cmake/PlatformCygwin.cmake
@@ -0,0 +1,18 @@
include (PlatformGenericUnix)

set (DE_PLATFORM_SUFFIX windows)
set (DE_AMETHYST_PLATFORM WIN32)

# if (NOT CYGWIN)
# set (DE_INSTALL_DATA_DIR "data")
# set (DE_INSTALL_DOC_DIR "doc")
# set (DE_INSTALL_LIB_DIR "bin")
# endif ()

add_definitions (
-D__USE_BSD
-DWINVER=0x0601
-D_WIN32_WINNT=0x0601
-D_GNU_SOURCE=1
-DDE_PLATFORM_ID="win-${DE_ARCH}"
)
2 changes: 1 addition & 1 deletion doomsday/external/lzss/src/lzss.c
Expand Up @@ -69,7 +69,7 @@

// MACROS ------------------------------------------------------------------

#ifndef WIN32
#if !defined (WIN32) && !defined (__CYGWIN__)
//Disable this on Win32 builds because of: warning: "O_BINARY" redefined on mingw
#define O_BINARY 0
#endif
Expand Down
10 changes: 4 additions & 6 deletions doomsday/libs/core/include/de/core/log.h
Expand Up @@ -476,12 +476,10 @@ class DE_PUBLIC LogEntry : public Lockable, public ISerializable

void clear();

void setValue(dint i);
void setValue(duint i);
void setValue(long int i);
void setValue(long unsigned int i);
void setValue(duint64 i);
void setValue(dint64 i);
void setValue(int32_t i);
void setValue(uint32_t i);
void setValue(int64_t i);
void setValue(uint64_t i);
void setValue(ddouble d);
void setValue(void const *p);
void setValue(const char *s);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/core/include/de/data/numbervalue.h
Expand Up @@ -66,7 +66,7 @@ class DE_PUBLIC NumberValue : public Value
explicit NumberValue(duint64 initialUnsignedInteger);
explicit NumberValue(dint32 initialInteger, SemanticHints semantic = Int);
explicit NumberValue(duint32 initialUnsignedInteger, SemanticHints semantic = UInt);
explicit NumberValue(unsigned long initialUnsignedInteger, SemanticHints semantic = UInt);
//explicit NumberValue(unsigned long initialUnsignedInteger, SemanticHints semantic = UInt);
explicit NumberValue(bool initialBoolean);

void setSemanticHints(SemanticHints hints);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/core/include/de/data/record.h
Expand Up @@ -404,7 +404,7 @@ class DE_PUBLIC Record
Variable &set(const String &name, duint64 value);

/// @copydoc set()
Variable &set(const String &name, unsigned long value);
//Variable &set(const String &name, unsigned long value);

/// @copydoc set()
Variable &set(const String &name, Time const &value);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/core/include/de/data/string.h
Expand Up @@ -796,7 +796,7 @@ class DE_PUBLIC String : public IByteArray
static String asText(duint16 value) { return format("%u", value); }
static String asText(duint32 value) { return format("%u", value); }
static String asText(duint64 value) { return format("%llu", value); }
#if !defined (_WIN64) // size_t == uint64
#if __SIZEOF_SIZE_T__ != 8 // already got uint64_t
static String asText(dsize value) { return format("%zu", value); }
#endif
static String asText(dfloat value) { return format("%f", double(value)); }
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/core/include/de/libcore.h
Expand Up @@ -156,7 +156,7 @@

#define DE_ASSERT_FAIL(msgCStr) DE_ASSERT(msgCStr == nullptr)

#ifdef UNIX
#if defined (UNIX) && !defined (__CYGWIN__)
# include <execinfo.h>
/**
* @macro DE_PRINT_BACKTRACE
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libs/core/src/core/app.cpp
Expand Up @@ -632,7 +632,7 @@ NativePath App::nativeHomePath()
#else // UNIX
{
nativeHome = NativePath::homePath();
nativeHome = nativeHome / d->unixHomeFolder / "runtime";
nativeHome = nativeHome / unixHomeFolderName() / "runtime";
}
#endif

Expand Down Expand Up @@ -729,7 +729,7 @@ NativePath App::nativeBasePath()
}

NativePath path;
#ifdef WIN32
#if defined (WIN32) || defined (__CYGWIN__)
{
path = d->appPath.fileNamePath() / "..";
}
Expand Down
22 changes: 4 additions & 18 deletions doomsday/libs/core/src/core/log.cpp
Expand Up @@ -96,48 +96,34 @@ void LogEntry::Arg::clear()
}
}

void LogEntry::Arg::setValue(dint i)
void LogEntry::Arg::setValue(int32_t i)
{
clear();
_type = IntegerArgument;
_data.intValue = i;
}

void LogEntry::Arg::setValue(duint i)
void LogEntry::Arg::setValue(uint32_t i)
{
clear();
_type = IntegerArgument;
_data.intValue = i;
}

void LogEntry::Arg::setValue(long int i)
void LogEntry::Arg::setValue(int64_t i)
{
clear();
_type = IntegerArgument;
_data.intValue = i;
}

void LogEntry::Arg::setValue(long unsigned int i)
{
clear();
_type = IntegerArgument;
_data.intValue = i;
}

void LogEntry::Arg::setValue(duint64 i)
void LogEntry::Arg::setValue(uint64_t i)
{
clear();
_type = IntegerArgument;
_data.intValue = dint64(i);
}

void LogEntry::Arg::setValue(dint64 i)
{
clear();
_type = IntegerArgument;
_data.intValue = i;
}

void LogEntry::Arg::setValue(ddouble d)
{
clear();
Expand Down
6 changes: 3 additions & 3 deletions doomsday/libs/core/src/data/numbervalue.cpp
Expand Up @@ -51,9 +51,9 @@ NumberValue::NumberValue(duint32 initialUnsignedInteger, SemanticHints semantic)
: _value(Number(initialUnsignedInteger)), _semantic(semantic)
{}

NumberValue::NumberValue(unsigned long initialUnsignedInteger, SemanticHints semantic)
: _value(Number(initialUnsignedInteger)), _semantic(semantic)
{}
// NumberValue::NumberValue(unsigned long initialUnsignedInteger, SemanticHints semantic)
// : _value(Number(initialUnsignedInteger)), _semantic(semantic)
// {}

NumberValue::NumberValue(bool initialBoolean)
: _value(initialBoolean ? True : False), _semantic(Boolean)
Expand Down
8 changes: 4 additions & 4 deletions doomsday/libs/core/src/data/record.cpp
Expand Up @@ -716,10 +716,10 @@ Variable &Record::set(const String &name, duint64 value)
return set(name, NumberValue(value));
}

Variable &Record::set(const String &name, unsigned long value)
{
return set(name, NumberValue(value));
}
// Variable &Record::set(const String &name, unsigned long value)
// {
// return set(name, NumberValue(value));
// }

Variable &Record::set(const String &name, Time const &value)
{
Expand Down
24 changes: 7 additions & 17 deletions doomsday/libs/gui/CMakeLists.txt
Expand Up @@ -55,38 +55,28 @@ else ()
message (FATAL_ERROR "Invalid value for OpenGL API: ${DE_OPENGL_API}")
endif ()

# Link libraries.
deng_link_libraries (libgui PUBLIC DengComms)
target_link_libraries (libgui
PUBLIC glbinding::glbinding
PRIVATE SDL2 stb assimp
)
if (WIN32)
target_link_libraries (libgui PUBLIC opengl32.lib)
# Direct2D is used for DPI information.
target_link_libraries (libgui PRIVATE d2d1.lib)
# Direct2D was used for DPI information.
# target_link_libraries (libgui PRIVATE d2d1.lib)
endif ()
if (CYGWIN)
target_compile_options (libgui PUBLIC -mwindows)
target_link_libraries (libgui PUBLIC ole32)
endif ()

# if (UNIX AND NOT APPLE)
# # The assimp target may be linked to some system libraries that
# # must be linked publicly (rather than privately like is the
# # done for libassimp).
# get_property (assimpLibs TARGET libassimp PROPERTY INTERFACE_LINK_LIBRARIES)
# target_link_libraries (libgui PUBLIC ${assimpLibs})
# endif ()

if (IOS)
link_framework (libgui PRIVATE OpenGLES)
elseif (APPLE)
link_framework (libgui PRIVATE Cocoa)
link_framework (libgui PRIVATE OpenGL)
endif ()

#if (DE_X11)
# target_include_directories (libgui PRIVATE ${X11_INCLUDE_DIR})
# target_link_libraries (libgui PRIVATE ${X11_LIBRARIES})
# deng_target_link_qt (libgui PRIVATE X11Extras)
#endif ()

deng_deploy_library (libgui DengGui)

if (WIN32)
Expand Down
1 change: 1 addition & 0 deletions doomsday/libs/gui/src/dialogs/filedialog_windows.cpp
Expand Up @@ -20,6 +20,7 @@

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <initguid.h>
#include <shobjidl.h>

namespace de {
Expand Down
2 changes: 1 addition & 1 deletion doomsday/tools/texc/texc.cpp
Expand Up @@ -47,7 +47,7 @@ patch_t plist;

// CODE --------------------------------------------------------------------

#ifdef UNIX
#if defined(UNIX) && !defined(__CYGWIN__)
void strupr(char* str)
{
for (char* c = str; *c; c++) *c = toupper(*c);
Expand Down

0 comments on commit 935c5f2

Please sign in to comment.