[Piglit] [PATCH 08/13] piglit-framework: Add support for static glfw usage.

Kenney Phillis kphillisjr at gmail.com
Thu Oct 31 15:48:04 CET 2013


Static glfw is to simplify platforms that do not have good support
for waffle. To make use of this feature, Simply download the latest
GLFW release ( for example 3.0.3 ) and follow the next steps.

1) decompress the source release.
2) rename the source release folder to glfw.
3) verify the file layout is correct. In the top layer of the glfw
   folder there should be a cmakelists.txt file.
---
 CMakeLists.txt               |   53 ++++++++++++++++++++++++++++++++++++++----
 tests/util/CMakeLists.gl.txt |    4 +++-
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cd92bbd..3dd488f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,12 +51,48 @@ elseif(PIGLIT_USE_GLFW3)
 	pkg_search_module(GLFW3  glfw3)
 	if(GLFW3_FOUND)
 		include_directories(${GLFW3_INCLUDE_DIRS})
-		#${GLFW_LIBRARIES}
 	else()
-		message(FATAL_ERROR "Failed to find GLFW version 3.\n"
-			"If GLFW3 is not installed, You can download GLFW3 from "
-			"their website at http://www.glfw.org/"
-		)
+		if(EXISTS "${CMAKE_SOURCE_DIR}/glfw/CMakeLists.txt")
+			set(GLFW_BUILD_EXAMPLES OFF CACHE STRING "" FORCE)
+			set(GLFW_BUILD_TESTS OFF CACHE STRING "" FORCE)
+			if(NOT WIN32)
+				set(GLFW_INSTALL OFF CACHE STRING "" FORCE)
+				if ( NOT MSVC)
+					set(BUILD_SHARED_LIBS ON CACHE STRING "" FORCE)
+				else()
+					set(BUILD_SHARED_LIBS ON CACHE STRING "" FORCE)
+				endif()
+			endif(NOT WIN32)
+            if(MSVC)
+                set(GLFW_INSTALL OFF CACHE STRING "" FORCE)
+                set(BUILD_SHARED_LIBS ON CACHE STRING "" FORCE)
+            endif()
+			set(GLFW_VERSION_EXTRA "piglit" CACHE STRING "" FORCE)
+			add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glfw)
+			include_directories(${CMAKE_CURRENT_SOURCE_DIR}/glfw/include)
+			set(GLFW_LIBRARY ${GLFW_LIBRARIES})
+			# tell the rest of the Scripts to rely on internal GLFW3.
+			set(PIGLIT_USE_INTERNAL_GLFW3 ON)
+			set(GLFW3_LIBRARIES glfw ${GLFW_LIBRARIES})
+			if(WIN32)
+                set_target_properties(glfw
+                    PROPERTIES
+                        LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
+                        LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin"
+                        LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin"
+                        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
+                        RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin"
+                        RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin"
+                        )
+                if(MSVC_IDE)
+                endif()
+			endif(WIN32)
+		else()
+			message(FATAL_ERROR "Failed to find GLFW version 3.\n"
+				"If GLFW3 is not installed, You can download GLFW3 from "
+				"their website at http://www.glfw.org/"
+			)
+		endif()
 	endif()
 	 add_definitions(-DPIGLIT_USE_GLFW3)
 else()
@@ -420,6 +456,13 @@ endif ()
 # See http://www.vtk.org/Wiki/CMake:CPackPackageGenerators
 if (WIN32)
 	set (CPACK_GENERATOR "ZIP")
+    # Install all DLL Files that are placed into the bin folder.
+     install (
+        DIRECTORY ${CMAKE_BINARY_DIR}/bin
+        DESTINATION .
+        FILES_MATCHING REGEX ".*\\.(dll)$"
+        REGEX "CMakeFiles|CMakeLists" EXCLUDE
+    )
 else ()
 	set (CPACK_GENERATOR "TBZ2")
 endif ()
diff --git a/tests/util/CMakeLists.gl.txt b/tests/util/CMakeLists.gl.txt
index 715d630..41b82db 100644
--- a/tests/util/CMakeLists.gl.txt
+++ b/tests/util/CMakeLists.gl.txt
@@ -56,5 +56,7 @@ piglit_add_library (piglitutil_${piglit_target_api}
 target_link_libraries(piglitutil_${piglit_target_api}
 	piglitutil
 )
-
+if(PIGLIT_USE_INTERNAL_GLFW3)
+    add_dependencies(${name} glfw)
+endif(PIGLIT_USE_INTERNAL_GLFW3)
 # vim: ft=cmake:
-- 
1.7.9.5



More information about the Piglit mailing list