Demos (cmake): cmake: Make logical target names globally unique.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Tue Nov 9 13:03:50 UTC 2010


Module: Demos
Branch: cmake
Commit: e94114d92fc9198dd63da53d693685709e987db1
URL:    http://cgit.freedesktop.org/mesa/demos/commit/?id=e94114d92fc9198dd63da53d693685709e987db1

Author: José Fonseca <jfonseca at vmware.com>
Date:   Tue Nov  9 12:06:39 2010 +0000

cmake: Make logical target names globally unique.

Cmake requires logical target names must be globally unique, but
several progs have the same name. Although we got away overriding
this policy on unices, it must be ovserved for MSVC project generation.

For more information see

  cmake --help-policy CMP0002

---

 CMakeLists.txt             |    3 ---
 src/demos/CMakeLists.txt   |    8 ++++++--
 src/fp/CMakeLists.txt      |   10 ++++++----
 src/fpglsl/CMakeLists.txt  |   10 ++++++----
 src/gs/CMakeLists.txt      |   10 ++++++----
 src/perf/CMakeLists.txt    |    8 +++++---
 src/redbook/CMakeLists.txt |    8 +++++---
 src/samples/CMakeLists.txt |   10 ++++++----
 src/tests/CMakeLists.txt   |   11 ++++++-----
 src/trivial/CMakeLists.txt |    8 +++++---
 src/vp/CMakeLists.txt      |   10 ++++++----
 src/vpglsl/CMakeLists.txt  |   10 ++++++----
 src/wgl/CMakeLists.txt     |    6 ++++--
 src/xdemos/CMakeLists.txt  |   18 +++++++++++-------
 14 files changed, 78 insertions(+), 52 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 53ad262..852a887 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,5 @@
 cmake_minimum_required (VERSION 2.6)
 
-# Allow targets with duplicate names
-cmake_policy(SET CMP0002 OLD)
-
 project (mesademos)
 
 find_package (OpenGL REQUIRED)
diff --git a/src/demos/CMakeLists.txt b/src/demos/CMakeLists.txt
index f1614fd..55e7bb3 100644
--- a/src/demos/CMakeLists.txt
+++ b/src/demos/CMakeLists.txt
@@ -17,6 +17,8 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir demos)
+
 set (targets
 	arbfplight
 	arbfslight
@@ -74,12 +76,14 @@ set (targets
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
 
 add_executable (rain rain.cxx particles.cxx)
 
-install (TARGETS ${targets} rain DESTINATION demos)
+install (TARGETS rain DESTINATION demos)
 
 file (GLOB data *.dat)
 
diff --git a/src/fp/CMakeLists.txt b/src/fp/CMakeLists.txt
index 658ab1c..44cf5e2 100644
--- a/src/fp/CMakeLists.txt
+++ b/src/fp/CMakeLists.txt
@@ -17,6 +17,8 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir fp)
+
 set (targets
 	fp-tri
 	tri-depth
@@ -29,11 +31,11 @@ set (targets
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
 
-install (TARGETS ${targets} DESTINATION fp)
-
 file (GLOB data *.txt)
 
-install (FILES ${data} DESTINATION fp)
+install (FILES ${data} DESTINATION ${subdir})
diff --git a/src/fpglsl/CMakeLists.txt b/src/fpglsl/CMakeLists.txt
index 3dd9a47..c7efb2c 100644
--- a/src/fpglsl/CMakeLists.txt
+++ b/src/fpglsl/CMakeLists.txt
@@ -17,16 +17,18 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir fpglsl)
+
 set (targets
 	fp-tri
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
 
-install (TARGETS ${targets} DESTINATION fpglsl)
-
 file (GLOB data *.glsl)
 
-install (FILES ${data} DESTINATION fpglsl)
+install (FILES ${data} DESTINATION ${subdir})
diff --git a/src/gs/CMakeLists.txt b/src/gs/CMakeLists.txt
index 3ecd4aa..2de72cb 100644
--- a/src/gs/CMakeLists.txt
+++ b/src/gs/CMakeLists.txt
@@ -17,16 +17,18 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir gs)
+
 set (targets
 	gs-tri
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
 
-install (TARGETS ${targets} DESTINATION gs)
-
 file (GLOB data *.glsl)
 
-install (FILES ${data} DESTINATION gs)
+install (FILES ${data} DESTINATION ${subdir})
diff --git a/src/perf/CMakeLists.txt b/src/perf/CMakeLists.txt
index a3754ed..ecd4216 100644
--- a/src/perf/CMakeLists.txt
+++ b/src/perf/CMakeLists.txt
@@ -17,6 +17,8 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir perf)
+
 set (targets
 	copytex
 	drawoverhead
@@ -31,7 +33,7 @@ set (targets
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c common.c glmain.c)
+	add_executable (${subdir}_${target} ${target}.c common.c glmain.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
-
-install (TARGETS ${targets} DESTINATION perf)
diff --git a/src/redbook/CMakeLists.txt b/src/redbook/CMakeLists.txt
index 8b84913..3311d99 100644
--- a/src/redbook/CMakeLists.txt
+++ b/src/redbook/CMakeLists.txt
@@ -17,6 +17,8 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir redbook)
+
 set (targets
 	aaindex
 	aapoly
@@ -97,7 +99,7 @@ set (targets
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
-
-install (TARGETS ${targets} DESTINATION redbook)
diff --git a/src/samples/CMakeLists.txt b/src/samples/CMakeLists.txt
index b0dcb95..3d5d9fc 100644
--- a/src/samples/CMakeLists.txt
+++ b/src/samples/CMakeLists.txt
@@ -17,6 +17,8 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir samples)
+
 set (targets
 	accum
 	bitmap1
@@ -50,11 +52,11 @@ set (targets
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
 
-install (TARGETS ${targets} DESTINATION samples)
-
 if (X11_FOUND)
 	include_directories (
 		${X11_INCLUDE_DIR}
@@ -72,5 +74,5 @@ if (X11_FOUND)
 		add_executable (${xtarget} ${xtarget}.c)
 	endforeach (xtarget)
 
-	install (TARGETS ${xtargets} DESTINATION tests)
+	install (TARGETS ${xtargets} DESTINATION ${subdir})
 endif (X11_FOUND)
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 72105ab..c246dad 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -17,6 +17,8 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir tests)
+
 set (targets
 	afsmultiarb
 	antialias
@@ -131,11 +133,11 @@ set (targets
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
 
-install (TARGETS ${targets} DESTINATION tests)
-
 if (X11_FOUND)
 	include_directories (
 		${X11_INCLUDE_DIR}
@@ -156,6 +158,5 @@ if (X11_FOUND)
 		add_executable (${xtarget} ${xtarget}.c)
 	endforeach (xtarget)
 
-	install (TARGETS ${xtargets} DESTINATION tests)
+	install (TARGETS ${xtargets} DESTINATION ${subdir})
 endif (X11_FOUND)
-
diff --git a/src/trivial/CMakeLists.txt b/src/trivial/CMakeLists.txt
index 8af7b30..7aea9e9 100644
--- a/src/trivial/CMakeLists.txt
+++ b/src/trivial/CMakeLists.txt
@@ -17,6 +17,8 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir trivial)
+
 set (targets
 	clear-color
 	clear-fbo
@@ -190,7 +192,7 @@ set (targets
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
-
-install (TARGETS ${targets} DESTINATION trivial)
diff --git a/src/vp/CMakeLists.txt b/src/vp/CMakeLists.txt
index e83c704..34cf249 100644
--- a/src/vp/CMakeLists.txt
+++ b/src/vp/CMakeLists.txt
@@ -17,16 +17,18 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir vp)
+
 set (targets
 	vp-tris
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
 
-install (TARGETS ${targets} DESTINATION vp)
-
 file (GLOB data *.txt)
 
-install (FILES ${data} DESTINATION vp)
+install (FILES ${data} DESTINATION ${subdir})
diff --git a/src/vpglsl/CMakeLists.txt b/src/vpglsl/CMakeLists.txt
index 72b9fd1..0aa9709 100644
--- a/src/vpglsl/CMakeLists.txt
+++ b/src/vpglsl/CMakeLists.txt
@@ -17,16 +17,18 @@ link_libraries (
 	${GLEW_glew_LIBRARY}
 )
 
+set (subdir vpglsl)
+
 set (targets
 	vp-tris
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
 
-install (TARGETS ${targets} DESTINATION vpglsl)
-
 file (GLOB data *.glsl)
 
-install (FILES ${data} DESTINATION vpglsl)
+install (FILES ${data} DESTINATION ${subdir})
diff --git a/src/wgl/CMakeLists.txt b/src/wgl/CMakeLists.txt
index 3583560..2a85954 100644
--- a/src/wgl/CMakeLists.txt
+++ b/src/wgl/CMakeLists.txt
@@ -9,7 +9,9 @@ link_libraries (
 )
 
 add_executable (wglthreads wglthreads/wglthreads.c)
-add_executable (sharedtex_mt sharedtex_mt/sharedtex_mt.c)
+add_executable (wgl_sharedtex_mt sharedtex_mt/sharedtex_mt.c)
+set_target_properties (wgl_sharedtex_mt PROPERTIES OUTPUT_NAME sharedtex_mt)
+
 add_executable (wglinfo wglinfo.c)
 
-install (TARGETS wglthreads sharedtex_mt wglthreads DESTINATION wgl)
+install (TARGETS wglthreads wgl_sharedtex_mt wglthreads DESTINATION wgl)
diff --git a/src/xdemos/CMakeLists.txt b/src/xdemos/CMakeLists.txt
index 73e6406..b335fcf 100644
--- a/src/xdemos/CMakeLists.txt
+++ b/src/xdemos/CMakeLists.txt
@@ -19,6 +19,8 @@ link_libraries (
 
 add_library (pbutil pbutil.c)
 
+set (subdir xdemos)
+
 set (targets
 	glsync
 	glthreads
@@ -54,16 +56,18 @@ set (targets
 )
 
 foreach (target ${targets})
-	add_executable (${target} ${target}.c)
+	add_executable (${subdir}_${target} ${target}.c)
+	set_target_properties (${subdir}_${target} PROPERTIES OUTPUT_NAME ${target})
+	install (TARGETS ${subdir}_${target} DESTINATION ${subdir})
 endforeach (target)
 
-target_link_libraries (glthreads pthread)
-target_link_libraries (glxgears_fbconfig pbutil)
-target_link_libraries (pbdemo pbutil)
-target_link_libraries (pbinfo pbutil)
-target_link_libraries (sharedtex_mt pthread)
+target_link_libraries (${subdir}_glthreads pthread)
+target_link_libraries (${subdir}_glxgears_fbconfig pbutil)
+target_link_libraries (${subdir}_pbdemo pbutil)
+target_link_libraries (${subdir}_pbinfo pbutil)
+target_link_libraries (${subdir}_sharedtex_mt pthread)
 
 add_executable (corender corender.c ipc.c) 
 add_executable (xrotfontdemo xrotfontdemo.c xuserotfont.c)
 
-install (TARGETS ${targets} corender xrotfontdemo DESTINATION xdemos)
+install (TARGETS corender xrotfontdemo DESTINATION demos)




More information about the mesa-commit mailing list