[Mesa-dev] [PATCH] osdemos: support building via cmake

Tommy mesilliac at tomanui.nz
Fri Sep 22 11:37:43 UTC 2017


Uses pkg-config to find osmesa, and builds only if found.
---
 CMakeLists.txt             |  1 +
 src/CMakeLists.txt         |  4 ++++
 src/osdemos/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 100644 src/osdemos/CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc1caa05..cda9f3bd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,7 @@ if (PKG_CONFIG_FOUND AND NOT WIN32)
 	pkg_check_modules (GLESV1 glesv1_cm)
 	pkg_check_modules (GLESV2 glesv2)
 	pkg_check_modules (VG vg)
+	pkg_check_modules (OSMESA osmesa)
 endif ()
 
 # Check for FreeGLUT 2.6 or later
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4e1c54ee..29a9d4c7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -25,6 +25,10 @@ if (X11_FOUND)
 	add_subdirectory (xdemos)
 endif (X11_FOUND)
 
+if (OSMESA_FOUND)
+	add_subdirectory (osdemos)
+endif (OSMESA_FOUND)
+
 if (WIN32)
 	add_subdirectory (wgl)
 endif (WIN32)
diff --git a/src/osdemos/CMakeLists.txt b/src/osdemos/CMakeLists.txt
new file mode 100644
index 00000000..25ded209
--- /dev/null
+++ b/src/osdemos/CMakeLists.txt
@@ -0,0 +1,31 @@
+include_directories (
+	${CMAKE_SOURCE_DIR}/src/util
+	${OSMESA_INCLUDE_DIRS}
+	${OPENGL_INCLUDE_PATH}
+)
+
+link_directories (
+	${CMAKE_SOURCE_DIR}/src/util
+	${OSMESA_LIBRARY_DIRS}
+)
+
+link_libraries (
+	util
+	${OSMESA_LIBRARIES}
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+)
+
+set (subdir osdemos)
+
+set (targets
+	osdemo
+	osdemo16
+	osdemo32
+)
+
+foreach (target ${targets})
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
+endforeach (target)
-- 
2.14.1



More information about the mesa-dev mailing list