[Piglit] [PATCH 11/15] piglit-dispatch: CMake code to build generated files
Paul Berry
stereotype441 at gmail.com
Fri Mar 2 15:40:29 PST 2012
This patch adds the necessary build infrastructure to build
piglit-dispatch's two generated files, generated_dispatch.c and
generated_dispatch.h.
These files can be built by invoking "make piglit_dispatch_gen" from
the toplevel source directory.
---
CMakeLists.txt | 21 +++++++++++++++++
cmake/piglit_dispatch.cmake | 53 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)
create mode 100644 cmake/piglit_dispatch.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d4b5b2a..c5cbcaa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,6 +12,7 @@ find_package(TIFF)
find_package(GLUT REQUIRED)
find_package(PNG REQUIRED)
find_package(X11)
+find_package(PkgConfig)
# Check for presence of Python 2.6 or greater.
foreach(python_cmd python2 python)
@@ -129,11 +130,31 @@ check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(GLAPI glapi)
+ if(GLAPI_FOUND)
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=datadir glapi
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ OUTPUT_VARIABLE glapi_datadir
+ RESULT_VARIABLE glapi_datadir_result)
+ endif(GLAPI_FOUND)
+endif(PKG_CONFIG_FOUND)
+if(glapi_datadir)
+ SET(GLAPI_XML_PATH ${glapi_datadir}/xml/glapi CACHE PATH
+ "Path to the shared GL API XML files" FORCE)
+else(glapi_datadir)
+ SET(GLAPI_XML_PATH NOTFOUND CACHE PATH
+ "Path to the shared GL API XML files")
+endif(glapi_datadir)
+
configure_file(
"${piglit_SOURCE_DIR}/tests/util/config.h.in"
"${piglit_SOURCE_DIR}/tests/util/config.h"
)
+include(cmake/piglit_dispatch.cmake)
+
include_directories(src)
add_subdirectory(cmake/target_api)
add_subdirectory(generated_tests)
diff --git a/cmake/piglit_dispatch.cmake b/cmake/piglit_dispatch.cmake
new file mode 100644
index 0000000..d03bc21
--- /dev/null
+++ b/cmake/piglit_dispatch.cmake
@@ -0,0 +1,53 @@
+# Copyright 2012 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+if(NOT GLAPI_XML_PATH EQUAL NOTFOUND)
+ set(piglit_dispatch_gen_output_dir ${CMAKE_SOURCE_DIR}/tests/util)
+
+ set(piglit_dispatch_gen_outputs
+ ${piglit_dispatch_gen_output_dir}/generated_dispatch.c
+ ${piglit_dispatch_gen_output_dir}/generated_dispatch.h
+ )
+
+ set(piglit_dispatch_gen_inputs
+ ${CMAKE_SOURCE_DIR}/tests/util/gen_dispatch.py
+ ${GLAPI_XML_PATH}/gl_API.xml
+ )
+
+ file(GLOB piglit_dispatch_gen_xml_inputs
+ ${GLAPI_XML_PATH}/*.xml)
+
+ set(piglit_dispatch_gen_deps
+ ${piglit_dispatch_gen_inputs}
+ ${piglit_dispatch_gen_xml_inputs}
+ )
+
+ add_custom_command(
+ OUTPUT ${piglit_dispatch_gen_outputs}
+ DEPENDS ${piglit_dispatch_gen_deps}
+ COMMAND ${python} ${piglit_dispatch_gen_inputs} ${piglit_dispatch_gen_outputs}
+ )
+
+ add_custom_target(piglit_dispatch_gen
+ DEPENDS ${piglit_dispatch_gen_outputs}
+ )
+
+endif(NOT GLAPI_XML_PATH EQUAL NOTFOUND)
--
1.7.7.6
More information about the Piglit
mailing list