Hijack SDL2 and GLEW include and library when compiling to javascript
authorkoda
Thu, 21 Apr 2016 00:10:23 -0400
changeset 11657 ae6706411b24
parent 11656 227718170097
child 11658 f87ed83568c8
Hijack SDL2 and GLEW include and library when compiling to javascript emscripten already provides the SDL2 suite and will simply ignore missing libraries.
cmake_modules/FindGLEW.cmake
cmake_modules/FindSDL2.cmake
cmake_modules/FindSDL2_image.cmake
cmake_modules/FindSDL2_mixer.cmake
cmake_modules/FindSDL2_net.cmake
cmake_modules/FindSDL2_ttf.cmake
--- a/cmake_modules/FindGLEW.cmake	Thu Apr 21 00:09:07 2016 -0400
+++ b/cmake_modules/FindGLEW.cmake	Thu Apr 21 00:10:23 2016 -0400
@@ -34,6 +34,11 @@
             $ENV{PROGRAMFILES}/GLEW/lib
             DOC "The GLEW library")
 
+if(BUILD_ENGINE_JS)
+    set(GLEW_INCLUDE_DIR "${EMSCRIPTEN_ROOT_PATH}/system/include")
+    SET(GLEW_LIBRARY "glew_emscripten_internal")
+endif()
+
 find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_DIR)
 mark_as_advanced(GLEW_LIBRARY GLEW_INCLUDE_DIR)
 
--- a/cmake_modules/FindSDL2.cmake	Thu Apr 21 00:09:07 2016 -0400
+++ b/cmake_modules/FindSDL2.cmake	Thu Apr 21 00:10:23 2016 -0400
@@ -158,6 +158,11 @@
     SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
 ENDIF(SDL2_LIBRARY_TEMP)
 
+if(BUILD_ENGINE_JS)
+    set(SDL2_LIBRARY "sdl2_emscripten_internal" CACHE STRING "emscripten override" FORCE)
+    set(SDL2_INCLUDE_DIR "${CMAKE_SYSTEM_INCLUDE_PATH}/SDL" CACHE STRING "emscripten override" FORCE)
+endif()
+
 INCLUDE(FindPackageHandleStandardArgs)
 
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
--- a/cmake_modules/FindSDL2_image.cmake	Thu Apr 21 00:09:07 2016 -0400
+++ b/cmake_modules/FindSDL2_image.cmake	Thu Apr 21 00:10:23 2016 -0400
@@ -74,6 +74,12 @@
 set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
 set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
 
+if(BUILD_ENGINE_JS)
+    set(SDL2_IMAGE_LIBRARY "sdl2_image_emscripten_internal")
+    set(SDL2_IMAGE_LIBRARIES "sdl2_image_emscripten_internal")
+    set(SDL2_IMAGE_INCLUDE_DIRS "${CMAKE_SYSTEM_INCLUDE_PATH}/SDL")
+endif()
+
 include(FindPackageHandleStandardArgs)
 
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
--- a/cmake_modules/FindSDL2_mixer.cmake	Thu Apr 21 00:09:07 2016 -0400
+++ b/cmake_modules/FindSDL2_mixer.cmake	Thu Apr 21 00:10:23 2016 -0400
@@ -74,6 +74,12 @@
 set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
 set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
 
+if(BUILD_ENGINE_JS)
+    set(SDL2_MIXER_LIBRARY "sdl2_mixer_emscripten_internal")
+    set(SDL2_MIXER_LIBRARIES "sdl2_mixer_emscripten_internal")
+    set(SDL2_MIXER_INCLUDE_DIRS "${CMAKE_SYSTEM_INCLUDE_PATH}/SDL")
+endif()
+
 include(FindPackageHandleStandardArgs)
 
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
--- a/cmake_modules/FindSDL2_net.cmake	Thu Apr 21 00:09:07 2016 -0400
+++ b/cmake_modules/FindSDL2_net.cmake	Thu Apr 21 00:10:23 2016 -0400
@@ -74,6 +74,12 @@
 set(SDL2_NET_LIBRARIES ${SDL2_NET_LIBRARY})
 set(SDL2_NET_INCLUDE_DIRS ${SDL2_NET_INCLUDE_DIR})
 
+if(BUILD_ENGINE_JS)
+    set(SDL2_NET_LIBRARY "sdl2_net_emscripten_internal")
+    set(SDL2_NET_LIBRARIES "sdl2_net_emscripten_internal")
+    set(SDL2_NET_INCLUDE_DIRS "${CMAKE_SYSTEM_INCLUDE_PATH}/SDL")
+endif()
+
 include(FindPackageHandleStandardArgs)
 
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_net
--- a/cmake_modules/FindSDL2_ttf.cmake	Thu Apr 21 00:09:07 2016 -0400
+++ b/cmake_modules/FindSDL2_ttf.cmake	Thu Apr 21 00:10:23 2016 -0400
@@ -74,6 +74,12 @@
 set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
 set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
 
+if(BUILD_ENGINE_JS)
+    set(SDL2_TTF_LIBRARY "sdl2_ttf_emscripten_internal")
+    set(SDL2_TTF_LIBRARIES "sdl2_ttf_emscripten_internal")
+    set(SDL2_TTF_INCLUDE_DIRS "${CMAKE_SYSTEM_INCLUDE_PATH}/SDL")
+endif()
+
 include(FindPackageHandleStandardArgs)
 
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf