浏览代码

CMake: changes to support Emscripten build

Closes #1069
rdb 5 年之前
父节点
当前提交
05403ab04a
共有 2 个文件被更改,包括 17 次插入1 次删除
  1. 12 1
      dtool/Config.cmake
  2. 5 0
      dtool/src/prc/CMakeLists.txt

+ 12 - 1
dtool/Config.cmake

@@ -30,10 +30,15 @@ if(DEFINED CMAKE_CXX_FLAGS_COVERAGE)
 endif()
 endif()
 
 
 # Are we building with static or dynamic linking?
 # Are we building with static or dynamic linking?
+if(EMSCRIPTEN)
+  set(_default_shared OFF)
+else()
+  set(_default_shared ON)
+endif()
 option(BUILD_SHARED_LIBS
 option(BUILD_SHARED_LIBS
   "Causes subpackages to be built separately -- setup for dynamic linking.
   "Causes subpackages to be built separately -- setup for dynamic linking.
 Utilities/tools/binaries/etc are then dynamically linked to the
 Utilities/tools/binaries/etc are then dynamically linked to the
-libraries instead of being statically linked." ON)
+libraries instead of being statically linked." ${_default_shared})
 
 
 option(BUILD_METALIBS
 option(BUILD_METALIBS
   "Should we build 'metalibs' -- fewer, larger libraries that contain the bulk
   "Should we build 'metalibs' -- fewer, larger libraries that contain the bulk
@@ -524,12 +529,18 @@ set(THREADS_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
 set(HAVE_POSIX_THREADS ${CMAKE_USE_PTHREADS_INIT})
 set(HAVE_POSIX_THREADS ${CMAKE_USE_PTHREADS_INIT})
 
 
 # Add basic use flag for threading
 # Add basic use flag for threading
+if(EMSCRIPTEN)
+  set(_default_threads OFF)
+else()
+  set(_default_threads ON)
+endif()
 package_option(THREADS
 package_option(THREADS
   "If on, compile Panda3D with threading support.
   "If on, compile Panda3D with threading support.
 Building in support for threading will enable Panda to take
 Building in support for threading will enable Panda to take
 advantage of multiple CPU's if you have them (and if the OS
 advantage of multiple CPU's if you have them (and if the OS
 supports kernel threads running on different CPU's), but it will
 supports kernel threads running on different CPU's), but it will
 slightly slow down Panda for the single CPU case."
 slightly slow down Panda for the single CPU case."
+  DEFAULT ${_default_threads}
   IMPORTED_AS Threads::Threads)
   IMPORTED_AS Threads::Threads)
 
 
 # Configure debug threads
 # Configure debug threads

+ 5 - 0
dtool/src/prc/CMakeLists.txt

@@ -69,6 +69,11 @@ if(ANDROID)
     androidLogStream.cxx)
     androidLogStream.cxx)
 endif()
 endif()
 
 
+if(EMSCRIPTEN)
+  set(P3PRC_SOURCES ${P3PRC_SOURCES}
+    emscriptenLogStream.cxx)
+endif()
+
 if(HAVE_OPENSSL)
 if(HAVE_OPENSSL)
   list(APPEND P3PRC_SOURCES encryptStreamBuf.cxx encryptStream.cxx)
   list(APPEND P3PRC_SOURCES encryptStreamBuf.cxx encryptStream.cxx)
 endif()
 endif()