Browse Source

Suppress linker warnings. Minor doc update.

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
6e0ff48059

+ 12 - 10
CMake/Modules/Urho3D-CMake-common.cmake

@@ -70,11 +70,11 @@ if (ANDROID OR RPI OR EMSCRIPTEN)
 else ()
     option (URHO3D_64BIT "Enable 64-bit build" ${URHO3D_DEFAULT_64BIT})
 endif ()
-cmake_dependent_option (URHO3D_ANGELSCRIPT "Enable AngelScript scripting support (non Emscripten only)" TRUE "NOT EMSCRIPTEN" FALSE)
-cmake_dependent_option (URHO3D_LUA "Enable additional Lua scripting support (non Emscripten only)" FALSE "NOT EMSCRIPTEN" FALSE)
-cmake_dependent_option (URHO3D_LUAJIT "Enable Lua scripting support using LuaJIT (check LuaJIT's CMakeLists.txt for more options) (non Emscripten only)" FALSE "NOT EMSCRIPTEN" FALSE)
+cmake_dependent_option (URHO3D_ANGELSCRIPT "Enable AngelScript scripting support" TRUE "NOT EMSCRIPTEN" FALSE)
+cmake_dependent_option (URHO3D_LUA "Enable additional Lua scripting support" FALSE "NOT EMSCRIPTEN" FALSE)
+cmake_dependent_option (URHO3D_LUAJIT "Enable Lua scripting support using LuaJIT (check LuaJIT's CMakeLists.txt for more options)" FALSE "NOT EMSCRIPTEN" FALSE)
 option (URHO3D_NAVIGATION "Enable navigation support" TRUE)
-cmake_dependent_option (URHO3D_NETWORK "Enable networking support (non Emscripten only)" TRUE "NOT EMSCRIPTEN" FALSE)
+cmake_dependent_option (URHO3D_NETWORK "Enable networking support" TRUE "NOT EMSCRIPTEN" FALSE)
 option (URHO3D_PHYSICS "Enable physics support" TRUE)
 option (URHO3D_URHO2D "Enable 2D graphics and physics support" TRUE)
 if (MINGW AND NOT DEFINED URHO3D_SSE)
@@ -88,7 +88,7 @@ if (MINGW AND NOT DEFINED URHO3D_SSE)
 else ()
     set (URHO3D_DEFAULT_SSE TRUE)
 endif ()
-cmake_dependent_option (URHO3D_SSE "Enable SSE instruction set (non Emscripten only)" ${URHO3D_DEFAULT_SSE} "NOT EMSCRIPTEN" FALSE)
+cmake_dependent_option (URHO3D_SSE "Enable SSE instruction set" ${URHO3D_DEFAULT_SSE} "NOT EMSCRIPTEN" FALSE)
 if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
     cmake_dependent_option (URHO3D_LUAJIT_AMALG "Enable LuaJIT amalgamated build (LuaJIT only)" FALSE "URHO3D_LUAJIT" FALSE)
     cmake_dependent_option (URHO3D_SAFE_LUA "Enable Lua C++ wrapper safety checks (Lua/LuaJIT only)" FALSE "URHO3D_LUA OR URHO3D_LUAJIT" FALSE)
@@ -378,7 +378,7 @@ else ()
         if (EMSCRIPTEN)
             # Emscripten-specific setup
             #todo:YWT: set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL=2")
-            set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_SDL=2 -Wno-warn-absolute-paths -Wno-unknown-warning-option")
+            set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-warn-absolute-paths -Wno-unknown-warning-option")
             set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-warn-absolute-paths -Wno-unknown-warning-option")
         elseif (MINGW)
             # MinGW-specific setup
@@ -815,7 +815,9 @@ macro (define_dependency_libs TARGET)
             list (APPEND LIBS dl log android)
         else ()
             # Linux
-            list (APPEND LIBS dl pthread rt)
+            if (NOT EMSCRIPTEN)
+                list (APPEND LIBS dl pthread rt)
+            endif ()
             if (RPI)
                 list (APPEND ABSOLUTE_PATH_LIBS ${BCM_VC_LIBRARIES})
             endif ()
@@ -826,14 +828,14 @@ macro (define_dependency_libs TARGET)
     if (${TARGET} MATCHES Civetweb|kNet|Urho3D)
         if (WIN32)
             list (APPEND LIBS ws2_32)
-        elseif (NOT ANDROID)
+        elseif (NOT ANDROID AND NOT EMSCRIPTEN)
             list (APPEND LIBS pthread)
         endif ()
     endif ()
 
     # Urho3D/LuaJIT external dependency
     if (URHO3D_LUAJIT AND ${TARGET} MATCHES LuaJIT|Urho3D)
-        if (NOT WIN32)
+        if (NOT WIN32 AND NOT EMSCRIPTEN)
             list (APPEND LIBS dl m)
         endif ()
     endif ()
@@ -846,7 +848,7 @@ macro (define_dependency_libs TARGET)
             if (URHO3D_MINIDUMPS)
                 list (APPEND LIBS dbghelp)
             endif ()
-        elseif (NOT ANDROID)
+        elseif (NOT ANDROID AND NOT EMSCRIPTEN)
             list (APPEND LIBS pthread)
         endif ()
 

+ 3 - 2
CMake/Toolchains/emscripten.toolchain.cmake

@@ -20,6 +20,8 @@
 # THE SOFTWARE.
 #
 
+# Based on cmake/Modules/Platform/Emscripten.cmake from https://github.com/kripken/emscripten
+
 cmake_minimum_required (VERSION 2.6.3)
 
 if (CMAKE_TOOLCHAIN_FILE)
@@ -62,11 +64,10 @@ if (NOT EMSCRIPTEN_SYSROOT)
 endif ()
 set (CMAKE_FIND_ROOT_PATH ${EMSCRIPTEN_SYSROOT})
 
-# only search programs, libraries, and headers in the target directories
+# only search libraries, and headers in the target directories
 set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
 
 # Don't do compiler autodetection, since we are cross-compiling.
 include (CMakeForceCompiler)

+ 1 - 1
CMake/Toolchains/raspberrypi.toolchain.cmake

@@ -64,7 +64,7 @@ if (NOT RPI_SYSROOT OR NOT BCM_VC_INCLUDE_DIRS OR NOT BCM_VC_LIBRARIES)
 endif ()
 set (CMAKE_FIND_ROOT_PATH ${RPI_SYSROOT})
 
-# only search programs, libraries, and headers in the target directories
+# only search libraries, and headers in the target directories
 set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

+ 28 - 5
Docs/GettingStarted.dox

@@ -18,6 +18,8 @@ Although all required third-party libraries are included as source code, there a
 
 - For Android, the Android SDK and Android NDK (minimum API level 12) need to be installed.
 
+- For Emscripten, the Emscripten SDK need to be installed.
+
 To run Urho3D, the minimum system requirements are:
 
 - Windows: CPU with SSE instructions support, Windows XP or newer, DirectX 9.0c, GPU with %Shader %Model 2 support (%Shader %Model 3 recommended.)
@@ -30,6 +32,8 @@ To run Urho3D, the minimum system requirements are:
 
 - iOS: OpenGL ES 2.0 capable GPU.
 
+- Emscripten: modern browsers with fast JavaScript engine and HTML5 and WebGL support.
+
 SSE requirement can be eliminated by disabling the use of SSE instruction set, see URHO3D_SSE build option below.
 
 CMake is required to configure and generate the Urho3D project build tree. The minimum required version is 2.8.6. However, it is recommended to use the latest CMake version avaiable out there, especially when targeting Mac OS X and iOS platforms using the latest Xcode version available. This is because Apple is known to change the internal working of Xcode with little regards to other third party build tools, such as CMake.
@@ -66,12 +70,12 @@ A number of build options can be defined when invoking the build scripts or when
 |WIN32                |0|Configure project using MinGW cross-compiler toolchain (cmake_generic.sh only); also applicable when cross-compiling 64-bit Windows platform|
 |IOS                  |0|Configure project for targeting iOS platform (cmake_generic.sh and cmake-gui only)|
 |URHO3D_64BIT         |*|Enable 64bit build, on MSVC default to 0, on other compilers the default is set based on the 64-bit capability of the chosen toolchain on host system|
-|URHO3D_ANGELSCRIPT   |1|Enable AngelScript scripting support (non Emscripten only)|
-|URHO3D_LUA           |0|Enable Lua scripting support (non Emscripten only)|
-|URHO3D_LUAJIT        |0|Enable Lua scripting support using LuaJIT (check LuaJIT's CMakeLists.txt for more options) (non Emscripten only)|
+|URHO3D_ANGELSCRIPT   |1|Enable AngelScript scripting support|
+|URHO3D_LUA           |0|Enable Lua scripting support|
+|URHO3D_LUAJIT        |0|Enable Lua scripting support using LuaJIT (check LuaJIT's CMakeLists.txt for more options)|
 |URHO3D_LUAJIT_AMALG  |0|Enable LuaJIT amalgamated build (LuaJIT only)|
 |URHO3D_SAFE_LUA      |0|Enable Lua C++ wrapper safety checks (Lua/LuaJIT only)|
-|URHO3D_NETWORK       |1|Enable Networking support (non Emscripten only)|
+|URHO3D_NETWORK       |1|Enable Networking support|
 |URHO3D_PHYSICS       |1|Enable Physics support|
 |URHO3D_NAVIGATION    |1|Enable Navigation support|
 |URHO3D_URHO2D        |1|Enable 2D rendering & physics support|
@@ -80,7 +84,7 @@ A number of build options can be defined when invoking the build scripts or when
 |URHO3D_EXTRAS        |0|Build extras (native and RPI only)|
 |URHO3D_DOCS          |0|Generate documentation as part of normal build (the 'doc' builtin target can be used to generate documentation regardless of this option's value)|
 |URHO3D_DOCS_QUIET    |0|Generate documentation as part of normal build, suppress generation process from sending anything to stdout|
-|URHO3D_SSE           |1|Enable SSE instruction set (non Emscripten only)|
+|URHO3D_SSE           |1|Enable SSE instruction set|
 |URHO3D_MINIDUMPS     |1|Enable minidumps on crash (VS only)|
 |URHO3D_FILEWATCHER   |1|Enable filewatcher support|
 |URHO3D_PROFILING     |1|Enable profiling support|
@@ -107,6 +111,8 @@ A number of build options can be defined when invoking the build scripts or when
 |MINGW_SYSROOT        |-|Path to MinGW system root (MinGW cross-compiling build only)|
 |RPI_PREFIX           |-|Prefix path to Raspberry Pi cross-compiler tools (RPI cross-compiling build only)|
 |RPI_SYSROOT          |-|Path to Raspberry Pi system root (RPI cross-compiling build only)|
+|EMSCRIPTEN_ROOT_PATH |-|Root path to Emscripten cross-compiler tools (Emscripten cross-compiling build only)|
+|EMSCRIPTEN_SYSROOT   |-|Path to Emscripten system root (Emscripten cross-compiling build only)|
 
 Note that the specified build option values are cached by CMake after the initial configuration step. The cached values will be used by CMake in the subsequent configuration. The same build options are not required to be specified again and again. But once a non-default build option value is being cached, it can only be reverted back to its default value by explicitly resetting it. That is, simply by not passing the corresponding build option would not revert it back to its default. One way to revert all the build options to their default values is by clearing the CMake cache by calling cmake_clean.bat or cmake_clean.sh.
 
@@ -206,6 +212,23 @@ For activating the MinGW toolchain, and to allow it to find the correct compiler
 
 Execute cmake_mingw.sh then go to the build tree to execute make command. After the build is complete, the Windows executables can be found in the build tree's "bin" subdirectory.
 
+\section Building_Emscripten Emscripten build process
+
+> WHAT DOESN'T WORK:
+>    - %Sound.
+>    - %Terrain rendering.
+>    - Networking. Javascript can only use http and websockets protocols so it's not likely that kNet will ever function.
+>    - Mouse locking.
+>    - All the scripting support: AngelScript and Lua/LuaJIT.
+
+This section assumes you have already updated, installed, and activated the latest Emscripten (trans-)compiler toolchain on your host system as per described in http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html.
+
+Set the EMSCRIPTEN_ROOT_PATH environment variable or build option to point to the root path of Emscripten cross-compiler tools. The Emscripten sysroot path will be derived from the root path, usually from 'system' subdir relative to the root path. However, you can optionally set the EMSCRIPTEN_SYSROOT environment variable or build option to point to another system root path.
+
+On Windows host, execute cmake_emscripten.bat. On OS X or Linux host, execute cmake_emscripten.sh. Then go to the build tree and execute the 'make' command to start the build as usual. You may want to set the URHO3D_SAMPLES build option to build all the samples.
+
+After the commands finish successfully, the HTMLs and its correspondng data files should have been generated in the build tree's "bin" subdirectory, from where it can be launched in a browser.
+
 \section Building_64bit Native 64bit build
 
 When using MSVC compiler, Urho3D common CMake module configures the build tree to target a 32-bit platform by default. When using other non-MSVC compilers (like GCC or Clang), the module sets the default to 32-bit or 64-bit based on the chosen toolchain in the build tree. You can, however, use the "URHO3D_64BIT" build option to override the default, i.e. by setting the option to '0' (for 32-bit) and '1' (for 64-bit) explicitly.

+ 5 - 5
Source/ThirdParty/SDL/CMakeLists.txt

@@ -23,13 +23,11 @@
 # Define target name
 set (TARGET_NAME SDL)
 
-# Install headers for building and using the Urho3D library (install dependency for D3D9GraphicsImpl.h, OGLGraphicsImpl.h, InputEvents.h, File.h, and Cursor.h)
-install_header_files (DIRECTORY include/ DESTINATION ${DEST_INCLUDE_DIR}/ThirdParty/SDL FILES_MATCHING PATTERN *.h USE_FILE_SYMLINK)    # Note: the trailing slash is significant
-
 if (EMSCRIPTEN)
-    # Emscripten has SDL2 port pre-built, so just create a dummy target
-    add_custom_target(${TARGET_NAME} ALL)   # Dummy target just so that its post-build step can install headers to the build tree
+    # Emscripten has SDL2 port pre-built, so just create a dummy target just so that its post-build step can install headers to the build tree
+    add_custom_target (${TARGET_NAME} ALL)
     set (STATIC_LIBRARY_TARGETS ${STATIC_LIBRARY_TARGETS} ${TARGET_NAME} PARENT_SCOPE)
+    install_header_files (DIRECTORY include/ DESTINATION ${DEST_INCLUDE_DIR}/ThirdParty/SDL FILES_MATCHING PATTERN *.h USE_FILE_SYMLINK)    # Note: the trailing slash is significant
     return ()
 endif ()
 
@@ -146,6 +144,8 @@ set (INCLUDE_DIRS include)
 # Setup target
 setup_library ()
 
+# Install headers for building and using the Urho3D library (install dependency for D3D9GraphicsImpl.h, OGLGraphicsImpl.h, InputEvents.h, File.h, and Cursor.h)
+install_header_files (DIRECTORY include/ DESTINATION ${DEST_INCLUDE_DIR}/ThirdParty/SDL FILES_MATCHING PATTERN *.h USE_FILE_SYMLINK)    # Note: the trailing slash is significant
 # Install dependency for SDL_android_main.c
 if (ANDROID)
     install_header_files (DIRECTORY src/main/android DESTINATION ${DEST_INCLUDE_DIR}/ThirdParty/SDL)

+ 1 - 1
Source/ThirdParty/rapidjson/CMakeLists.txt

@@ -24,7 +24,7 @@
 set (TARGET_NAME rapidjson)
 
 # Setup target
-add_custom_target(${TARGET_NAME} ALL)   # Dummy target just so that its post-build step can install headers to the build tree
+add_custom_target (${TARGET_NAME} ALL)   # Dummy target just so that its post-build step can install headers to the build tree
 set (STATIC_LIBRARY_TARGETS ${STATIC_LIBRARY_TARGETS} ${TARGET_NAME} PARENT_SCOPE)
 
 # Install headers for building the Urho3D library

+ 3 - 1
Source/Tools/CMakeLists.txt

@@ -28,7 +28,9 @@ find_package (Urho3D REQUIRED)
 include_directories (${URHO3D_INCLUDE_DIRS})
 
 # Urho3DPlayer target is rather special, although it is here, it is not a tool because it builds into platform-specific binary
-add_subdirectory (Urho3DPlayer)
+if (NOT EMSCRIPTEN)
+    add_subdirectory (Urho3DPlayer)
+endif ()
 
 # Do not build tools for iOS, Android, and Emscripten regardless of the URHO3D_TOOLS build option
 if (NOT IOS AND NOT ANDROID AND NOT EMSCRIPTEN AND URHO3D_TOOLS)