Parcourir la source

Avoid SDL dependency when building mini Urho for PackageTool target.
[skip appveyor] [ci only: Emscripten]

Yao Wei Tjong 姚伟忠 il y a 10 ans
Parent
commit
32fb97b5c9

+ 5 - 3
Source/Tools/PackageTool/CMakeLists.txt

@@ -85,11 +85,14 @@ if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
 
     # Check existence of stdint.h for LibCpuId
     include (CheckIncludeFiles)
-    CHECK_INCLUDE_FILES (stdint.h HAVE_STDINT_H)
+    check_include_files (stdint.h HAVE_STDINT_H)
     if (HAVE_STDINT_H)
         add_definitions (-DHAVE_STDINT_H)
     endif ()
 
+    # Define that we are building mini Urho
+    add_definitions (-DMINI_URHO)
+
     # Setup SDK-like include dir in the build tree for building the mini-urho
     set (DEST_INCLUDE_DIR include/Urho3D)
     file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)
@@ -97,9 +100,8 @@ if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # Add dependency targets
     add_subdirectory (${BAKED_CMAKE_SOURCE_DIR}/Source/ThirdParty/LibCpuId host/LibCpuId)
     add_subdirectory (${BAKED_CMAKE_SOURCE_DIR}/Source/ThirdParty/LZ4 host/LZ4)
-    add_subdirectory (${BAKED_CMAKE_SOURCE_DIR}/Source/ThirdParty/SDL host/SDL)
     set (INCLUDE_DIRS ${BAKED_CMAKE_BINARY_DIR}/include ${BAKED_CMAKE_BINARY_DIR}/include/Urho3D ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)
-    set (LIBS LibCpuId SDL)
+    set (LIBS LibCpuId)
 endif ()
 
 # Define target name

+ 4 - 0
Source/Urho3D/Core/ProcessUtils.cpp

@@ -74,7 +74,9 @@ inline void SetFPUState(unsigned control)
 
 #endif
 
+#ifndef MINI_URHO
 #include <SDL/SDL.h>
+#endif
 
 #include "../DebugNew.h"
 
@@ -125,7 +127,9 @@ void InitFPU()
 
 void ErrorDialog(const String& title, const String& message)
 {
+#ifndef MINI_URHO
     SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title.CString(), message.CString(), 0);
+#endif
 }
 
 void ErrorExit(const String& message, int exitCode)

+ 8 - 2
Source/Urho3D/IO/FileSystem.cpp

@@ -32,7 +32,11 @@
 #include "../IO/IOEvents.h"
 #include "../IO/Log.h"
 
+#ifndef MINI_URHO
 #include <SDL/SDL_filesystem.h>
+#else
+#include <stdio.h>
+#endif
 
 #include <sys/stat.h>
 
@@ -79,12 +83,12 @@ namespace Urho3D
 
 int DoSystemCommand(const String& commandLine, bool redirectToLog, Context* context)
 {
-#if !defined(NO_POPEN)
+#if !defined(NO_POPEN) && !defined(MINI_URHO)
     if (!redirectToLog)
 #endif
         return system(commandLine.CString());
 
-#if !defined(NO_POPEN)
+#if !defined(NO_POPEN) && !defined(MINI_URHO)
     // Get a platform-agnostic temporary file name for stderr redirection
     String stderrFilename;
     String adjustedCommandLine(commandLine);
@@ -748,6 +752,7 @@ String FileSystem::GetUserDocumentsDir() const
 String FileSystem::GetAppPreferencesDir(const String& org, const String& app) const
 {
     String dir;
+#ifndef MINI_URHO
     char* prefPath = SDL_GetPrefPath(org.CString(), app.CString());
     if (prefPath)
     {
@@ -755,6 +760,7 @@ String FileSystem::GetAppPreferencesDir(const String& org, const String& app) co
         SDL_free(prefPath);
     }
     else
+#endif
         URHO3D_LOGWARNING("Could not get application preferences directory");
 
     return dir;