From dd178de4e54e6771c2dd6aaa04c397469e5950ba Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Mon, 9 Sep 2013 15:37:14 -0500 Subject: cmake,dma_buf: Refactor decisions to build dma_buf tests This patch unifies the logic for deciding (1) to build dma_buf support into libpiglitutil and (2) to build the ext_image_dma_buf_import tests. In doing so, the patch creates a new CMake option, PIGLIT_BUILD_DMA_BUF_TESTS. It doesn't make sense to do (1) without (2) because the tests would all skip. There does exist some logic in the ext_image_dma_buf_import CMakeLists to prevent the tests from getting built without (1), but the logic is incopmlete. This patch's unification fixes the incompleteness. During Piglit's initial configuration, CMake chooses a default value of PIGLIT_BUILD_DMA_BUF_TESTS based on what packages are present on the system. Tested-by: Ian Romanick Signed-off-by: Chad Versace --- CMakeLists.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index a39d9dfe3..2aba8448a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,11 +89,38 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") add_definitions(-DPIGLIT_HAS_GLX) pkg_check_modules(LIBDRM QUIET libdrm) + pkg_check_modules(LIBDRM_INTEL QUIET libdrm_intel) + pkg_check_modules(XCB_DRI2 QUIET xcb-dri2) option(PIGLIT_BUILD_GLX_TESTS "Build tests that require GLX" ON) ELSE() option(PIGLIT_BUILD_GLX_TESTS "Build tests that require GLX" OFF) ENDIF() + +# Choose to build tests that use dma_buf. +# +# The presence of libdrm is not sufficient. At least one libdrm_${hardware} +# library is also needed. +# +if(LIBDRM_FOUND AND LIBDRM_INTEL_FOUND) + set(PIGLIT_BUILD_DMA_BUF_TESTS_IS_VALID true) +else() + set(PIGLIT_BUILD_DMA_BUF_TESTS_IS_VALID false) +endif() + +if(PIGLIT_BUILD_DMA_BUF_TESTS_IS_VALID) + option(PIGLIT_BUILD_DMA_BUF_TESTS "Build tests that use dma_buf" ON) +else() + option(PIGLIT_BUILD_DMA_BUF_TESTS "Build tests that use dma_buf" OFF) +endif() + +# If the users has updated PIGLIT_BUILD_DMA_BUF_TESTS in the CMakeCache, then +# we need to validate it. +if(PIGLIT_BUILD_DMA_BUF_TESTS AND NOT PIGLIT_BUILD_DMA_BUF_TESTS_IS_VALID) + message(FATAL_ERROR + "PIGLIT_BUILD_DMA_BUF_TESTS require libdrm and libdrm_intel") +endif() + IF(PIGLIT_BUILD_GLX_TESTS) pkg_check_modules(GLPROTO REQUIRED glproto) ENDIF() -- cgit v1.2.3