Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/emulators/einstein-newton/files/patch-CMakeLists.txt
46590 views
1
--- CMakeLists.txt.orig 2025-12-19 16:57:53 UTC
2
+++ CMakeLists.txt
3
@@ -56,6 +56,10 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
4
5
# Linux: nothing to do here
6
7
+elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD" )
8
+
9
+ # FreeBSD and NetBSD: nothing to do here
10
+
11
elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
12
13
set_property ( GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1 )
14
@@ -159,23 +163,37 @@ endif ()
15
# ---- Setup Google Testing
16
#
17
18
+include( CTest )
19
+
20
# For Windows: Prevent overriding the parent project's compiler/linker settings
21
set( gtest_force_shared_crt ON CACHE BOOL "" FORCE )
22
23
-# Check if population has already been performed
24
-FetchContent_GetProperties(googletest)
25
-if ( NOT googletest_POPULATED )
26
- # Fetch the content using previously declared details
27
- FetchContent_MakeAvailable(googletest)
28
+option( EINSTEIN_FETCH_GTEST "Download googletest if not found" ON )
29
30
- # Bring the populated content into the build
31
- #add_subdirectory( ${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} )
32
-endif ()
33
+set( EINSTEIN_USE_GTEST OFF )
34
+if ( BUILD_TESTING )
35
+ # Try to find GTest installed on the system first.
36
+ find_package( GTest CONFIG QUIET )
37
38
-enable_testing()
39
+ # Check if population has already been performed
40
+ if ( NOT GTest_FOUND AND EINSTEIN_FETCH_GTEST )
41
+ FetchContent_GetProperties(googletest)
42
+ if ( NOT googletest_POPULATED )
43
+ # Fetch the content using previously declared details
44
+ FetchContent_MakeAvailable(googletest)
45
46
-include( GoogleTest )
47
+ # Bring the populated content into the build
48
+ #add_subdirectory( ${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} )
49
+ endif ()
50
+ endif ()
51
52
+ if ( TARGET GTest::gtest_main OR TARGET gtest_main )
53
+ set( EINSTEIN_USE_GTEST ON )
54
+ else ()
55
+ message( STATUS "GoogleTest not available; tests disabled." )
56
+ endif ()
57
+endif ()
58
+
59
#
60
# ---- Newt/64 library ---------------------------------------------------------
61
#
62
@@ -322,11 +340,13 @@ if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
63
${app_sources}
64
${cmake_sources}
65
)
66
- add_executable ( EinsteinTests
67
- ${common_sources}
68
- ${test_sources}
69
- ${cmake_sources}
70
- )
71
+ if ( EINSTEIN_USE_GTEST )
72
+ add_executable ( EinsteinTests
73
+ ${common_sources}
74
+ ${test_sources}
75
+ ${cmake_sources}
76
+ )
77
+ endif ()
78
if ( EINSTEIN_FLTK_FRONTEND )
79
add_library ( EinsteinFLGUI STATIC
80
${fluid_sources}
81
@@ -337,9 +357,11 @@ if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
82
target_compile_options( Einstein PUBLIC
83
-Wall -Wextra -Wpedantic -Wno-missing-field-initializers -Werror
84
)
85
- target_compile_options( EinsteinTests PUBLIC
86
- -Wall -Wextra -Wpedantic -Wno-missing-field-initializers -Werror
87
- )
88
+ if ( EINSTEIN_USE_GTEST )
89
+ target_compile_options( EinsteinTests PUBLIC
90
+ -Wall -Wextra -Wpedantic -Wno-missing-field-initializers -Werror
91
+ )
92
+ endif ()
93
if ( EINSTEIN_FLTK_FRONTEND )
94
target_compile_options( EinsteinFLGUI PUBLIC
95
-Wall -Wextra -Wpedantic -Wno-missing-field-initializers -Werror
96
@@ -357,10 +379,12 @@ if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
97
TARGET_OS_MAC=1 NS_BLOCK_ASSERTIONS=1
98
)
99
endif ()
100
- target_compile_definitions ( EinsteinTests PRIVATE
101
- TARGET_UI_FLTK=1 NO_PORT_AUDIO NO_X11 TARGET_OS_OPENSTEP=1
102
- TARGET_OS_MAC=1 NS_BLOCK_ASSERTIONS=1
103
- )
104
+ if ( EINSTEIN_USE_GTEST )
105
+ target_compile_definitions ( EinsteinTests PRIVATE
106
+ TARGET_UI_FLTK=1 NO_PORT_AUDIO NO_X11 TARGET_OS_OPENSTEP=1
107
+ TARGET_OS_MAC=1 NS_BLOCK_ASSERTIONS=1
108
+ )
109
+ endif ()
110
if ( EINSTEIN_FLTK_FRONTEND )
111
target_compile_definitions ( EinsteinFLGUI PRIVATE
112
TARGET_UI_FLTK=1 NO_PORT_AUDIO NO_X11 TARGET_OS_OPENSTEP=1
113
@@ -390,7 +414,7 @@ if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
114
$ENV{ANDROID_NDK_HOME}/sysroot/usr/include
115
)
116
endif ()
117
- if ( EINSTEIN_FLTK_FRONTEND )
118
+ if ( EINSTEIN_USE_GTEST AND EINSTEIN_FLTK_FRONTEND )
119
target_link_libraries ( EinsteinTests
120
${system_libs}
121
fltk::fltk
122
@@ -423,7 +447,7 @@ if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
123
)
124
endif ()
125
126
-elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
127
+elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD$" )
128
129
# create the application
130
add_executable ( Einstein
131
@@ -431,11 +455,13 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CM
132
${app_sources}
133
${cmake_sources}
134
)
135
- add_executable ( EinsteinTests
136
- ${common_sources}
137
- ${test_sources}
138
- ${cmake_sources}
139
- )
140
+ if ( EINSTEIN_USE_GTEST )
141
+ add_executable ( EinsteinTests
142
+ ${common_sources}
143
+ ${test_sources}
144
+ ${cmake_sources}
145
+ )
146
+ endif ()
147
add_library ( EinsteinFLGUI STATIC
148
${fluid_sources}
149
)
150
@@ -443,23 +469,34 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CM
151
# how to compile and link
152
target_compile_options ( Einstein PUBLIC
153
-Wall -Wno-multichar -Wno-misleading-indentation -Wno-unused-result
154
- -Wno-missing-field-initializers -Wno-stringop-truncation # -Werror
155
+ -Wno-missing-field-initializers # -Werror
156
# Werror is disabled for testing purposes. Must reenable as soon as all Linux warnings are fixed.
157
)
158
- target_compile_options ( EinsteinTests PUBLIC
159
- -Wall -Wno-multichar -Wno-misleading-indentation -Wno-unused-result
160
- -Wno-missing-field-initializers -Wno-stringop-truncation -Werror
161
- )
162
+ if ( EINSTEIN_USE_GTEST )
163
+ target_compile_options ( EinsteinTests PUBLIC
164
+ -Wall -Wno-multichar -Wno-misleading-indentation -Wno-unused-result
165
+ -Wno-missing-field-initializers -Werror
166
+ )
167
+ endif ()
168
target_compile_options ( EinsteinFLGUI PUBLIC
169
-Wall -Wno-multichar -Wno-misleading-indentation -Wno-unused-result
170
- -Wno-missing-field-initializers -Wno-stringop-truncation -Werror
171
+ -Wno-missing-field-initializers -Werror
172
)
173
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
174
+ target_compile_options(Einstein PUBLIC -Wno-stringop-truncation)
175
+ if ( EINSTEIN_USE_GTEST )
176
+ target_compile_options(EinsteinTests PUBLIC -Wno-stringop-truncation)
177
+ endif ()
178
+ target_compile_options(EinsteinFLGUI PUBLIC -Wno-stringop-truncation)
179
+ endif()
180
target_compile_definitions ( Einstein PRIVATE
181
TARGET_UI_FLTK=1 TARGET_OS_LINUX=1
182
)
183
- target_compile_definitions ( EinsteinTests PRIVATE
184
- TARGET_UI_FLTK=1 TARGET_OS_LINUX=1
185
- )
186
+ if ( EINSTEIN_USE_GTEST )
187
+ target_compile_definitions ( EinsteinTests PRIVATE
188
+ TARGET_UI_FLTK=1 TARGET_OS_LINUX=1
189
+ )
190
+ endif ()
191
target_compile_definitions ( EinsteinFLGUI PRIVATE
192
TARGET_UI_FLTK=1 TARGET_OS_LINUX=1
193
)
194
@@ -469,18 +506,20 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CM
195
EinsteinFLGUI
196
pthread
197
)
198
- target_link_libraries ( EinsteinTests
199
- ${system_libs}
200
- fltk::fltk
201
- EinsteinFLGUI
202
- pthread
203
- )
204
+ if ( EINSTEIN_USE_GTEST )
205
+ target_link_libraries ( EinsteinTests
206
+ ${system_libs}
207
+ fltk::fltk
208
+ EinsteinFLGUI
209
+ pthread
210
+ )
211
+ endif ()
212
target_link_libraries ( EinsteinFLGUI
213
fltk::fltk fltk::images fltk::png fltk::z
214
)
215
216
- if ( ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
217
- # Under OpenBSD, libffi is in ports (i.e. /usr/local) not base (i.e. /usr)
218
+ if ( ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD$" )
219
+ # Under BSD, libffi is in ports (i.e. /usr/local) not base (i.e. /usr)
220
find_library ( ffi_lib NAMES ffi )
221
find_file ( ffi_incl NAMES ffi.h )
222
if ( ffi_lib MATCHES ".*NOTFOUND" OR ffi_incl MATCHES ".*NOTFOUND" )
223
@@ -493,7 +532,7 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CM
224
target_link_libraries ( Einstein ${ffi_lib} )
225
endif ()
226
227
- # Under OpenBSD, pulseaudio is in ports (i.e. /usr/local) not base (i.e. /usr)
228
+ # Under BSD, pulseaudio is in ports (i.e. /usr/local) not base (i.e. /usr)
229
find_library ( pulse_lib NAMES pulse )
230
if ( pulse_lib MATCHES ".*NOTFOUND" )
231
message ( FATAL_ERROR "libpulse not found! " )
232
@@ -503,7 +542,7 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CM
233
target_link_libraries ( Einstein ${pulse_lib} )
234
endif ()
235
236
- # Under OpenBSD, X11 is in /usr/X11R6
237
+ # Under BSD, find X11
238
include ( FindX11 )
239
if ( X11_FOUND )
240
target_include_directories ( Einstein SYSTEM PUBLIC ${X11_INCLUDE_DIR} )
241
@@ -527,30 +566,38 @@ elseif ( WIN32 )
242
${common_sources} ${app_sources} ${cmake_sources} ${data}
243
${CMAKE_CURRENT_BINARY_DIR}/Einstein.rc
244
)
245
- add_executable ( EinsteinTests
246
- ${common_sources} ${test_sources}
247
- )
248
+ if ( EINSTEIN_USE_GTEST )
249
+ add_executable ( EinsteinTests
250
+ ${common_sources} ${test_sources}
251
+ )
252
+ endif ()
253
add_library ( EinsteinFLGUI STATIC
254
${fluid_sources}
255
)
256
257
# how to compile and link
258
target_compile_options( Einstein PUBLIC "/bigobj" )
259
- target_compile_options( EinsteinTests PUBLIC "/bigobj" )
260
+ if ( EINSTEIN_USE_GTEST )
261
+ target_compile_options( EinsteinTests PUBLIC "/bigobj" )
262
+ endif ()
263
target_compile_options( EinsteinFLGUI PUBLIC "/bigobj" )
264
if ( $<CONFIG:Debug> )
265
target_compile_options( Einstein PUBLIC "/ZI" )
266
- target_compile_options( EinsteinTests PUBLIC "/ZI" )
267
+ if ( EINSTEIN_USE_GTEST )
268
+ target_compile_options( EinsteinTests PUBLIC "/ZI" )
269
+ endif ()
270
target_compile_options( EinsteinFLGUI PUBLIC "/ZI" )
271
endif ()
272
target_compile_definitions ( Einstein PRIVATE
273
TARGET_UI_FLTK=1 TARGET_OS_WIN32=1
274
WIN32_LEAN_AND_MEAN=1 _CRT_SECURE_NO_WARNINGS=1
275
)
276
- target_compile_definitions ( EinsteinTests PRIVATE
277
- TARGET_UI_FLTK=1 TARGET_OS_WIN32=1
278
- WIN32_LEAN_AND_MEAN=1 _CRT_SECURE_NO_WARNINGS=1
279
- )
280
+ if ( EINSTEIN_USE_GTEST )
281
+ target_compile_definitions ( EinsteinTests PRIVATE
282
+ TARGET_UI_FLTK=1 TARGET_OS_WIN32=1
283
+ WIN32_LEAN_AND_MEAN=1 _CRT_SECURE_NO_WARNINGS=1
284
+ )
285
+ endif ()
286
target_compile_definitions ( EinsteinFLGUI PRIVATE
287
TARGET_UI_FLTK=1 TARGET_OS_WIN32=1
288
WIN32_LEAN_AND_MEAN=1 _CRT_SECURE_NO_WARNINGS=1
289
@@ -562,17 +609,19 @@ elseif ( WIN32 )
290
winmm
291
gdiplus
292
)
293
- target_link_libraries ( EinsteinTests
294
- ${system_libs}
295
- fltk::fltk
296
- EinsteinFLGUI
297
- gdiplus
298
- )
299
- target_link_libraries ( EinsteinTests
300
- ${system_libs}
301
- fltk::fltk
302
- gdiplus
303
- )
304
+ if ( EINSTEIN_USE_GTEST )
305
+ target_link_libraries ( EinsteinTests
306
+ ${system_libs}
307
+ fltk::fltk
308
+ EinsteinFLGUI
309
+ gdiplus
310
+ )
311
+ target_link_libraries ( EinsteinTests
312
+ ${system_libs}
313
+ fltk::fltk
314
+ gdiplus
315
+ )
316
+ endif ()
317
target_link_libraries ( EinsteinFLGUI
318
fltk::fltk fltk::images fltk::png fltk::z
319
)
320
@@ -634,11 +683,13 @@ target_include_directories (
321
${CMAKE_SOURCE_DIR}
322
${FLTK_INCLUDE_DIRS}
323
)
324
-target_include_directories (
325
- EinsteinTests PUBLIC
326
- ${CMAKE_SOURCE_DIR}
327
- ${FLTK_INCLUDE_DIRS}
328
-)
329
+if ( EINSTEIN_USE_GTEST )
330
+ target_include_directories (
331
+ EinsteinTests PUBLIC
332
+ ${CMAKE_SOURCE_DIR}
333
+ ${FLTK_INCLUDE_DIRS}
334
+ )
335
+endif ()
336
if ( EINSTEIN_FLTK_FRONTEND )
337
target_include_directories (
338
EinsteinFLGUI PUBLIC
339
@@ -648,14 +699,27 @@ target_compile_definitions ( Einstein PUBLIC "$<$<CONF
340
endif ()
341
342
target_compile_definitions ( Einstein PUBLIC "$<$<CONFIG:DEBUG>:_DEBUG>" USE_CMAKE )
343
-target_compile_definitions ( EinsteinTests PUBLIC "$<$<CONFIG:DEBUG>:_DEBUG>" USE_CMAKE )
344
+if ( EINSTEIN_USE_GTEST )
345
+ target_compile_definitions ( EinsteinTests PUBLIC "$<$<CONFIG:DEBUG>:_DEBUG>" USE_CMAKE )
346
+endif ()
347
if ( EINSTEIN_FLTK_FRONTEND )
348
target_compile_definitions ( EinsteinFLGUI PUBLIC "$<$<CONFIG:DEBUG>:_DEBUG>" USE_CMAKE )
349
endif ()
350
351
-target_link_libraries ( EinsteinTests gtest_main )
352
+if ( EINSTEIN_USE_GTEST )
353
+ include( GoogleTest )
354
+ if ( TARGET GTest::gtest_main )
355
+ target_link_libraries ( EinsteinTests GTest::gtest_main )
356
+ elseif ( TARGET gtest_main )
357
+ target_link_libraries ( EinsteinTests gtest_main )
358
+ else ()
359
+ message ( STATUS "GoogleTest found without a gtest_main target; tests disabled." )
360
+ endif ()
361
+endif ()
362
363
-gtest_discover_tests ( EinsteinTests )
364
+if ( EINSTEIN_USE_GTEST AND ( TARGET GTest::gtest_main OR TARGET gtest_main ) )
365
+ gtest_discover_tests ( EinsteinTests )
366
+endif ()
367
368
endif ()
369
370
371