[Piglit] [PATCH 1/6] cmake: Use find_package to find Waffle
groleo at gmail.com
groleo at gmail.com
Wed Oct 24 06:11:27 PDT 2012
From: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
* replace pkg_check_modules with find_package
* add FindWaffle.cmake
Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
---
:100644 100644 2f4c213... 719cda1... M CMakeLists.txt
:000000 100644 0000000... 4bdfef8... A cmake/Modules/FindWaffle.cmake
CMakeLists.txt | 6 ++---
cmake/Modules/FindWaffle.cmake | 57 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f4c213..719cda1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,7 @@ else()
endif()
if(PIGLIT_USE_WAFFLE)
- pkg_check_modules(WAFFLE REQUIRED waffle-1>=1.1.0)
+ find_package(Waffle 1.1.0 REQUIRED)
if(NOT WAFFLE_FOUND)
message(FATAL_ERROR "Failed to find Waffle. If Waffle is not "
@@ -44,8 +44,8 @@ if(PIGLIT_USE_WAFFLE)
endif()
add_definitions(-DPIGLIT_USE_WAFFLE)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WAFFLE_CFLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WAFFLE_CFLAGS}")
+ include_directories(${WAFFLE_INCLUDE_DIR})
+ link_libraries(${WAFFLE_LIBRARY})
endif(PIGLIT_USE_WAFFLE)
if(PIGLIT_BUILD_GLES1_TESTS AND NOT PIGLIT_USE_WAFFLE)
diff --git a/cmake/Modules/FindWaffle.cmake b/cmake/Modules/FindWaffle.cmake
new file mode 100644
index 0000000..4bdfef8
--- /dev/null
+++ b/cmake/Modules/FindWaffle.cmake
@@ -0,0 +1,57 @@
+# Copyright 2012 Intel Corporation
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# - Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# - Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#
+# Locate the Waffle library.
+#
+#
+# Defines the variables:
+# WAFFLE_INCLUDE_DIR Where to look for Waffle headers.
+# WAFFLE_LIBRARY Where to look for Waffle library.
+# WAFFLE_FOUND If FALSE, don't try to use Waffle.
+# WAFFLE_VERSION_STRING Waffle Version: Major.Minor.Patch
+
+find_path(WAFFLE_INCLUDE_DIR
+ NAMES waffle.h
+)
+
+find_library(WAFFLE_LIBRARY
+ NAMES waffle
+)
+
+if(WAFFLE_INCLUDE_DIR AND EXISTS "${WAFFLE_INCLUDE_DIR}/waffle_version.h")
+ file(STRINGS "${WAFFLE_INCLUDE_DIR}/waffle_version.h" WAFFLE_VERSION_H)
+ string(REGEX REPLACE "^.*WAFFLE_MAJOR_VERSION ([0-9]+).*$" "\\1" WAFFLE_MAJOR_VERSION "${WAFFLE_VERSION_H}")
+ string(REGEX REPLACE "^.*WAFFLE_MINOR_VERSION ([0-9]+).*$" "\\1" WAFFLE_MINOR_VERSION "${WAFFLE_VERSION_H}")
+ string(REGEX REPLACE "^.*WAFFLE_PATCH_VERSION ([0-9]+).*$" "\\1" WAFFLE_PATCH_VERSION "${WAFFLE_VERSION_H}")
+ set(WAFFLE_VERSION_STRING "${WAFFLE_MAJOR_VERSION}.${WAFFLE_MINOR_VERSION}.${WAFFLE_PATCH_VERSION}")
+endif()
+
+# handle the 'QUIETLY' and 'REQUIRED' arguments and
+# set 'WAFFLE_FOUND' to TRUE if all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Waffle REQUIRED_VARS WAFFLE_LIBRARY WAFFLE_INCLUDE_DIR VERSION_VAR WAFFLE_VERSION_STRING)
+
+mark_as_advanced(WAFFLE_LIBRARY WAFFLE_INCLUDE_DIR)
--
1.8.0
More information about the Piglit
mailing list