forked from usexfg/fuego-suite
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
464 lines (409 loc) · 18.5 KB
/
Copy pathCMakeLists.txt
File metadata and controls
464 lines (409 loc) · 18.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
cmake_minimum_required(VERSION 3.16)
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
if(POLICY CMP0144)
cmake_policy(SET CMP0144 NEW)
endif()
include(CheckCXXCompilerFlag)
set(VERSION "0.2")
# Packaged from main commits
set(COMMIT 72946d9)
set(REFS " (HEAD -> master)")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo Release CACHE STRING INTERNAL)
set(CMAKE_SKIP_INSTALL_RULES ON)
set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY ON)
set(CMAKE_SUPPRESS_REGENERATION ON)
project(fuegoX)
# --------------------------
# Version generation
# --------------------------
set(VERSION "0.2")
set(COMMIT 72946d9)
set(REFS " (HEAD -> master)")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version")
configure_file("src/version.h.in" "${CMAKE_BINARY_DIR}/version/version.h")
add_custom_target(version ALL)
# --------------------------
# C++ Standard
# --------------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set C standard for proper stdint.h and other C headers
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-deprecated-builtins")
message(STATUS "Using ${CMAKE_CXX_COMPILER_ID} compiler with C++17")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
message(STATUS "Using MSVC compiler with C++17")
endif()
# Set C standard flags
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
message(STATUS "Using ${CMAKE_C_COMPILER_ID} compiler with C99")
endif()
# Debug/Release flags - platform-specific
if(MSVC)
# MSVC uses different optimization and warning flags
set(CMAKE_C_FLAGS_DEBUG "/Zi /Od /MDd")
set(CMAKE_CXX_FLAGS_DEBUG "/Zi /Od /MDd")
set(CMAKE_C_FLAGS_RELEASE "/O2 /DNDEBUG /MD")
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /DNDEBUG /MD")
# Disable specific warnings that cause issues
string(REPLACE "/W3" "/W0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/W3" "/W0" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS_DEBUG "-g3 -O0")
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -O0")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
endif()
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
message(STATUS "C++ Flags: ${CMAKE_CXX_FLAGS}")
# --------------------------
# Include directories
# --------------------------
include_directories(include src external "${CMAKE_BINARY_DIR}/version")
if(APPLE OR FREEBSD)
include_directories(SYSTEM /usr/include/malloc)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
enable_language(ASM)
# Add macOS specific definitions for Boost.Asio
add_definitions(-D_DARWIN_C_SOURCE -D__BSD_VISIBLE=1)
# Fix header search paths for macOS
if(APPLE)
# Ensure proper C++ standard library is used
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
# Explicitly set the sysroot to ensure proper header search paths
if(EXISTS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
elseif(EXISTS "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
set(CMAKE_OSX_SYSROOT "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
endif()
# Add C++ standard library headers explicitly
if(EXISTS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
include_directories(SYSTEM /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1)
include_directories(SYSTEM /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include)
elseif(EXISTS "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
include_directories(SYSTEM /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1)
include_directories(SYSTEM /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include)
endif()
# Add C standard library headers
if(EXISTS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
include_directories(SYSTEM /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include)
elseif(EXISTS "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
include_directories(SYSTEM /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include)
endif()
# Add Homebrew include paths for macOS (after standard library paths)
include_directories(SYSTEM /opt/homebrew/include)
include_directories(SYSTEM /usr/local/include)
# Ensure C targets also get proper system includes
if(EXISTS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include")
elseif(EXISTS "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include")
endif()
endif()
endif()
if(MSVC)
include_directories(src/Platform/Windows)
include_directories(src/Platform/Posix)
elseif(APPLE)
include_directories(src/Platform/OSX)
include_directories(src/Platform/Posix)
# Add additional system include directories for macOS
include_directories(SYSTEM /opt/homebrew/include)
include_directories(SYSTEM /usr/local/include)
# Add C++ standard library headers explicitly
if(EXISTS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
include_directories(SYSTEM /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1)
include_directories(SYSTEM /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include)
elseif(EXISTS "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
include_directories(SYSTEM /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1)
include_directories(SYSTEM /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include)
endif()
else()
include_directories(src/Platform/Linux)
include_directories(src/Platform/Posix)
endif()
include_directories(src/Platform/Android)
include_directories(src/Platform/FreeBSD)
# --------------------------
# Boost - Updated for 1.86
# --------------------------
# Link static BOOST libraries everywhere
set(Boost_NO_BOOST_CMAKE OFF)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
if(MINGW)
set(Boost_THREADAPI win32)
include_directories(SYSTEM src/platform/mingw)
endif()
# Required components
find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options coroutine context atomic)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
message(STATUS "Boost Found: ${Boost_INCLUDE_DIRS}")
message(STATUS "Found Boost Version: ${Boost_VERSION}")
# Platform-specific Boost library handling
if(MINGW)
set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock;iphlpapi;bcrypt")
elseif(APPLE)
# Ensure proper linking on macOS
if(EXISTS "/opt/homebrew/opt/boost@1.85/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/boost@1.85/lib -Wl,-rpath,/opt/homebrew/opt/boost@1.85/lib")
elseif(EXISTS "/usr/local/opt/boost@1.85/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/opt/boost@1.85/lib -Wl,-rpath,/usr/local/opt/boost@1.85/lib")
endif()
# Ensure we're using the correct Boost libraries path
if(EXISTS "/opt/homebrew/opt/boost@1.85/lib")
link_directories("/opt/homebrew/opt/boost@1.85/lib")
endif()
if(EXISTS "/usr/local/opt/boost@1.85/lib")
link_directories("/usr/local/opt/boost@1.85/lib")
endif()
elseif(OPENBSD OR ANDROID)
set(Boost_LIBRARIES "${Boost_LIBRARIES}")
elseif(NOT MSVC)
set(Boost_LIBRARIES "${Boost_LIBRARIES};rt")
endif()
# --------------------------
# jsoncpp Configuration
# --------------------------
# Check for Homebrew installation first (takes precedence on macOS)
if(APPLE)
# Check via Homebrew on macOS first
execute_process(COMMAND brew --prefix jsoncpp OUTPUT_VARIABLE BREW_JSONCPP_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE BREW_RESULT)
if(BREW_RESULT EQUAL 0)
set(JSONCPP_INCLUDE_DIRS "${BREW_JSONCPP_PREFIX}/include/json")
set(JSONCPP_LIBRARY_DIRS "${BREW_JSONCPP_PREFIX}/lib")
set(JSONCPP_LIBRARIES "${BREW_JSONCPP_PREFIX}/lib/libjsoncpp.dylib")
set(JSONCPP_FOUND TRUE)
message(STATUS "Found jsoncpp via Homebrew at ${JSONCPP_INCLUDE_DIRS}")
message(STATUS "jsoncpp library: ${JSONCPP_LIBRARIES}")
else()
# Fall back to find_package if Homebrew fails
find_package(jsoncpp QUIET)
if(jsoncpp_FOUND OR JSONCPP_FOUND)
if(jsoncpp_FOUND)
message(STATUS "Found jsoncpp via find_package")
endif()
else()
set(JSONCPP_FOUND FALSE)
endif()
endif()
else()
# For non-macOS, try find_package first
find_package(jsoncpp QUIET)
if(jsoncpp_FOUND OR JSONCPP_FOUND)
if(jsoncpp_FOUND)
message(STATUS "Found jsoncpp via find_package")
endif()
else()
set(JSONCPP_FOUND FALSE)
endif()
endif()
if(NOT JSONCPP_FOUND)
# Manual detection fallback
set(JSONCPP_FOUND FALSE)
set(JSONCPP_LIBRARIES "jsoncpp")
set(JSONCPP_LIBRARY_DIRS "")
# Try standard locations
if(EXISTS "/usr/include/json/json.h")
set(JSONCPP_INCLUDE_DIRS "/usr/include/json")
set(JSONCPP_FOUND TRUE)
message(STATUS "Found jsoncpp headers at /usr/include/json")
elseif(EXISTS "/usr/include/jsoncpp/json/json.h")
set(JSONCPP_INCLUDE_DIRS "/usr/include/jsoncpp/json")
set(JSONCPP_FOUND TRUE)
message(STATUS "Found jsoncpp headers at /usr/include/jsoncpp/json")
elseif(EXISTS "/usr/include/x86_64-linux-gnu/jsoncpp/json/json.h")
set(JSONCPP_INCLUDE_DIRS "/usr/include/x86_64-linux-gnu/jsoncpp/json")
set(JSONCPP_FOUND TRUE)
message(STATUS "Found jsoncpp headers at /usr/include/x86_64-linux-gnu/jsoncpp/json")
elseif(WIN32)
if(EXISTS "C:/vcpkg/installed/x64-windows/include/json/json.h")
set(JSONCPP_INCLUDE_DIRS "C:/vcpkg/installed/x64-windows/include/json")
set(JSONCPP_FOUND TRUE)
message(STATUS "Found jsoncpp via vcpkg at ${JSONCPP_INCLUDE_DIRS}")
endif()
endif()
if(JSONCPP_FOUND)
include_directories(SYSTEM ${JSONCPP_INCLUDE_DIRS})
else()
include_directories(SYSTEM /usr/include/json /usr/include/jsoncpp/json /usr/include/x86_64-linux-gnu/jsoncpp/json)
message(WARNING "jsoncpp headers not found, using fallback paths")
endif()
endif()
# Ensure variables are always defined
if(NOT DEFINED JSONCPP_LIBRARIES)
set(JSONCPP_LIBRARIES "jsoncpp")
endif()
if(NOT DEFINED JSONCPP_INCLUDE_DIRS)
set(JSONCPP_INCLUDE_DIRS "/usr/include/json")
endif()
if(NOT DEFINED JSONCPP_LIBRARY_DIRS)
set(JSONCPP_LIBRARY_DIRS "")
endif()
message(STATUS "jsoncpp include dirs: ${JSONCPP_INCLUDE_DIRS}")
message(STATUS "jsoncpp libraries: ${JSONCPP_LIBRARIES}")
message(STATUS "jsoncpp library dirs: ${JSONCPP_LIBRARY_DIRS}")
if(JSONCPP_LIBRARY_DIRS)
link_directories(${JSONCPP_LIBRARY_DIRS})
endif()
message(STATUS "Boost libraries: ${Boost_LIBRARIES}")
# Configure runtime path for Boost libraries on macOS
if(APPLE)
if(EXISTS "/opt/homebrew/opt/boost@1.85/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/boost@1.85/lib -Wl,-rpath,/opt/homebrew/opt/boost@1.85/lib")
elseif(EXISTS "/usr/local/opt/boost@1.85/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/opt/boost@1.85/lib -Wl,-rpath,/usr/local/opt/boost@1.85/lib")
endif()
# Also add ICU library paths
if(EXISTS "/opt/homebrew/opt/icu4c/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/icu4c/lib -Wl,-rpath,/opt/homebrew/opt/icu4c/lib")
elseif(EXISTS "/usr/local/opt/icu4c/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/opt/icu4c/lib -Wl,-rpath,/usr/local/opt/icu4c/lib")
endif()
endif()
# --------------------------
# ICU (skipped on Android)
# --------------------------
if(ANDROID)
message(STATUS "Android build detected: skipping ICU discovery")
else()
if(APPLE)
# Ensure proper ICU paths for macOS
if(EXISTS "/opt/homebrew/opt/icu4c")
list(APPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/icu4c")
set(ICU_ROOT "/opt/homebrew/opt/icu4c")
elseif(EXISTS "/usr/local/opt/icu4c")
list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/icu4c")
set(ICU_ROOT "/usr/local/opt/icu4c")
endif()
endif()
# Special handling for vcpkg on Windows
if(WIN32 AND DEFINED CMAKE_TOOLCHAIN_FILE AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
message(STATUS "Using vcpkg toolchain, configuring ICU search...")
# First try to find ICU without specifying components (vcpkg way)
find_package(ICU QUIET)
if(NOT ICU_FOUND)
# If that fails, try with explicit components
find_package(ICU REQUIRED COMPONENTS data i18n uc)
endif()
else()
# Standard ICU detection for non-vcpkg builds
find_package(ICU REQUIRED COMPONENTS data i18n uc)
endif()
if(ICU_FOUND)
message(STATUS "Found ICU includes: ${ICU_INCLUDE_DIRS}")
message(STATUS "Found ICU libraries: ${ICU_LIBRARIES}")
message(STATUS "ICU version: ${ICU_VERSION}")
include_directories(SYSTEM ${ICU_INCLUDE_DIRS})
# On macOS, ensure we have the correct ICU library paths
if(APPLE)
# Add ICU library directories
if(EXISTS "/opt/homebrew/opt/icu4c/lib")
link_directories("/opt/homebrew/opt/icu4c/lib")
elseif(EXISTS "/usr/local/opt/icu4c/lib")
link_directories("/usr/local/opt/icu4c/lib")
endif()
if(ICU_DATA_LIBRARY)
message(STATUS "ICU Data Library: ${ICU_DATA_LIBRARY}")
endif()
if(ICU_I18N_LIBRARY)
message(STATUS "ICU I18N Library: ${ICU_I18N_LIBRARY}")
endif()
if(ICU_UC_LIBRARY)
message(STATUS "ICU UC Library: ${ICU_UC_LIBRARY}")
endif()
endif()
else()
if(WIN32)
message(FATAL_ERROR "ICU not found! Make sure it's installed via vcpkg.")
else()
message(FATAL_ERROR "ICU not found, install via Homebrew: brew install icu4c")
endif()
endif()
endif()
# --------------------------
# Boost linking for executables (macOS)
# --------------------------
if(APPLE AND Boost_FOUND)
message(STATUS "Linking Boost libraries to executables")
foreach(exec_target Daemon SimpleWallet PaymentGateService Optimizer TestnetDaemon testnet-wallet-cli)
if(TARGET ${exec_target})
message(STATUS "Linking Boost to ${exec_target}")
target_link_libraries(${exec_target} PRIVATE ${Boost_LIBRARIES})
endif()
endforeach()
endif()
# --------------------------
# Compiler flags
# --------------------------
if(APPLE)
# Enhanced compiler flags for macOS to ensure proper header search
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-deprecated -Wno-deprecated-builtins -stdlib=libc++")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
# Ensure we're using the correct C++ standard library
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
# Set explicit sysroot if available
if(EXISTS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
elseif(EXISTS "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
set(CMAKE_OSX_SYSROOT "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
endif()
# Ensure proper system header inclusion
if(EXISTS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
elseif(EXISTS "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
endif()
endif()
# --------------------------
# Testing
# --------------------------
option(BUILD_TESTS "Build test executables" OFF)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# --------------------------
# Subdirectories
# --------------------------
add_subdirectory(external)
add_subdirectory(src)
# add_subdirectory(tui) # Disabled - requires separate build
# --------------------------
# ICU linking for executables (macOS)
# --------------------------
if(APPLE AND ICU_FOUND)
message(STATUS "Linking ICU libraries to executables")
foreach(exec_target Daemon SimpleWallet PaymentGateService Optimizer TestnetDaemon testnet-wallet-cli)
if(TARGET ${exec_target})
message(STATUS "Linking ICU to ${exec_target}")
target_link_libraries(${exec_target} PRIVATE ${ICU_LIBRARIES})
# Ensure proper rpath for ICU libraries on macOS
if(EXISTS "/opt/homebrew/opt/icu4c/lib")
set_target_properties(${exec_target} PROPERTIES
LINK_FLAGS "-L/opt/homebrew/opt/icu4c/lib -Wl,-rpath,/opt/homebrew/opt/icu4c/lib")
elseif(EXISTS "/usr/local/opt/icu4c/lib")
set_target_properties(${exec_target} PROPERTIES
LINK_FLAGS "-L/usr/local/opt/icu4c/lib -Wl,-rpath,/usr/local/opt/icu4c/lib")
endif()
endif()
endforeach()
# Note: TUI is a Go application and doesn't need ICU linking
# The Go TUI component is built separately with its own dependencies
endif()