66# Manually define WITHTESTS=true, if you want build test applications!
77#
88# (c)ISS UW, @author Wojciech Borkowski
9- # @date 2026-02-18 (last update)
9+ # @date 2026-04-16 (last update)
1010##################################################################################
1111
1212cmake_minimum_required (VERSION 3.20 )
@@ -109,6 +109,20 @@ endif(WINDOWS)
109109#######################
110110
111111if (X11 AND WITHTESTS ) #X11 tests
112+ # 1. Definiujemy listę nazw programów, aby uniknąć powtórzeń
113+ set (X11_EXAMPLES
114+ "TestmousX11"
115+ "TestpaleX11"
116+ "TestpolyX11"
117+ "TestrandX11"
118+ "TestsymsX11"
119+ "TestsyshX11"
120+ "TurmitX11"
121+ "CAGasX11"
122+ "LinktestX11"
123+ )
124+
125+ #2. Definicja źródeł (także dla tych z niestandardowymi plikami)
112126 add_executable ("TestmousX11" "EXAMPLES/Testmous.cpp" )
113127 add_executable ("TestpaleX11" "EXAMPLES/Testpale.cpp" )
114128 add_executable ("TestpolyX11" "EXAMPLES/Testpoly.cpp" )
@@ -123,18 +137,40 @@ if(X11 AND WITHTESTS ) #X11 tests
123137 add_executable ("CAGasX11" "EXAMPLES/CAGas.cpp" )
124138 add_executable ("LinktestX11" "EXAMPLES/Linktest.cpp" )
125139
126- target_link_libraries ("TestmousX11" wbsyshLight X11 Xpm rt )
127- target_link_libraries ("TestpaleX11" wbsyshLight X11 Xpm rt )
128- target_link_libraries ("TestpolyX11" wbsyshLight X11 Xpm rt )
129- target_link_libraries ("TestrandX11" wbsyshLight X11 Xpm rt )
130- target_link_libraries ("TestsymsX11" wbsyshLight X11 Xpm rt )
131- target_link_libraries ("TestsyshX11" wbsyshLight X11 Xpm rt )
132- target_link_libraries ("TurmitX11" wbsyshLight X11 Xpm rt )
133- target_link_libraries ("CAGasX11" wbsyshLight X11 Xpm pthread rt )
134- target_link_libraries ("LinktestX11" wbsyshLight X11 Xpm rt )
140+ # 3. Masowe ustawienie bibliotek i katalogu wyjściowego
141+ foreach (test_target ${X11_EXAMPLES} )
142+ # Kierujemy pliki wykonywalne do podkatalogu bin/
143+ set_target_properties (${test_target} PROPERTIES
144+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /bin"
145+ )
146+
147+ # Wspólne biblioteki dla wszystkich
148+ target_link_libraries (${test_target} wbsyshLight X11 Xpm rt )
149+ endforeach ()
150+
151+ # Specyficzny przypadek dla CAGas (dodatkowy pthread)
152+ target_link_libraries ("CAGasX11" pthread )
153+
154+ # 4. Cel zbiorczy (meta-target)
155+ # Pozwala na wywołanie: make all_x11_tests
156+ add_custom_target (all_x11_tests DEPENDS ${X11_EXAMPLES} )
135157endif ()
136158
137159if ( WINDOWS AND WITHTESTS ) #MS Windows tests
160+ # 1. Definiujemy listę nazw programów, aby uniknąć powtórzeń
161+ set (WIN_EXAMPLES
162+ "TestmousSVG"
163+ "TestpaleSVG"
164+ "TestpolySVG"
165+ "TestrandSVG"
166+ "TestsymsSVG"
167+ "TestsyshSVG"
168+ "TurmitSVG"
169+ "CAGasSVG"
170+ "LinktestSVG"
171+ )
172+
173+ #2. Definicja źródeł (także dla tych z niestandardowymi plikami)
138174 add_executable ("TestmousWIN" "EXAMPLES/Testmous.cpp" )
139175 add_executable ("TestpaleWIN" "EXAMPLES/Testpale.cpp" )
140176 add_executable ("TestpolyWIN" "EXAMPLES/Testpoly.cpp" )
@@ -149,6 +185,15 @@ if( WINDOWS AND WITHTESTS ) #MS Windows tests
149185 add_executable ("CAGasWIN" "EXAMPLES/CAGas.cpp" )
150186 add_executable ("LinktestWIN" "EXAMPLES/Linktest.cpp" )
151187
188+ # 3. Masowe ustawienie katalogu wyjściowego
189+ foreach (test_target ${WIN_EXAMPLES} )
190+ # Kierujemy pliki wykonywalne do podkatalogu bin/
191+ set_target_properties (${test_target} PROPERTIES
192+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /bin"
193+ )
194+ endforeach ()
195+
196+ # 3b. Ustawienie bibliotek
152197 target_link_libraries ("TestmousWIN" wbsyshLight )
153198 target_link_libraries ("TestpaleWIN" wbsyshLight )
154199 target_link_libraries ("TestpolyWIN" wbsyshLight )
@@ -158,10 +203,28 @@ if( WINDOWS AND WITHTESTS ) #MS Windows tests
158203 target_link_libraries ("TurmitWIN" wbsyshLight )
159204 target_link_libraries ("CAGasWIN" wbsyshLight )
160205 target_link_libraries ("LinktestWIN" wbsyshLight )
206+
207+ # 4. Cel zbiorczy (meta-target)
208+ # Pozwala na wywołanie: make all_Win_tests
209+ add_custom_target (all_Win_tests DEPENDS ${WIN_EXAMPLES} )
161210endif ()
162211
163212
164213if (WITHTESTS) #SVG tests
214+ # 1. Definiujemy listę nazw programów, aby uniknąć powtórzeń
215+ set (SVG_EXAMPLES
216+ "TestmousSVG"
217+ "TestpaleSVG"
218+ "TestpolySVG"
219+ "TestrandSVG"
220+ "TestsymsSVG"
221+ "TestsyshSVG"
222+ "TurmitSVG"
223+ "CAGasSVG"
224+ "LinktestSVG"
225+ )
226+
227+ #2. Definicja źródeł (także dla tych z niestandardowymi plikami)
165228 add_executable ("TestmousSVG" "EXAMPLES/Testmous.cpp" )
166229 add_executable ("TestpaleSVG" "EXAMPLES/Testpale.cpp" )
167230 add_executable ("TestpolySVG" "EXAMPLES/Testpoly.cpp" )
@@ -176,6 +239,15 @@ if(WITHTESTS) #SVG tests
176239 add_executable ("CAGasSVG" "EXAMPLES/CAGas.cpp" )
177240 add_executable ("LinktestSVG" "EXAMPLES/Linktest.cpp" )
178241
242+ # 3. Masowe ustawienie katalogu wyjściowego
243+ foreach (test_target ${SVG_EXAMPLES} )
244+ # Kierujemy pliki wykonywalne do podkatalogu bin/
245+ set_target_properties (${test_target} PROPERTIES
246+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /bin"
247+ )
248+ endforeach ()
249+
250+ # 3b. Ustawienie bibliotek
179251 if ( WINDOWS )
180252 target_link_libraries ("TestmousSVG" wbsyshLightSVG )
181253 target_link_libraries ("TestpaleSVG" wbsyshLightSVG )
@@ -198,6 +270,9 @@ if(WITHTESTS) #SVG tests
198270 target_link_libraries ("LinktestSVG" wbsyshLightSVG rt )
199271 endif ()
200272
273+ # 4. Cel zbiorczy (meta-target)
274+ # Pozwala na wywołanie: make all_Win_tests
275+ add_custom_target (all_SVG_tests DEPENDS ${SVG_EXAMPLES} )
201276endif ()
202277
203278#KONIEC - THE END
0 commit comments