How about this beast (yeah i had to do slight update/rewrite) :]

For your question aboud CXXFLAGS, i added there section where you can express 
yourself :P Search for # HERE SET DESIRED DEBUG USEFLAGS comment in root 
CMakeLists.txt

Also note preffered build cycle:

cd piglit
mkdir build
cd build
cmake ..
make
make install
# this is without root cause it install back into the source dir
# ( note that uninstall target is availible :] )

Test and report issues. It build for me 100% correctly so i hope i catched 
everything.

Cheers
From 4bea0b061ef2b3afd78dbb5944b73f78e69be233 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <[email protected]>
Date: Sat, 21 Nov 2009 01:49:49 +0100
Subject: [PATCH] Fix cmake build system to work correctly with newer cmake and represent the dependencies properly.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit


Signed-off-by: Tomáš Chvátal <[email protected]>
---
 CMakeLists.txt                      |   71 ++++++++++++++++++++-------
 cmake/cmake_uninstall.cmake.in      |   21 ++++++++
 cmake/modules/FindGLEW.cmake        |   32 ++++++++++++
 tests/CMakeLists.txt                |    1 -
 tests/asmparsertest/CMakeLists.txt  |   23 ++++-----
 tests/bugs/CMakeLists.txt           |   58 +++++++++++------------
 tests/fbo/CMakeLists.txt            |   43 ++++++++---------
 tests/general/CMakeLists.txt        |   63 ++++++++-----------------
 tests/glean/CMakeLists.txt          |   16 ++++---
 tests/glslparsertest/CMakeLists.txt |   25 ++++------
 tests/mesa/CMakeLists.txt           |    5 +-
 tests/mesa/tests/CMakeLists.txt     |   38 ++++++++-------
 tests/mesa/util/CMakeLists.txt      |   27 ++++++----
 tests/shaders/CMakeLists.txt        |   90 ++++++++--------------------------
 tests/texturing/CMakeLists.txt      |   82 ++++++++++++++++++--------------
 tests/util/CMakeLists.txt           |    9 ++-
 16 files changed, 315 insertions(+), 289 deletions(-)
 create mode 100644 cmake/cmake_uninstall.cmake.in
 create mode 100644 cmake/modules/FindGLEW.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b5f9e6d..566faf3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,26 +1,61 @@
-INCLUDE (CheckCCompilerFlag)
-
 project (piglit)
 
-include(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
-include(${CMAKE_ROOT}/Modules/FindTIFF.cmake)
-include(${CMAKE_ROOT}/Modules/FindGLUT.cmake)
-include(${CMAKE_ROOT}/Modules/FindPNG.cmake)
+# HACK TO KEEP PREVIOUS BEHAVIOR
+# WE SHOULD HAVE PROPER DATA INSTALL PATH AND ALLOW IN-TREE GLOBAL INSTALL
+SET ( CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}" )
 
-CHECK_C_COMPILER_FLAG("-Wall" C_COMPILER_FLAG_WALL)
-IF (C_COMPILER_FLAG_WALL)
-	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
-ENDIF (C_COMPILER_FLAG_WALL)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
+
+# cmake policies
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
+if(COMMAND cmake_policy)
+    cmake_policy(SET CMP0003 NEW)
+endif(COMMAND cmake_policy)
+set(CMAKE_COLOR_MAKEFILE ON)
+
+# uninstall
+CONFIGURE_FILE (
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+  IMMEDIATE @ONLY )
+ADD_CUSTOM_TARGET ( uninstall "${CMAKE_COMMAND}"
+  -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
 
-FIND_LIBRARY( GLEW_glew_LIBRARY GLEW
-	/usr/lib
-)
+# set build type
+#set(DEFAULT_BUILD_TYPE "RelWithDebugInfo")
+set(DEFAULT_BUILD_TYPE "Debugfull")
+if(NOT CMAKE_BUILD_TYPE)
+	set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING "CMake Build Type" FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
 
-FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
-      /usr/include/GL
-)
+# compiler quirks
+if(CMAKE_COMPILER_IS_GNUCXX)
+	# HERE SET DESIRED DEBUG USEFLAGS
+	set(CMAKE_C_FLAGS_DEBUGFULL "-ggdb")
+endif(CMAKE_COMPILER_IS_GNUCXX)
 
-set(EXECUTABLE_OUTPUT_PATH ${piglit_SOURCE_DIR}/bin)
-set(LIBRARY_OUTPUT_PATH ${piglit_SOURCE_DIR}/bin)
+include (CheckCCompilerFlag)
+CHECK_C_COMPILER_FLAG("-Wall" C_COMPILER_FLAG_WALL)
+if(C_COMPILER_FLAG_WALL)
+	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+endif(C_COMPILER_FLAG_WALL)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
 
+# global dependencies
+find_package(OpenGL REQUIRED)
+find_package(GLEW REQUIRED)
+find_package(GLUT REQUIRED)
+
+# code
 add_subdirectory (tests)
+
+# PRINT OUT ENVIRONMENT
+message(STATUS "<Printing out environment settings>")
+message(STATUS "<******************************>")
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+message(STATUS "Additional CFlags: ${CMAKE_C_FLAGS}")
+message(STATUS "Additional CXXFlags: ${CMAKE_CXX_FLAGS}")
+message(STATUS "Additional LDflags: ${CMAKE_LINK_FLAGS}")
+message(STATUS "INSTALL PREFIX: ${CMAKE_INSTALL_PREFIX}")
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..cd4c9d8
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,21 @@
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+	MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+	MESSAGE(STATUS "Uninstalling: \"$ENV{DESTDIR}${file}\"")
+	IF(EXISTS "$ENV{DESTDIR}${file}")
+		EXEC_PROGRAM(
+		"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+		OUTPUT_VARIABLE rm_out
+		RETURN_VALUE rm_retval
+		)
+		IF(NOT "${rm_retval}" STREQUAL 0)
+			MESSAGE(FATAL_ERROR "Problem when removing: \"$ENV{DESTDIR}${file}\"")
+		ENDIF(NOT "${rm_retval}" STREQUAL 0)
+	ELSE(EXISTS "$ENV{DESTDIR}${file}")
+		MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+	ENDIF(EXISTS "$ENV{DESTDIR}${file}")
+ENDFOREACH(file)
diff --git a/cmake/modules/FindGLEW.cmake b/cmake/modules/FindGLEW.cmake
new file mode 100644
index 0000000..445ff56
--- /dev/null
+++ b/cmake/modules/FindGLEW.cmake
@@ -0,0 +1,32 @@
+# - Find GLEW
+# Find the GLEW includes and library
+#
+#  GLEW_INCLUDE_DIR - where to find zip.h, etc.
+#  GLEW_LIBRARIES   - List of libraries when using zip.
+#  GLEW_FOUND       - True if zip found.
+
+if(GLEW_LIBRARIES AND GLEW_INCLUDE_DIR)
+	# Already in cache, be silent
+	SET(GLEW_FIND_QUIETLY TRUE)
+else(GLEW_LIBRARIES AND GLEW_INCLUDE_DIR)
+	find_path(GLEW_INCLUDE_DIR glew.h
+		PATH
+		/usr/local/include/GL
+		/usr/include/GL
+	)
+	find_library(GLEW_LIBRARIES libGLEW.so
+		PATH_SUFFIXES lib64 lib
+		PATH
+		/usr/local
+		/usr
+	)
+
+	include(FindPackageHandleStandardArgs)
+	FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLEW DEFAULT_MSG GLEW_LIBRARIES GLEW_INCLUDE_DIR)
+	if(NOT GLEW_FOUND)
+		if(GLEW_REQUIRED)
+			message(FATAL_ERROR "GLEW not found")
+		endif(GLEW_REQUIRED)
+		set(GLEW_LIBRARIES)
+	endif(NOT GLEW_FOUND)
+endif(GLEW_LIBRARIES AND GLEW_INCLUDE_DIR)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index cdd3a4e..c91a455 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,4 +1,3 @@
-
 add_subdirectory (util)
 add_subdirectory (bugs)
 add_subdirectory (fbo)
diff --git a/tests/asmparsertest/CMakeLists.txt b/tests/asmparsertest/CMakeLists.txt
index 4c30b32..e2e03c6 100644
--- a/tests/asmparsertest/CMakeLists.txt
+++ b/tests/asmparsertest/CMakeLists.txt
@@ -1,20 +1,17 @@
-
 include_directories(
-	${OPENGL_INCLUDE_PATH}
-	${GLUT_INCLUDE_DIR}
-	${piglit_SOURCE_DIR}/tests/util
+	${OPENGL_INCLUDE_DIR}
 	${GLEW_INCLUDE_DIR}
+	${GLUT_INCLUDE_DIR}
+	${CMAKE_SOURCE_DIR}/tests/util
 )
 
-link_directories (
-	${piglit_SOURCE_DIR}/tests/util
-)
-
-link_libraries (
+add_executable(asmparsertest asmparsertest.c)
+add_dependencies(asmparsertest piglitutil)
+target_link_libraries(asmparsertest
 	piglitutil
-	${OPENGL_gl_LIBRARY}
-	${GLUT_glut_LIBRARY}
-	${GLEW_glew_LIBRARY}
+	${OPENGL_LIBRARIES}
+	${GLEW_LIBRARIES}
+	${GLUT_LIBRARIES}
 )
 
-add_executable (asmparsertest asmparsertest.c)
+install(TARGETS asmparsertest RUNTIME DESTINATION bin)
diff --git a/tests/bugs/CMakeLists.txt b/tests/bugs/CMakeLists.txt
index e621f8a..d35065d 100644
--- a/tests/bugs/CMakeLists.txt
+++ b/tests/bugs/CMakeLists.txt
@@ -1,36 +1,34 @@
-
 include_directories(
-	${OPENGL_INCLUDE_PATH}
-	${GLUT_INCLUDE_DIR}
-	${piglit_SOURCE_DIR}/tests/mesa/util
-	${piglit_SOURCE_DIR}/tests/util
+	${OPENGL_INCLUDE_DIR}
 	${GLEW_INCLUDE_DIR}
+	${GLUT_INCLUDE_DIR}
+	${CMAKE_SOURCE_DIR}/tests/util
 )
 
-link_directories (
-	${piglit_SOURCE_DIR}/tests/mesa/util
-)
+# use for loop for easier recognition
+file(GLOB _bin_files *.c)
+foreach(_current_bin_file ${_bin_files})
+	get_filename_component( _bin ${_current_bin_file} NAME_WE )
+	add_executable(${_bin} ${_current_bin_file})
+	add_dependencies(${_bin} piglitutil)
+	target_link_libraries(${_bin}
+		piglitutil
+		${OPENGL_LIBRARIES}
+		${GLUT_LIBRARIES}
+		${GLEW_LIBRARIES}
+	)
+	install(TARGETS ${_bin} RUNTIME DESTINATION bin)
+endforeach(_current_bin_file ${_bin_files})
+
 
-link_libraries (
-	piglitutil
-	${OPENGL_gl_LIBRARY}
-	${OPENGL_glu_LIBRARY}
-	${GLUT_glut_LIBRARY}
-	${TIFF_LIBRARY}
-	${GLEW_glew_LIBRARY}
-)
 
-add_executable (crash-cubemap-order crash-cubemap-order.c)
-add_executable (crash-texparameter-before-teximage crash-texparameter-before-teximage.c)
-add_executable (fdo9833 fdo9833.c)
-add_executable (fdo10370 fdo10370.c)
-add_executable (fdo14575 fdo14575.c)
-add_executable (r300-readcache r300-readcache.c)
-add_executable (tex1d-2dborder tex1d-2dborder.c)
-add_executable (fdo20701 fdo20701.c)
-add_executable (point-sprite point-sprite.c)
-add_executable (fdo22540 fdo22540.c)
-add_executable (fdo23489 fdo23489.c)
-add_executable (fdo23670-depth_test fdo23670-depth_test.c)
-add_executable (fdo23670-drawpix_stencil fdo23670-drawpix_stencil.c)
-add_executable (fdo24066 fdo24066.c)
+# EXAMPLE OF PER TARGET INSTALL IF LOOP IS NOT SUFFICIENT
+#add_executable(crash-cubemap-order crash-cubemap-order.c)
+#add_dependencies(crash-cubemap-order piglitutil)
+#target_link_libraries(crash-cubemap-order
+#	piglitutil
+#	${OPENGL_LIBRARIES}
+#	${GLEW_LIBRARIES}
+#	${GLUT_LIBRARIES}
+#)
+#install(TARGETS crash-cubemap-order RUNTIME DESTINATION bin)
diff --git a/tests/fbo/CMakeLists.txt b/tests/fbo/CMakeLists.txt
index c3c77ef..2fd1a48 100644
--- a/tests/fbo/CMakeLists.txt
+++ b/tests/fbo/CMakeLists.txt
@@ -1,29 +1,26 @@
+# find pakcages that are required since this target
+find_package(TIFF REQUIRED)
 
 include_directories(
-	${OPENGL_INCLUDE_PATH}
+	${OPENGL_INCLUDE_DIR}
 	${GLUT_INCLUDE_DIR}
-	${piglit_SOURCE_DIR}/tests/mesa/util
-	${piglit_SOURCE_DIR}/tests/util
 	${GLEW_INCLUDE_DIR}
+	${CMAKE_SOURCE_DIR}/tests/util
+	${CMAKE_SOURCE_DIR}/tests/mesa/util
 )
 
-link_directories (
-	${piglit_SOURCE_DIR}/tests/mesa/util
-	${piglit_SOURCE_DIR}/tests/util
-)
-
-link_libraries (
-	piglitutil
-	${OPENGL_gl_LIBRARY}
-	${OPENGL_glu_LIBRARY}
-	${GLUT_glut_LIBRARY}
-	${TIFF_LIBRARY}
-	${GLEW_glew_LIBRARY}
-)
-
-add_executable (fbo-1d fbo-1d.c)
-add_executable (fbo-3d fbo-3d.c)
-add_executable (fbo-clearmipmap fbo-clearmipmap.c)
-add_executable (fbo-generatemipmap fbo-generatemipmap.c)
-add_executable (fbo-readpixels fbo-readpixels.c)
-add_executable (fbo-cubemap fbo-cubemap.c)
+# use for loop for easier recognition
+file(GLOB _bin_files *.c)
+foreach(_current_bin_file ${_bin_files})
+	get_filename_component( _bin ${_current_bin_file} NAME_WE )
+	add_executable(${_bin} ${_current_bin_file})
+	add_dependencies(${_bin} piglitutil)
+	target_link_libraries(${_bin}
+		piglitutil
+		${OPENGL_LIBRARIES}
+		${GLUT_LIBRARIES}
+		${TIFF_LIBRARIES}
+		${GLEW_LIBRARIES}
+	)
+	install(TARGETS ${_bin} RUNTIME DESTINATION bin)
+endforeach(_current_bin_file ${_bin_files})
diff --git a/tests/general/CMakeLists.txt b/tests/general/CMakeLists.txt
index 884dce5..02e7d84 100644
--- a/tests/general/CMakeLists.txt
+++ b/tests/general/CMakeLists.txt
@@ -1,48 +1,25 @@
+# find pakcages that are required since this target
+find_package(TIFF REQUIRED)
 
 include_directories(
-	${OPENGL_INCLUDE_PATH}
-	${GLUT_INCLUDE_DIR}
-	${piglit_SOURCE_DIR}/tests/util
+	${OPENGL_INCLUDE_DIR}
 	${GLEW_INCLUDE_DIR}
+	${GLUT_INCLUDE_DIR}
+	${CMAKE_SOURCE_DIR}/tests/util
 )
 
-link_directories (
-	${piglit_SOURCE_DIR}/tests/util
-)
-
-link_libraries (
-	piglitutil
-	${OPENGL_gl_LIBRARY}
-	${OPENGL_glu_LIBRARY}
-	${GLUT_glut_LIBRARY}
-	${TIFF_LIBRARY}
-	${GLEW_glew_LIBRARY}
-)
-
-add_executable (bgra-vert-attrib-pointer bgra-vert-attrib-pointer.c)
-add_executable (bgra-sec-color-pointer bgra-sec-color-pointer.c)
-add_executable (clear-varray-2.0 clear-varray-2.0.c)
-add_executable (depth-clamp-range depth-clamp-range.c)
-add_executable (dlist-clear dlist-clear.c)
-add_executable (dlist-fdo3129-01 dlist-fdo3129-01.c)
-add_executable (dlist-fdo3129-02 dlist-fdo3129-02.c)
-add_executable (depth_clamp depth_clamp.c)
-add_executable (depthrange-clear depthrange-clear.c)
-add_executable (draw-elements-base-vertex draw-elements-base-vertex.c)
-add_executable (linestipple linestipple.c)
-add_executable (pbo-drawpixels pbo-drawpixels.c)
-add_executable (pbo-teximage pbo-teximage.c)
-add_executable (provoking-vertex provoking-vertex.c)
-add_executable (read-front read-front.c)
-add_executable (scissor-copypixels scissor-copypixels.c)
-add_executable (scissor-depth-clear scissor-depth-clear.c)
-add_executable (scissor-stencil-clear scissor-stencil-clear.c)
-add_executable (stencil-drawpixels stencil-drawpixels.c)
-add_executable (sync_api sync_api.c)
-add_executable (texgen texgen.c)
-add_executable (user-clip user-clip.c)
-add_executable (varray-disabled varray-disabled.c)
-add_executable (vbo-map-remap vbo-map-remap.c)
-add_executable (vbo-subdata-sync vbo-subdata-sync.c)
-add_executable (windowoverlap windowoverlap.c)
-add_executable (occlusion_query occlusion_query.c)
+# use for loop for easier recognition
+file(GLOB _bin_files *.c)
+foreach(_current_bin_file ${_bin_files})
+	get_filename_component( _bin ${_current_bin_file} NAME_WE )
+	add_executable(${_bin} ${_current_bin_file})
+	add_dependencies(${_bin} piglitutil)
+	target_link_libraries(${_bin}
+		piglitutil
+		${OPENGL_LIBRARIES}
+		${TIFF_LIBRARIES}
+		${GLEW_LIBRARIES}
+		${GLUT_LIBRARIES}
+	)
+	install(TARGETS ${_bin} RUNTIME DESTINATION bin)
+endforeach(_current_bin_file ${_bin_files})
diff --git a/tests/glean/CMakeLists.txt b/tests/glean/CMakeLists.txt
index f2634b3..e0fb72c 100644
--- a/tests/glean/CMakeLists.txt
+++ b/tests/glean/CMakeLists.txt
@@ -1,3 +1,6 @@
+# find pakcages that are required since this target
+find_package(TIFF REQUIRED)
+
 if (MSVC)
 	add_definitions ( -D__WIN__ -D__MS__ )
 ELSEIF (APPLE)
@@ -7,7 +10,7 @@ ELSE ()
 ENDIF ()
 
 include_directories(
-	${OPENGL_INCLUDE_PATH}
+	${OPENGL_INCLUDE_DIR}
 	${TIFF_INCLUDE_DIR}
 )
 
@@ -84,11 +87,10 @@ add_executable (glean
 )
 
 target_link_libraries (glean
-	${OPENGL_gl_LIBRARY}
-	${OPENGL_glu_LIBRARY}
-	${GLUT_glut_LIBRARY}
-	${X11_X11_LIB}
-	${TIFF_LIBRARY}
-	${CARBON_LIBRARY}
+	${OPENGL_LIBRARIES}
+	${GLUT_LIBRARIES}
+	${TIFF_LIBRARIES}
 )
+install(TARGETS glean RUNTIME DESTINATION bin)
 
+# ?? CARBON_LIBRARY
diff --git a/tests/glslparsertest/CMakeLists.txt b/tests/glslparsertest/CMakeLists.txt
index d2902df..f26ab08 100644
--- a/tests/glslparsertest/CMakeLists.txt
+++ b/tests/glslparsertest/CMakeLists.txt
@@ -1,22 +1,17 @@
-
 include_directories(
-	${OPENGL_INCLUDE_PATH}
-	${GLUT_INCLUDE_DIR}
-	${piglit_SOURCE_DIR}/tests/util
+	${OPENGL_INCLUDE_DIR}
 	${GLEW_INCLUDE_DIR}
+	${GLUT_INCLUDE_DIR}
+	${CMAKE_SOURCE_DIR}/tests/util
 )
 
-link_directories (
-	${piglit_SOURCE_DIR}/tests/util
-)
-
-link_libraries (
+add_executable(glslparsertest glslparsertest.c)
+add_dependencies(glslparsertest piglitutil)
+target_link_libraries(glslparsertest
 	piglitutil
-	${OPENGL_gl_LIBRARY}
-	${OPENGL_glu_LIBRARY}
-	${GLUT_glut_LIBRARY}
-	${TIFF_LIBRARY}
-	${GLEW_glew_LIBRARY}
+	${OPENGL_LIBRARIES}
+	${GLEW_LIBRARIES}
+	${GLUT_LIBRARIES}
 )
 
-add_executable (glslparsertest glslparsertest.c)
+install(TARGETS glslparsertest RUNTIME DESTINATION bin)
diff --git a/tests/mesa/CMakeLists.txt b/tests/mesa/CMakeLists.txt
index 5673128..f2d2d43 100644
--- a/tests/mesa/CMakeLists.txt
+++ b/tests/mesa/CMakeLists.txt
@@ -1,3 +1,2 @@
-
-add_subdirectory (util)
-add_subdirectory (tests)
+add_subdirectory(util)
+add_subdirectory(tests)
diff --git a/tests/mesa/tests/CMakeLists.txt b/tests/mesa/tests/CMakeLists.txt
index 4232208..fa74c1f 100644
--- a/tests/mesa/tests/CMakeLists.txt
+++ b/tests/mesa/tests/CMakeLists.txt
@@ -1,30 +1,34 @@
+# find pakcages that are required since this target
+find_package(PNG REQUIRED)
 
 #add_definitions ( -D__X11__ -D__UNIX__ )
 
 include_directories(
-	${OPENGL_INCLUDE_PATH}
-	${GLUT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_DIR}
 	${PNG_INCLUDE_DIR}
-	${piglit_SOURCE_DIR}/tests/mesa/util
+	${CMAKE_SOURCE_DIR}/tests/mesa/util
 )
 
-link_directories (
-	${piglit_SOURCE_DIR}/tests/mesa/util
-)
+add_definitions ( ${PNG_DEFINITIONS} )
 
-link_libraries (
-	${OPENGL_gl_LIBRARY}
-	${OPENGL_glu_LIBRARY}
-	${GLUT_glut_LIBRARY}
+add_executable(crossbar crossbar.c)
+add_dependencies(crossbar mesautil)
+target_link_libraries(crossbar
+	${OPENGL_LIBRARIES}
+	${TIFF_LIBRARIES}
 	${PNG_LIBRARIES}
-	${TIFF_LIBRARY}
+	${GLUT_LIBRARIES}
 	mesautil
 )
+install(TARGETS crossbar RUNTIME DESTINATION bin)
 
-add_definitions (
-	${PNG_DEFINITIONS}
+add_executable(texline texline.c)
+add_dependencies(texline mesautil)
+target_link_libraries(texline
+	${OPENGL_LIBRARIES}
+	${TIFF_LIBRARIES}
+	${PNG_LIBRARIES}
+	${GLUT_LIBRARIES}
+	mesautil
 )
-
-add_executable (crossbar crossbar.c)
-add_executable (texline texline.c)
-#add_executable (arbfptest1 arbfptest1.c)
+install(TARGETS texline RUNTIME DESTINATION bin)
diff --git a/tests/mesa/util/CMakeLists.txt b/tests/mesa/util/CMakeLists.txt
index 9b58136..e647566 100644
--- a/tests/mesa/util/CMakeLists.txt
+++ b/tests/mesa/util/CMakeLists.txt
@@ -1,19 +1,14 @@
+# find pakcages that are required since this target
+find_package(TIFF REQUIRED)
+find_package(PNG REQUIRED)
 
 include_directories (
-	${OPENGL_INCLUDE_PATH}
+	${OPENGL_INCLUDE_DIR}
 	${PNG_INCLUDE_DIR}
 )
-link_libraries (
-	${OPENGL_gl_LIBRARY}
-	${OPENGL_glu_LIBRARY}
-	${TIFF_LIBRARY}
-	${PNG_LIBRARIES}
-)
-add_definitions (
-	${PNG_DEFINITIONS}
-)
+add_definitions(${PNG_DEFINITIONS})
 
-add_library (mesautil
+add_library(mesautil
 	dumpstate.c
 	glstate.c
 	idproj.c
@@ -27,3 +22,13 @@ add_library (mesautil
 	winpos.c
 	writeimg.c
 )
+
+target_link_libraries(mesautil
+	${OPENGL_LIBRARIES}
+	${TIFF_LIBRARIES}
+	${PNG_LIBRARIES}
+)
+
+install(TARGETS mesautil
+	LIBRARY DESTINATION lib${LIB_SUFFIX}
+	ARCHIVE DESTINATION lib${LIB_SUFFIX})
diff --git a/tests/shaders/CMakeLists.txt b/tests/shaders/CMakeLists.txt
index 999ba4f..0fa604d 100644
--- a/tests/shaders/CMakeLists.txt
+++ b/tests/shaders/CMakeLists.txt
@@ -1,75 +1,27 @@
-
 include_directories(
-	${OPENGL_INCLUDE_PATH}
+	${OPENGL_INCLUDE_DIR}
 	${GLUT_INCLUDE_DIR}
-	${piglit_SOURCE_DIR}/tests/mesa/util
-	${piglit_SOURCE_DIR}/tests/util
 	${GLEW_INCLUDE_DIR}
+	${CMAKE_SOURCE_DIR}/tests/mesa/util
+	${CMAKE_SOURCE_DIR}/tests/util
 )
 
-link_directories (
-	${piglit_SOURCE_DIR}/tests/mesa/util
-	${piglit_SOURCE_DIR}/tests/util
-)
-
-link_libraries (
-	piglitutil
-	${OPENGL_gl_LIBRARY}
-	${OPENGL_glu_LIBRARY}
-	${GLUT_glut_LIBRARY}
-	${TIFF_LIBRARY}
-	${GLEW_glew_LIBRARY}
-)
-
-add_definitions ( -DSOURCE_DIR="\\\"${piglit_SOURCE_DIR}/\\\"" )
+add_definitions(-DSOURCE_DIR="\\\"${CMAKE_SOURCE_DIR}/\\\"")
 
-add_executable (trinity-fp1 trinity-fp1.c)
-add_executable (fp-abs-01 fp-abs-01.c)
-add_executable (fp-abs-02 fp-abs-02.c)
-add_executable (fp-condition_codes-01 fp-condition_codes-01.c)
-add_executable (fp-lit-mask fp-lit-mask.c)
-add_executable (fp-fog fp-fog.c)
-add_executable (fp-fragment-position fp-fragment-position.c)
-add_executable (fp-generic fp-generic.c)
-add_executable (fp-kil fp-kil.c)
-add_executable (fp-incomplete-tex fp-incomplete-tex.c)
-add_executable (fp-indirections fp-indirections.c)
-add_executable (fp-indirections2 fp-indirections2.c)
-add_executable (fp-long-alu fp-long-alu.c)
-add_executable (fp-rfl fp-rfl.c)
-add_executable (fp-set-01 fp-set-01.c)
-add_executable (fp-set-02 fp-set-02.c)
-add_executable (fp-unpack-01 fp-unpack-01.c)
-add_executable (glsl-bug-22603 glsl-bug-22603.c)
-add_executable (glsl-dlist-getattriblocation glsl-dlist-getattriblocation.c)
-add_executable (glsl-reload-source glsl-reload-source.c)
-add_executable (glsl-unused-varying glsl-unused-varying.c)
-add_executable (glsl-uniform-update glsl-uniform-update.c)
-add_executable (glsl-uniform-out-of-bounds glsl-uniform-out-of-bounds.c)
-add_executable (glsl-fs-exp2 glsl-fs-exp2.c)
-add_executable (glsl-fs-fragcoord glsl-fs-fragcoord.c)
-add_executable (glsl-fs-log2 glsl-fs-log2.c)
-add_executable (glsl-vs-if glsl-vs-if.c)
-add_executable (glsl-vs-if-bool glsl-vs-if-bool.c)
-add_executable (glsl-vs-loop glsl-vs-loop.c)
-add_executable (vp-address-01 vp-address-01.c)
-add_executable (vp-address-02 vp-address-02.c)
-add_executable (vp-address-03 vp-address-03.c)
-add_executable (vp-address-04 vp-address-04.c)
-add_executable (vp-address-05 vp-address-05.c)
-add_executable (vp-address-06 vp-address-06.c)
-add_executable (vp-bad-program vp-bad-program.c)
-add_executable (vp-clipdistance-01 vp-clipdistance-01.c)
-add_executable (vp-clipdistance-02 vp-clipdistance-02.c)
-add_executable (vp-clipdistance-03 vp-clipdistance-03.c)
-add_executable (vp-clipdistance-04 vp-clipdistance-04.c)
-add_executable (vpfp-generic vpfp-generic.cpp)
-add_executable (vp-max-array vp-max-array.c)
-add_executable (glsl-derivs glsl-derivs.c)
-add_executable (glsl-deriv-varyings glsl-deriv-varyings.c)
-add_executable (glsl-fwidth glsl-fwidth.c)
-add_executable (glsl-lod-bias glsl-lod-bias.c)
-add_executable (glsl-preprocessor-comments glsl-preprocessor-comments.c)
-add_executable (vp-ignore-input vp-ignore-input.c)
-add_executable (glsl-empty-vs-no-fs glsl-empty-vs-no-fs.c)
-add_executable (glsl-useprogram-displaylist glsl-useprogram-displaylist.c)
+# use for loop for easier recognition
+file(GLOB _bin_files *.c)
+foreach(_current_bin_file ${_bin_files})
+	get_filename_component( _bin ${_current_bin_file} NAME_WE )
+	add_executable(${_bin} ${_current_bin_file})
+	add_dependencies(${_bin} piglitutil)
+	add_dependencies(${_bin} mesautil)
+	target_link_libraries(${_bin}
+		piglitutil
+		mesautil
+		${OPENGL_LIBRARIES}
+		${GLUT_LIBRARIES}
+		${TIFF_LIBRARIES}
+		${GLEW_LIBRARIES}
+	)
+	install(TARGETS ${_bin} RUNTIME DESTINATION bin)
+endforeach(_current_bin_file ${_bin_files})
diff --git a/tests/texturing/CMakeLists.txt b/tests/texturing/CMakeLists.txt
index cd5b93a..d75b498 100644
--- a/tests/texturing/CMakeLists.txt
+++ b/tests/texturing/CMakeLists.txt
@@ -1,45 +1,55 @@
-
 include_directories(
-	${OPENGL_INCLUDE_PATH}
+	${OPENGL_INCLUDE_DIR}
 	${GLUT_INCLUDE_DIR}
-	${piglit_SOURCE_DIR}/tests/util
 	${GLEW_INCLUDE_DIR}
+	${CMAKE_SOURCE_DIR}/tests/util
 )
 
-link_directories (
-	${piglit_SOURCE_DIR}/tests/util
-)
+# use for loop for easier recognition
+file(GLOB _bin_files *.c)
+foreach(_current_bin_file ${_bin_files})
+	get_filename_component( _bin ${_current_bin_file} NAME_WE )
+	if(${_bin} STREQUAL depth-tex-modes-common OR 
+			${_bin} STREQUAL depth-tex-modes OR
+			${_bin} STREQUAL depth-tex-modes-rg)
+	#message("Debug skipping: ${_bin}")
+	else(${_bin} STREQUAL depth-tex-modes-common OR
+			${_bin} STREQUAL depth-tex-modes OR
+			${_bin} STREQUAL depth-tex-modes-rg)
+		add_executable(${_bin} ${_current_bin_file})
+		add_dependencies(${_bin} piglitutil)
+		target_link_libraries(${_bin}
+			${OPENGL_LIBRARIES}
+			${GLUT_LIBRARIES}
+			${TIFF_LIBRARIES}
+			${GLEW_LIBRARIES}
+			piglitutil
+		)
+		install(TARGETS ${_bin} RUNTIME DESTINATION bin)
+	endif(${_bin} STREQUAL depth-tex-modes-common OR
+			${_bin} STREQUAL depth-tex-modes OR
+			${_bin} STREQUAL depth-tex-modes-rg)
+endforeach(_current_bin_file ${_bin_files})
 
-link_libraries (
+# install depth-tex-modes and depth-tex-modes-rg
+add_executable(depth-tex-modes depth-tex-modes.c depth-tex-modes-common.c)
+add_dependencies(depth-tex-modes piglitutil)
+target_link_libraries(depth-tex-modes
 	piglitutil
-	${OPENGL_gl_LIBRARY}
-	${OPENGL_glu_LIBRARY}
-	${GLUT_glut_LIBRARY}
-	${TIFF_LIBRARY}
-	${GLEW_glew_LIBRARY}
+	${OPENGL_LIBRARIES}
+	${GLEW_LIBRARIES}
+	${GLUT_LIBRARIES}
+	${TIFF_LIBRARIES}
 )
+install(TARGETS depth-tex-modes RUNTIME DESTINATION bin)
 
-add_executable (copytexsubimage copytexsubimage.c)
-add_executable (cubemap cubemap.c)
-add_executable (gen-compressed-teximage gen-compressed-teximage.c)
-add_executable (gen-teximage gen-teximage.c)
-add_executable (gen-texsubimage gen-texsubimage.c)
-add_executable (getteximage-simple getteximage-simple.c)
-add_executable (levelclamp levelclamp.c)
-add_executable (lodbias lodbias.c)
-add_executable (lodclamp lodclamp.c)
-add_executable (lodclamp-between lodclamp-between.c)
-add_executable (rg-draw-pixels rg-draw-pixels.c)
-add_executable (s3tc-teximage s3tc-teximage.c)
-add_executable (s3tc-texsubimage s3tc-texsubimage.c)
-add_executable (streaming-texture-leak streaming-texture-leak.c)
-add_executable (tex3d tex3d.c)
-add_executable (texdepth texdepth.c)
-add_executable (texrect-many texrect-many.c)
-add_executable (texredefine texredefine.c)
-add_executable (tfp tfp.c)
-add_executable (depth-tex-modes      depth-tex-modes.c depth-tex-modes-common.c)
-add_executable (depth-tex-modes-rg   depth-tex-modes-rg.c depth-tex-modes-common.c)
-add_executable (depth-tex-modes-glsl depth-tex-modes-glsl.c)
-add_executable (depth-tex-compare depth-tex-compare.c)
-add_executable (tex-swizzle tex-swizzle.c)
+add_executable(depth-tex-modes-rg depth-tex-modes-rg.c depth-tex-modes-common.c)
+add_dependencies(depth-tex-modes-rg piglitutil)
+target_link_libraries(depth-tex-modes-rg
+	piglitutil
+	${OPENGL_LIBRARIES}
+	${GLEW_LIBRARIES}
+	${GLUT_LIBRARIES}
+	${TIFF_LIBRARIES}
+)
+install(TARGETS depth-tex-modes-rg RUNTIME DESTINATION bin)
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index 607ebe4..5bc99fc 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -1,8 +1,7 @@
 include_directories(
-	${OPENGL_INCLUDE_PATH}
-	${GLUT_INCLUDE_DIR}
-	${piglit_SOURCE_DIR}/tests/util
+	${OPENGL_INCLUDE_DIR}
 	${GLEW_INCLUDE_DIR}
+	${CMAKE_SOURCE_DIR}/tests/util
 )
 
 add_library (piglitutil
@@ -10,3 +9,7 @@ add_library (piglitutil
 	    shader-load.c
 	    piglit-framework.c
 )
+
+install(TARGETS piglitutil
+	LIBRARY DESTINATION lib${LIB_SUFFIX}
+	ARCHIVE DESTINATION lib${LIB_SUFFIX})
-- 
1.6.5.3

Attachment: signature.asc
Description: This is a digitally signed message part.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to