2
0
Эх сурвалжийг харах

CMake: Configure: Add threading support.

kestred 12 жил өмнө
parent
commit
054cafeac8

+ 44 - 4
dtool/Configure.cmake

@@ -237,7 +237,7 @@ config_package(VRPN)
 #config_package(VORBIS COMMENT "Vorbis Ogg decoder")
 #config_package(VORBIS COMMENT "Vorbis Ogg decoder")
 
 
 
 
-
+### Configure interrogate ###
 message(STATUS "") # simple line break
 message(STATUS "") # simple line break
 if(HAVE_PYTHON)
 if(HAVE_PYTHON)
 	set(USE_INTERROGATE TRUE CACHE BOOL "If true, Panda3D will generate python interfaces")
 	set(USE_INTERROGATE TRUE CACHE BOOL "If true, Panda3D will generate python interfaces")
@@ -252,21 +252,33 @@ else()
 endif()
 endif()
 
 
 
 
+### Configure threading support ###
+# Add basic use flag for threading
 set(USE_THREADS TRUE CACHE BOOL "If true, compile Panda3D with threading support.")
 set(USE_THREADS TRUE CACHE BOOL "If true, compile Panda3D with threading support.")
 if(USE_THREADS)
 if(USE_THREADS)
 	set(HAVE_THREADS TRUE)
 	set(HAVE_THREADS TRUE)
 else()
 else()
 	unset(SIMPLE_THREADS CACHE)
 	unset(SIMPLE_THREADS CACHE)
-	unset(DO_PIPELINING CACHE)
+	unset(OS_SIMPLE_THREADS CACHE)
+endif()
+
+# Configure debug threads
+if(NOT DEFINED OPTIMIZE OR OPTIMIZE LESS 3)
+	set(DEBUG_THREADS ON CACHE BOOL "If on, enables debugging of thread and sync operations (i.e. mutexes, deadlocks)")
+else()
+	set(DEBUG_THREADS OFF CACHE BOOL "If on, enables debugging of thread and sync operations (i.e. mutexes, deadlocks)")
 endif()
 endif()
 
 
+# Add advanced threading configuration
 if(HAVE_THREADS)
 if(HAVE_THREADS)
 	set(SIMPLE_THREADS FALSE CACHE BOOL "If true, compile with simulated threads.")
 	set(SIMPLE_THREADS FALSE CACHE BOOL "If true, compile with simulated threads.")
 	if(SIMPLE_THREADS)
 	if(SIMPLE_THREADS)
 		message(STATUS "Compilation will include simulated threading support.")
 		message(STATUS "Compilation will include simulated threading support.")
-		unset(DO_PIPELINING CACHE)
+		set(OS_SIMPLE_THREADS TRUE CACHE BOOL "If true, OS threading constructs will be used to perform context switches.")
 	else()
 	else()
-		set(DO_PIPELINING TRUE CACHE BOOL "If true, compile with pipelined threads.")
+		unset(OS_SIMPLE_THREADS CACHE)
+
+		set(DO_PIPELINING TRUE CACHE BOOL "If true, compile with pipelined rendering.")
 		if(DO_PIPELINING)
 		if(DO_PIPELINING)
 			message(STATUS "Compilation will include full, pipelined threading support.")
 			message(STATUS "Compilation will include full, pipelined threading support.")
 		else()
 		else()
@@ -277,6 +289,34 @@ else()
 	message(STATUS "Configuring Panda without threading support.")
 	message(STATUS "Configuring Panda without threading support.")
 endif()
 endif()
 
 
+set(HAVE_POSIX_THREADS FALSE)
+if(NOT WIN32)
+	find_path(PTHREAD_IPATH
+		NAMES "pthread.h"
+		PATHS "/usr/include"
+	)
+	if(PTHREAD_IPATH)
+		set(HAVE_POSIX_THREADS TRUE)
+		set(THREAD_LIBS pthread)
+		set(CMAKE_CXX_FLAGS "-pthread")
+		set(CMAKE_CXX_FLAGS_DEBUG "-pthread")
+		set(CMAKE_CXX_FLAGS_RELEASE "-pthread")
+		set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-pthread")
+		set(CMAKE_CXX_FLAGS_MINSIZEREL "-pthread")
+	endif()
+endif()
+
+
+### Configure pipelining ###
+if(NOT DEFINED DO_PIPELINING)
+	if(NOT DEFINED OPTIMIZE OR OPTIMIZE LESS 2)
+		set(DO_PIPELINING TRUE CACHE BOOL "If true, compile with pipelined rendering.")
+	else()
+		set(DO_PIPELINING FALSE CACHE BOOL "If true, compile with pipelined rendering.")
+	endif()
+endif()
+
+### Configure OS X options ###
 if(OSX_PLATFORM)
 if(OSX_PLATFORM)
 	set(UNIVERSIAL_BINARIES TRUE CACHE BOOL "If true, compiling will create universal OS X binaries.")
 	set(UNIVERSIAL_BINARIES TRUE CACHE BOOL "If true, compiling will create universal OS X binaries.")
 	if(UNIVERSAL_BINARIES)
 	if(UNIVERSAL_BINARIES)