Skip to content

Commit

Permalink
CMake: reworked SDL2 lookup & update depended projects
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg committed Aug 7, 2018
1 parent d16dfa5 commit 29bb39f
Show file tree
Hide file tree
Showing 24 changed files with 91 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Externals/OPCODE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../../src
${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
${SDL_INCLUDE_DIR}
${SDL_INCLUDE_DIRS}
)

add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})
Expand Down
48 changes: 25 additions & 23 deletions Externals/cximage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,39 @@ cmake_minimum_required(VERSION 2.8.0)
project(cximage)

set(SOURCES
ximacfg.cpp
ximaenc.cpp
ximaexif.cpp
ximage.cpp
ximainfo.cpp
ximaint.cpp
ximajpg.cpp
ximalpha.cpp
ximalyr.cpp
ximapal.cpp
ximasel.cpp
ximath.cpp
xmemfile.cpp
ximacfg.cpp
ximaenc.cpp
ximaexif.cpp
ximage.cpp
ximainfo.cpp
ximaint.cpp
ximajpg.cpp
ximalpha.cpp
ximalyr.cpp
ximapal.cpp
ximasel.cpp
ximath.cpp
xmemfile.cpp
)

set(HEADERS
xfile.h
ximacfg.h
ximadef.h
ximage.h
ximaiter.h
ximajpg.h
ximath.h
xiofile.h
xmemfile.h
xfile.h
ximacfg.h
ximadef.h
ximage.h
ximaiter.h
ximajpg.h
ximath.h
xiofile.h
xmemfile.h
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive --std=c++14")
add_definitions(-DCXIMAGE_BUILD)

include_directories("." ${CMAKE_SOURCE_DIR})
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)

add_library(cximage STATIC ${SOURCES} ${HEADERS})

Expand Down
4 changes: 2 additions & 2 deletions cmake/FindSDL2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ find_package_handle_standard_args(SDL REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR
VERSION_VAR SDL_VERSION)

if(SDL_FOUND)
set(SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIRS})
set(SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIR})

if(NOT SDL_LIBRARIES)
set(SDL_LIBRARIES ${SDL_LIBRARY})
Expand Down Expand Up @@ -157,4 +157,4 @@ if(SDL_FOUND)

add_dependencies(SDL::SDL SDL::main)
endif()
endif()
endif()
13 changes: 1 addition & 12 deletions src/Common/PlatformLinux.inl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include <dirent.h>
#include <utime.h>

#include <SDL2/SDL.h>
#define CONFIG_USE_SDL

#define _LINUX // for GameSpy

#if !defined(__INTEL_COMPILER)
Expand Down Expand Up @@ -85,11 +82,6 @@ inline pthread_t GetCurrentThreadId()
return pthread_self();
}

inline void Sleep(int ms)
{
SDL_Delay(ms);
}

inline void _splitpath (
const char* path, // Path Input
char* drive, // Drive : Output
Expand Down Expand Up @@ -196,8 +188,7 @@ typedef LONG_PTR LPARAM;
typedef long HRESULT;
typedef long LRESULT;
typedef long _W64;
//typedef void* HWND;
typedef SDL_Window* HWND;
typedef void* HWND;
typedef void* HDC;
typedef float FLOAT;
typedef unsigned char UINT8;
Expand Down Expand Up @@ -291,8 +282,6 @@ inline int _filelength(int fd)
#define __max(a, b) std::max(a, b)
#define __min(a, b) std::min(a, b)

#define itoa SDL_itoa
#define _itoa_s(value, buffer, radix) SDL_itoa(value, buffer, radix)
#define _locale_t locale_t
#define _isalpha_l isalpha_l
#define _create_locale(category, arg) newlocale(category, arg, (locale_t) 0)
Expand Down
11 changes: 6 additions & 5 deletions src/utils/xrLCUtil/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
project(xrLCUtil)

list(APPEND DIRS
"."
)
"."
)

add_dir("${DIRS}")

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../..
${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/include
)
${CMAKE_CURRENT_SOURCE_DIR}/../..
${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/include
${SDL_INCLUDE_DIRS}
)

list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./LevelCompilerLoggerWindow.cpp")
list(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./LevelCompilerLoggerWindow.hpp")
Expand Down
3 changes: 2 additions & 1 deletion src/utils/xrLCUtil/xrThread.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "pch.hpp"
#include "xrThread.hpp"
#include "SDL.h"

void CThread::StubLog(const char*, ...) {}
void CThread::startup(void* P)
Expand Down Expand Up @@ -30,7 +31,7 @@ void CThreadManager::wait(u32 sleep_time)
return;
for (;;)
{
Sleep(sleep_time);
SDL_Delay(sleep_time);

perf[0] = 0;
float sumProgress = 0;
Expand Down
1 change: 1 addition & 0 deletions src/utils/xrMiscMath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ add_dir("${DIRS}")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../..
${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/include
${SDL_INCLUDE_DIRS}
)

#list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./LevelCompilerLoggerWindow.cpp")
Expand Down
11 changes: 6 additions & 5 deletions src/utils/xrQSlim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
project(xrQSlim)

list(APPEND DIRS
"src"
)
"src"
)

add_dir("${DIRS}")

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../..
${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/include
)
${CMAKE_CURRENT_SOURCE_DIR}/../..
${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/include
${SDL_INCLUDE_DIRS}
)

#list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./LevelCompilerLoggerWindow.cpp")
#ist(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./LevelCompilerLoggerWindow.hpp")
Expand Down
1 change: 1 addition & 0 deletions src/xrAICore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/luabind
${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
${SDL_INCLUDE_DIRS}
)

#foreach(header ${${PROJECT_NAME}__INCLUDES})
Expand Down
2 changes: 1 addition & 1 deletion src/xrCDB/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_dir("${DIRS}")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
${SDL_INCLUDE_DIR}
${SDL_INCLUDE_DIRS}
)

add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})
Expand Down
1 change: 1 addition & 0 deletions src/xrCore/Animation/Motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Motion.hpp"
#include "xrCore/Animation/Envelope.hpp"
#include "SDL.h"

#define EOBJ_OMOTION 0x1100
#define EOBJ_SMOTION 0x1200
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/pugixml/src
#${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
${SDL_INCLUDE_DIR}
${SDL_INCLUDE_DIRS}
${TBB_INCLUDE_DIRS}
)

Expand Down
3 changes: 2 additions & 1 deletion src/xrCore/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#endif
#include <sys/stat.h>
#include <fcntl.h>
#include "SDL.h"

#pragma warning(pop)

Expand Down Expand Up @@ -121,7 +122,7 @@ bool file_handle_internal(LPCSTR file_name, u32& size, int& file_handle)
{
if (open_internal(file_name, file_handle))
{
Sleep(1);
SDL_Delay(1);
if (open_internal(file_name, file_handle))
return (false);
}
Expand Down
3 changes: 3 additions & 0 deletions src/xrCore/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ void MakeFilter(string1024& dest, LPCSTR info, LPCSTR ext)
// start_flt_ext = -1-all 0..n-indices
//------------------------------------------------------------------------------

#if defined(WINDOWS)

// Vista uses this hook for old-style save dialog
UINT_PTR CALLBACK OFNHookProcOldStyle(HWND, UINT, WPARAM, LPARAM)
{
// let default hook work on this message
return 0;
}
#endif

bool EFS_Utils::GetOpenNameInternal(
LPCSTR initial, LPSTR buffer, int sz_buf, bool bMulti, LPCSTR offset, int start_flt_ext)
Expand Down
5 changes: 3 additions & 2 deletions src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "file_stream_reader.h"
#include "xrCore/Threading/Lock.hpp"
#if defined(LINUX)
#include "SDL.h"
#include "xrstring.h"
#include <glob.h>
#endif
Expand Down Expand Up @@ -179,7 +180,7 @@ CLocatorAPI::~CLocatorAPI()
{
VERIFY(0 == m_iLockRescan);
_dump_open_files(1);
delete m_auth_lock;
delete m_auth_lock;
}

const CLocatorAPI::file* CLocatorAPI::RegisterExternal(pcstr name)
Expand Down Expand Up @@ -629,7 +630,7 @@ bool CLocatorAPI::Recurse(pcstr path)
while (done != -1)
{
#if defined(LINUX)
xr_strcpy(findData.name, sizeof globbuf.gl_pathv[handle - done], globbuf.gl_pathv[handle - done]);
xr_strcpy(findData.name, sizeof globbuf.gl_pathv[handle - done], globbuf.gl_pathv[handle - done]);
struct stat fi;
stat(findData.name, &fi);
findData.size = fi.st_size;
Expand Down
12 changes: 12 additions & 0 deletions src/xrCore/_std_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <float.h>
#include <stdio.h>
#include "xrCommon/math_funcs_inline.h"
#include "SDL.h"
//#include "xr_token.h"

#ifdef abs
Expand Down Expand Up @@ -257,6 +258,17 @@ inline int xr_strcat(char(&destination)[count], LPCSTR source)
}
//#endif // #ifndef _EDITOR

#if defined(LINUX)

#define itoa SDL_itoa
#define _itoa_s(value, buffer, radix) SDL_itoa(value, buffer, radix)

inline void Sleep(int ms)
{
SDL_Delay(ms);
}
#endif

inline void MemFill32(void* dst, u32 value, size_t dstSize)
{
u32* ptr = static_cast<u32*>(dst);
Expand Down
4 changes: 3 additions & 1 deletion src/xrCore/ppmd_compressor.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "stdafx.h"
#include "ppmd_compressor.h"
#include "PPMd.h"
#include "SDL.h"

#if defined(LINUX)


LONG InterlockedExchange(LONG volatile *dest, LONG val)
{
LONG ret;
Expand All @@ -26,7 +28,7 @@ static LONG PPMd_Locked = 0;
static inline void PPMd_Lock()
{
while (::InterlockedExchange(&PPMd_Locked, 1))
::Sleep(0);
SDL_Delay(0);
}

static inline void PPMd_Unlock() { ::InterlockedExchange(&PPMd_Locked, 0); }
Expand Down
1 change: 1 addition & 0 deletions src/xrCore/xrstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "xrCore/_std_extensions.h"

#include "FS_impl.h"
#include "SDL.h"

XRCORE_API str_container* g_pStringContainer = NULL;

Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/OpenAutomate/inc
${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/luabind
${SDL_INCLUDE_DIR}
${SDL_INCLUDE_DIRS}
${FREEIMAGE_INCLUDE_PATH}
${LOCKFILE_INCLUDE_DIR}
)
Expand Down
1 change: 0 additions & 1 deletion src/xrEngine/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase

public:
SDL_Window* m_sdlWnd;
LRESULT MsgProc(HWND, UINT, WPARAM, LPARAM);

// u32 dwFrame;
// u32 dwPrecacheFrame;
Expand Down
1 change: 1 addition & 0 deletions src/xrParticles/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ add_dir("${DIRS}")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
${SDL_INCLUDE_DIRS}
)

#list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./xr_cda.cpp")
Expand Down
13 changes: 9 additions & 4 deletions src/xrScriptEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
project(xrScriptEngine)

list(APPEND DIRS
"."
"LuaStudio"
)
"."
"LuaStudio"
)

add_dir("${DIRS}")

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/luabind ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include )
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/luabind
${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
${SDL_INCLUDE_DIRS}
)

add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})

Expand Down
Loading

0 comments on commit 29bb39f

Please sign in to comment.