فهرست منبع

Fix MinGW build on Windows host system.

Yao Wei Tjong 姚伟忠 11 سال پیش
والد
کامیت
2e9d9f4806
4فایلهای تغییر یافته به همراه9 افزوده شده و 5 حذف شده
  1. 4 3
      CMake/Modules/Urho3D-CMake-common.cmake
  2. 1 0
      Rakefile
  3. 3 1
      Source/Urho3D/CMakeLists.txt
  4. 1 1
      Source/Urho3D/Revision.h

+ 4 - 3
CMake/Modules/Urho3D-CMake-common.cmake

@@ -412,9 +412,10 @@ macro (create_symlink SOURCE DESTINATION)
         endif ()
         if (URHO3D_MKLINK)
             if (NOT EXISTS ${DESTINATION})
-                file (TO_NATIVE_PATH ${DESTINATION} NATIVE_DESTINATION)
-                file (TO_NATIVE_PATH ${SOURCE} NATIVE_SOURCE)
-                execute_process (COMMAND cmd /C mklink ${SLASH_D} ${NATIVE_DESTINATION} ${NATIVE_SOURCE} OUTPUT_QUIET ERROR_QUIET)
+                # Have to use string-REPLACE as file-TO_NATIVE_PATH does not work as expected with MinGW on "backward host" system
+                string (REPLACE / \\ BACKWARD_DESTINATION ${DESTINATION})
+                string (REPLACE / \\ BACKWARD_SOURCE ${SOURCE})
+                execute_process (COMMAND cmd /C mklink ${SLASH_D} ${BACKWARD_DESTINATION} ${BACKWARD_SOURCE} OUTPUT_QUIET ERROR_QUIET)
             endif ()
         elseif (${ARGN} STREQUAL FALLBACK_TO_COPY)
             if (NOT IS_ABSOLUTE ${SOURCE})

+ 1 - 0
Rakefile

@@ -72,6 +72,7 @@ task :cmake do
       platform = option
       build_options = "#{build_options} -D#{option == 'mingw' ? 'WIN32' : option.upcase}=1" unless script == 'cmake_clean'
       script = 'cmake_macosx' if option == 'ios'
+      script = 'cmake_mingw' if option == 'mingw' && ENV['OS']
     when 'fix_scm'
       build_options = "#{build_options} --fix-scm" if script == 'cmake_eclipse'
     else

+ 3 - 1
Source/Urho3D/CMakeLists.txt

@@ -135,7 +135,9 @@ if (MSVC)
     set (MSVC_WORKAROUND MSVC-WORKAROUND)
 endif ()
 # Add include directories to find the precompiled header, export header, and installed headers from thirdparty libs
-set (INCLUDE_DIRS_ONLY ${CMAKE_CURRENT_SOURCE_DIR} ${MSVC_WORKAROUND} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)
+# Hack: the ${CMAKE_CURRENT_SOURCE_DIR}/generated is added so that "../Urho3D.h" include path could be resolved back to CMAKE_CURRENT_BINARY_DIR where this generated header is located
+#       the "../Urho3D.h" relative path is preferred over "Urho3D.h" because we want to avoid adding "include/Urho3D" into the search path when *using* the library
+set (INCLUDE_DIRS_ONLY ${CMAKE_CURRENT_SOURCE_DIR} ${MSVC_WORKAROUND} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/generated ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)
 if (URHO3D_PHYSICS)
     # Bullet library depends on its own include dir to be added in the header search path
     # This is more practical than patching its header files in many places to make them work with relative path

+ 1 - 1
Source/Urho3D/Revision.h

@@ -22,7 +22,7 @@
 
 #pragma once
 
-#include "../Urho3D.h"
+#include "Urho3D.h"
 
 namespace Urho3D
 {