-
Notifications
You must be signed in to change notification settings - Fork 446
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
618 lines (539 loc) · 25.2 KB
/
Copy pathCMakeLists.txt
File metadata and controls
618 lines (539 loc) · 25.2 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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
cmake_minimum_required(VERSION 3.16)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
include(SupportCcache)
project("VTR")
#
# VTR Build Options
#
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message("CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds not allowed. Use the Makefile wrapper (e.g. make), or create a new build directory and call cmake manually from there (e.g. mkdir -p build && cd build && cmake .. && make). You may need to 'rm -rf CMakeCache.txt CMakeFiles' first.")
endif()
#We install to the source directory by default
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "default install path" FORCE)
endif()
set(VTR_IPO_BUILD "auto" CACHE STRING "Should VTR be compiled with interprocedural compiler optimizations?")
set_property(CACHE VTR_IPO_BUILD PROPERTY STRINGS auto on off)
#Allow the user to configure how much assertion checking should occur
set(VTR_ASSERT_LEVEL "2" CACHE STRING "VTR assertion checking level. 0: no assertions, 1: fast assertions, 2: regular assertions, 3: additional assertions with noticeable run-time overhead, 4: all assertions (including those with significant run-time cost)")
set_property(CACHE VTR_ASSERT_LEVEL PROPERTY STRINGS 0 1 2 3 4)
option(VTR_ENABLE_SANITIZE "Enable address/leak/undefined-behaviour sanitizers (i.e. run-time error checking)" OFF)
option(VTR_ENABLE_PROFILING "Enable performance profiler (gprof)" OFF)
option(VTR_ENABLE_COVERAGE "Enable code coverage tracking (gcov)" OFF)
option(VTR_ENABLE_DEBUG_LOGGING "Enable debug logging" OFF)
option(VTR_ENABLE_VERBOSE "Enable increased debug verbosity" OFF)
option(SPEC_CPU "Enable SPEC CPU v8 support" OFF)
#Allow the user to decide whether to compile the graphics library
set(VPR_USE_EZGL "auto" CACHE STRING "Specify whether vpr uses the graphics library")
set_property(CACHE VPR_USE_EZGL PROPERTY STRINGS auto off on)
option(VTR_ENABLE_CAPNPROTO "Enable capnproto binary serialization support in VPR." ON)
#Allow the user to decide whether to compile the server module
option(VPR_USE_SERVER "Specify whether vpr enables the server mode" ON)
option(VPR_ENABLE_INTERCHANGE "Enable FPGA interchange." ON)
option(VPR_ENABLE_NOC_SAT_ROUTING "Enable NoC SAT routing." OFF)
option(WITH_BLIFEXPLORER "Enable build with blifexplorer" OFF)
option(WITH_ABC "Enable building abc" ON)
option(WITH_ODIN "Enable building odin" OFF)
option(ODIN_DEBUG "Enable building odin with debug flags" OFF)
option(ODIN_WARN "Enable building odin with extra warning flags" OFF)
option(ODIN_COVERAGE "Enable building odin with coverage flags" OFF)
option(ODIN_TIDY "Enable building odin with clang tidy" OFF)
option(ODIN_SANITIZE "Enable building odin with sanitize flags" OFF)
# Yosys plugins. Yosys is built when WITH_PARMYS or WITH_MOSAIC is on.
option(WITH_PARMYS "Enable Yosys as elaborator and parmys-plugin as partial mapper" ON)
option(WITH_MOSAIC "Enable mosaic yosys plugin as an alternative synthesis frontend" ON)
option(SLANG_SYSTEMVERILOG "Enable building and installing Yosys-Slang plugin for parsing SystemVerilog" ON)
if(${WITH_PARMYS} OR ${WITH_MOSAIC})
set(WITH_YOSYS ON)
else()
set(WITH_YOSYS OFF)
endif()
# slang is a yosys plugin, so skip it when neither frontend builds yosys
if(${SLANG_SYSTEMVERILOG} AND NOT ${WITH_YOSYS})
message(WARNING "Yosys is not enabled, disabling Yosys-Slang as well.")
set(SLANG_SYSTEMVERILOG OFF)
endif()
set(VTR_VERSION_MAJOR 9)
set(VTR_VERSION_MINOR 0)
set(VTR_VERSION_PATCH 0)
set(VTR_VERSION_PRERELEASE "dev")
include(FilesToDirs)
#
#
# Determine compiler configuration
#
#
#Set the default build type if not specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build: None, Debug, Release, RelWithDebInfo, MinSizeRel"
FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
#
#Set the assertion level
#
add_definitions("-DVTR_ASSERT_LEVEL=${VTR_ASSERT_LEVEL}")
if(WIN32)
# On Windows, <windows.h> defines min/max macros which conflict with std::min/std::max.
add_compile_definitions(NOMINMAX)
endif()
#Compiler flag configuration checks
include(CheckCXXCompilerFlag)
#
# We require c++20 support
#
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) #No compiler specific extensions
#
# Interprocedural optimization
#
# Note that we manually clear the INTERPROCEDURAL_OPTIMIZATION flag on ABC later
# to avoid cmake warnings
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
if (VTR_IPO_BUILD STREQUAL "on")
if (IPO_SUPPORTED)
message(STATUS "Building with IPO: on")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
else()
message(ERROR "Building with IPO unsupported with this compiler!")
endif()
elseif(VTR_IPO_BUILD STREQUAL "auto")
if (IPO_SUPPORTED AND NOT CMAKE_BUILD_TYPE STREQUAL "debug")
message(STATUS "Building with IPO: on (auto)")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
else()
message(STATUS "Building with IPO: off (auto)")
if(NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC")
endif()
endif()
else()
message(STATUS "Building with IPO: off")
endif()
#
# Build type flags
#
if(NOT MSVC)
# for GCC and Clang
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3")
endif()
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
#
# Warning flags
#
set(WARN_FLAGS "") #The actual warning flags to be applied
if(MSVC)
#Visual studio warnings
# Note that we don't use /Wall since it generates warnings about standard library headers
set(WARN_FLAGS_TO_CHECK #The flags to check if the compiler supports
"/W4" #Most warnings
)
else()
set(WARN_FLAGS_TO_CHECK #The flags to check if the compiler supports
#GCC-like
"-Wall" #Most warnings, typically good
"-Wextra" #Extra warning, usually good
"-Wpedantic" #Ensure ISO compliance (i.e. no non-standard extensions)
"-Wcast-qual" #Warn if cast removes qualifier (e.g. const char* -> char*)
"-Wcast-align" #Warn if a cast causes memory alignment changes
"-Wshadow" #Warn if local variable shadows another variable
"-Wformat=2" #Sanity checks for printf-like formatting
"-Wno-format-nonliteral" # But don't worry about non-literal formatting (i.e. run-time printf format strings)
"-Wlogical-op" #Checks for logical op when bit-wise expected
"-Wmissing-declarations" #Warn if a global function is defined with no declaration
"-Wmissing-include-dirs" #Warn if a user include directory is missing
"-Wredundant-decls" #Warn if there are overlapping declarations
"-Wswitch-default" #Warn if a switch has no default
"-Wundef" #Warn if #if() preprocessor refers to an undefined directive
"-Wunused" #Warn about unused variables/parameters
"-Wunused-variable" #Warn about variables that are not used
"-Wunused-parameter" #Warn about function parameters which are unused
"-Wdisabled-optimization" #Warn when optimizations are skipped (usually due to large/complex code)
"-Wnoexcept" #Warn when functions should be noexcept (i.e. compiler know it doesn't throw)
"-Woverloaded-virtual" #Warn when a function declaration overrides a virtual method
"-Wctor-dtor-privacy" #Warn about inaccessible constructors/destructors
"-Wnon-virtual-dtor" #Warn about missing virtual destructors
"-Wduplicated-cond" #Warn about identical conditions in if-else chains
"-Wduplicated-branches" #Warn when different branches of an if-else chain are equivalent
"-Wnull-dereference" #Warn about null pointer dereference execution paths
"-Wuninitialized" #Warn about uninitialized values
"-Winit-self" #Warn about self-initialization
"-Wcatch-value=3" #Warn when catch statements don't catch by reference
"-Wextra-semi" #Warn about redundant semicolons
"-Wimplicit-fallthrough=3" #Warn about case fallthroughs, but allow 'fallthrough' comments to suppress warnings
#GCC-like optional
#"-Wsuggest-final-types" #Suggest where 'final' would help if specified on a type methods
#"-Wsuggest-final-methods" #Suggest where 'final' would help if specified on methods
#"-Wsuggest-override" #Suggest where 'override' should be specified
#"-Wold-style-cast" #Warn about using c-style casts
#"-Wconversion" #Warn when type conversions may change value
#"-Wsign-conversion" #Warn if a conversion may change the sign
#"-Wpadded" #Will warn if additional padding is introduced to a struct/class. Turn on if optimizing class memory layouts
#"-Wstrict-overflow=2" #Warn if the compiler optimizes assuming signed overflow does not occur
#"-Wfloat-equal" #Warn about using direct floating point equality
#"-Wunsafe-loop-optimizations" #Warn when loops can't be optimized
#"-Wswitch-enum" #Warn about uncovered enumeration values in a switch (even if there is a default)
#"-Wsign-promo" #Warn when overload resolution converts an unsigned type to signed when an unsigned overload exists
#"-Wdouble-promotion" #Warn when float is implicitly propted to double
#"-Wuseless-cast" #Warn about casts to the same type
#"-Wzero-as-null-pointer-constant" #Warn about using '0' instead of nullptr
)
endif()
#Check and see if the compiler supports the various warning flags,
#and add valid flags
foreach(flag ${WARN_FLAGS_TO_CHECK})
CHECK_CXX_COMPILER_FLAG(${flag} CXX_COMPILER_SUPPORTS_${flag})
if(CXX_COMPILER_SUPPORTS_${flag})
#Flag supported, so enable it
set(WARN_FLAGS "${WARN_FLAGS} ${flag}")
endif()
endforeach()
#The flex/bison code is not warning clean so we need to suppress some warnings
set(FLEX_BISON_WARN_SUPPRESS_FLAGS "")
set(FLEX_BISON_WARN_SUPPRESS_FLAGS_TO_CHECK
"-Wno-redundant-decls" #Flex/bison generate code with redundant declarations
"-Wno-switch-default" #Flex/bison generate switch statements w/o default cases
"-Wno-unused-parameter" #Flex produces functions with unused params in re-entrant mode
"-Wno-missing-declarations" #Flex misses some declarations in re-entrant mode
"-Wimplicit-fallthrough=0" #Bison produces some cases with explicit
"-Wno-sign-compare" #Flex generates code which performs some signed/unsigned comparison
"-Wno-null-dereference" #Bison produces some cases with potential null derefs
)
foreach(flag ${FLEX_BISON_WARN_SUPPRESS_FLAGS_TO_CHECK})
CHECK_CXX_COMPILER_FLAG(${flag} CXX_COMPILER_SUPPORTS_${flag})
if(CXX_COMPILER_SUPPORTS_${flag})
#Flag supported, so enable it
set(FLEX_BISON_WARN_SUPPRESS_FLAGS "${FLEX_BISON_WARN_SUPPRESS_FLAGS} ${flag}")
endif()
endforeach()
# Suppress IPO link warnings.
# When IPO is turned on, it sometimes leads to false positives for warnings
# since it checks for warnings after some of the source files have been compiled.
# We globally suppress these warnings here. Any CMake executable which is added
# after this line will have these warnings suppressed at link time.
if (CMAKE_INTERPROCEDURAL_OPTIMIZATION)
message(STATUS "IPO: Suppressing known VTR warnings.")
# These warning flags are GCC-specific; skip on Clang (e.g. Apple Clang on macOS)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_link_options(-Wno-alloc-size-larger-than # libarchfpga allocates C-style arrays using integers.
-Wno-stringop-overflow # EXTERNAL/capnproto has some string overflow warnings.
)
endif()
endif()
#
# Sanitizer flags
#
set(SANITIZE_FLAGS "")
if(VTR_ENABLE_SANITIZE)
#Enable sanitizers
if(APPLE)
# macOS/Apple Clang: no -fuse-ld=gold, no -static-libasan, no leak sanitizer
set(SANITIZE_FLAGS "-g -fsanitize=address -fsanitize=undefined")
else()
# Linux/GCC: use gold linker and static libasan
set(SANITIZE_FLAGS "-g -fsanitize=address -fsanitize=leak -fuse-ld=gold -static-libasan")
endif()
message(STATUS "SANITIZE_FLAGS: ${SANITIZE_FLAGS}")
endif()
#
# Profiling flags
#
#Support for gprof
set(PROFILING_FLAGS "")
if(VTR_ENABLE_PROFILING)
#Enable gprof
set(PROFILING_FLAGS "-g -pg")
message(STATUS "Profiling Flags: ${PROFILING_FLAGS}")
endif()
#
# Code coverage flags
#
#Support for gcov
set(COVERAGE_FLAGS "")
if(VTR_ENABLE_COVERAGE)
#Enable gcov
set(COVERAGE_FLAGS "-g -ftest-coverage -fprofile-arcs")
# List form for target_compile_options / target_link_options consumers
# (e.g. libs/EXTERNAL/CMakeLists.txt scopes these to the ezgl submodule
# — see DEF-013 in vpr_gui_defects_discovered.rst).
set(COVERAGE_FLAGS_LIST -g -ftest-coverage -fprofile-arcs)
message(STATUS "Coverage Flags: ${COVERAGE_FLAGS}")
endif()
#
# Debug logging
#
set(LOGGING_FLAGS "")
if(VTR_ENABLE_DEBUG_LOGGING)
#Enable gcov
set(LOGGING_FLAGS "-DVTR_ENABLE_DEBUG_LOGGING")
message(STATUS "Logging Flags: ${LOGGING_FLAGS}")
endif()
#
# Increased debugging vebosity
#
set(EXTRA_FLAGS "")
if(VTR_ENABLE_VERBOSE)
set(EXTRA_FLAGS "${EXTRA_FLAGS} -DVTR_ENABLE_DEBUG_LOGGING")
message(STATUS "Enabling increased debugging verbosity")
endif()
#
# Build for SPEC CPU Benchmark v8
#
set(SPEC_CPU_FLAGS "")
if(SPEC_CPU)
# Enable SPEC CPU flag - Maximizes portability of code and minimizing the variation in how much work we do on different platforms
set(SPEC_CPU_FLAGS "-DSPEC_CPU")
message(STATUS "SPEC CPU FLAGS: ${SPEC_CPU_FLAGS}")
endif()
if (CMAKE_MAKE_PROGRAM EQUAL "ninja" )
#Only for coloured output for ninja, it may be desired
#to not force colours with other make programs (e.g. if
#being parsed by an IDE).
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(COLORED_COMPILE "-fdiagnostics-color=always")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(COLORED_COMPILE "-fcolor-diagnostics")
else()
set(COLORED_COMPILE "")
endif ()
endif()
#
# Set final flags
#
separate_arguments(
ADDITIONAL_FLAGS UNIX_COMMAND "${SANITIZE_FLAGS} ${PROFILING_FLAGS} ${COVERAGE_FLAGS} ${LOGGING_FLAGS} ${COLORED_COMPILE} ${EXTRA_FLAGS} ${SPEC_CPU_FLAGS}"
)
separate_arguments(
WARN_FLAGS UNIX_COMMAND "${WARN_FLAGS}"
)
#
# Titan Benchmarks
#
add_custom_target(get_titan_benchmarks
COMMAND ./vtr_flow/scripts/download_titan.py --vtr_flow_dir ./vtr_flow
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Downloading (~1GB) and extracting Titan benchmarks (~10GB) into VTR source tree.")
#
# NoC MLP Benchmarks
#
add_custom_target(get_noc_mlp_benchmarks
COMMAND ./vtr_flow/scripts/download_noc_mlp.py --vtr_flow_dir ./vtr_flow
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Downloading (~100MB) and extracting NoC MLP benchmarks (~3.2GB) into VTR source tree.")
#
# ISPD Benchmarks
#
add_custom_target(get_ispd_benchmarks
COMMAND ./vtr_flow/scripts/download_ispd.py --vtr_flow_dir ./vtr_flow
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Downloading (~50MB) and extracting Titan benchmarks (~0.5GB) into VTR source tree.")
#
# SymbiFlow Benchmarks
#
add_custom_target(get_symbiflow_benchmarks
COMMAND ./vtr_flow/scripts/download_symbiflow.py --vtr_flow_dir ./vtr_flow
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Downloading (~100MB) and extracting SymbiFlow architectures (~2.7GB) into VTR source tree.")
#
# Zero ASIC RR Graph Files
#
add_custom_target(get_zeroasic_rr_graphs
COMMAND ./vtr_flow/scripts/get_zeroasic_rr_graphs.py --vtr_flow_dir ./vtr_flow
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Downloading (~2MB) and extracting Zero ASIC RR graphs (~0.1GB) into VTR source tree.")
#
# Flat Placement Files
#
add_custom_target(get_flat_placements
COMMAND ./vtr_flow/scripts/get_flat_placement_files.py --vtr_flow_dir ./vtr_flow
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Downloading (~5MB) and extracting Flat Placement Files (~0.1GB) into VTR source tree.")
#
# Unit Testing
#
enable_testing()
#
# Sub-projects
#
#Explicitly specify that libreadline has not been found
# This must be explicitly set for ABC to not depend on
# libreadline. Note that because the ABC CMakeLists uses MATCHES
# in its check the value must be explicitly 'FALSE' (in upper case).
#
# TODO: Ideally ABC's CMakeLists.txt should handle this itself,
# or we should really search for readline correctly.
# For now just disable readline.
set(READLINE_FOUND FALSE)
# ===========================================================================
# Qt6 discovery for the VPR GUI (EZGL).
#
# Goal: a plain `make` finds Qt6 and the resulting binaries/tests run with NO
# Qt environment variables (no LD_LIBRARY_PATH / QT_PLUGIN_PATH / QT6_HOME).
#
# Strategy:
# * Require Qt >= 6.9.3. QRhi is available since Qt 6.7, but even Qt 6.8 has
# rendering bugs, so the floor is set higher.
# * Prefer a SYSTEM Qt on the loader's default search path -> no RPATH needed
# and the binaries stay relocatable.
# * Otherwise fall back to a repo-local SDK provisioned by
# ./dev/ensure_qt6_sdk.sh (default <repo>/qt6, override with VTR_QT_PREFIX)
# and bake its lib dir into RPATH so the binaries still run with no env.
# * An explicit user CMAKE_PREFIX_PATH / Qt6_DIR always wins; RPATH is baked
# only when the chosen Qt lib dir is outside the default search path.
# ===========================================================================
set(VTR_QT_MIN_VERSION 6.9.3)
# We knowingly depend on Qt private modules (QRhi / QShader via Qt6::GuiPrivate
# in libezgl), which have no binary/source-compatibility guarantees. Silence
# Qt's private-module warning here -- it must be set BEFORE the first
# find_package(Qt6) so it is in scope for every Qt package load downstream,
# including the libezgl subdirectory's find_package(Qt6 ... GuiPrivate).
set(QT_NO_PRIVATE_MODULE_WARNING ON)
if (NOT VPR_USE_EZGL STREQUAL "off")
# 1) System-first probe. This honors any explicit user override
# (env CMAKE_PREFIX_PATH / Qt6_DIR, or a cached Qt6_DIR): an explicit
# path always gets first crack here.
find_package(Qt6 ${VTR_QT_MIN_VERSION} QUIET COMPONENTS Core Gui Widgets)
# 2) Fall back to the repo-local SDK whenever the probe above did not find a
# suitable Qt -- regardless of any env/cache override. The override had
# its chance in step 1; if it didn't resolve a usable Qt6, a validated
# repo-local SDK (./dev/ensure_qt6_sdk.sh) should still be used rather
# than failing the build. (Previously a stale `Qt6_DIR-NOTFOUND` cache
# entry or an unrelated CMAKE_PREFIX_PATH in the environment would
# suppress this fallback and abort even though a valid SDK was present.)
if (NOT Qt6_FOUND)
set(_vtr_qt_prefix "$ENV{VTR_QT_PREFIX}")
if (NOT _vtr_qt_prefix)
set(_vtr_qt_prefix "${CMAKE_SOURCE_DIR}/qt6")
endif()
# aqt layout: <prefix>/<version>/gcc_64.
file(GLOB _vtr_qt_candidates "${_vtr_qt_prefix}/*/gcc_64")
list(SORT _vtr_qt_candidates)
list(REVERSE _vtr_qt_candidates) # newest version first
foreach(_home ${_vtr_qt_candidates})
if (EXISTS "${_home}/lib/cmake/Qt6")
list(PREPEND CMAKE_PREFIX_PATH "${_home}")
message(STATUS "VTR: using repo-local Qt6 SDK at ${_home}")
break()
endif()
endforeach()
find_package(Qt6 ${VTR_QT_MIN_VERSION} QUIET COMPONENTS Core Gui Widgets)
endif()
endif()
# Resolve VPR_USE_EZGL (auto -> on/off) from whether a suitable Qt was found.
# VPR_USE_EZGL decides whether the graphics subdirectory is added; it is read by
# both the vpr CMakeLists and libs/EXTERNAL CMakeLists.
if (VPR_USE_EZGL STREQUAL "auto")
if (Qt6_FOUND)
set(VPR_USE_EZGL "on")
message(STATUS "VPR Graphics: Enabled (Qt6 ${Qt6_VERSION} found)")
else()
set(VPR_USE_EZGL "off")
message(STATUS "VPR Graphics: Disabled (no Qt6 >= ${VTR_QT_MIN_VERSION}; run ./dev/ensure_qt6_sdk.sh or install a system Qt6 if its version >= ${VTR_QT_MIN_VERSION})")
endif()
endif()
# Graphics explicitly requested but no suitable Qt -> fail loudly.
if (VPR_USE_EZGL STREQUAL "on" AND NOT Qt6_FOUND)
message(FATAL_ERROR
"VPR_USE_EZGL=on but Qt6 >= ${VTR_QT_MIN_VERSION} was not found. "
"Run ./dev/ensure_qt6_sdk.sh to provision a repo-local Qt SDK, install a "
"system Qt6 >= ${VTR_QT_MIN_VERSION}, or pass -DCMAKE_PREFIX_PATH=<qt-prefix>.")
endif()
# Custom Mode: bake the Qt lib dir into RPATH so binaries run with no env.
# Skipped for a system Qt (already on the default loader search path).
if (Qt6_FOUND AND VPR_USE_EZGL STREQUAL "on")
# Qt6_DIR is <prefix>/lib/cmake/Qt6 -> its grandparent is the Qt lib dir.
get_filename_component(_qt_libdir "${Qt6_DIR}/../.." ABSOLUTE)
if (_qt_libdir MATCHES "^/usr/" OR _qt_libdir MATCHES "^/lib/")
message(STATUS "VTR: system Qt6 at ${_qt_libdir} (no RPATH baking)")
else()
list(APPEND CMAKE_BUILD_RPATH "${_qt_libdir}")
list(APPEND CMAKE_INSTALL_RPATH "${_qt_libdir}")
message(STATUS "VTR: baking custom Qt6 lib dir into RPATH: ${_qt_libdir}")
endif()
endif()
#Add the various sub-projects
if(${WITH_ABC})
add_subdirectory(abc)
endif()
add_subdirectory(libs) #libs/CMakeLists.txt handles adding warnings flags to non-external libraries
if(${WITH_PARMYS})
add_subdirectory(parmys)
endif()
if(${WITH_MOSAIC})
add_subdirectory(mosaic)
endif()
#Add the various tools
add_compile_options(${WARN_FLAGS}) #Add warn flags for VTR tools
add_compile_options(${ADDITIONAL_FLAGS})
link_libraries(${ADDITIONAL_FLAGS})
add_subdirectory(vpr)
if(${WITH_ABC})
add_subdirectory(ace2)
endif()
add_subdirectory(utils)
if(${WITH_ODIN})
add_subdirectory(odin_ii)
# blifexplorer depends on odin
if(${WITH_BLIFEXPLORER})
add_subdirectory(blifexplorer)
endif()
endif()
#Add extra compilation flags to suppress warnings from some libraries/tools
# Note that target_compile_options() *appends* to the current compilation options of
# the specified target
if(${WITH_ABC})
#Since ABC is an externally developed tool, we suppress all compiler warnings
CHECK_CXX_COMPILER_FLAG("-w" CXX_COMPILER_SUPPORTS_-w)
if(CXX_COMPILER_SUPPORTS_-w)
target_compile_options(libabc PRIVATE "-w")
target_compile_options(abc PRIVATE "-w")
endif()
#Some ABC headers generate warnings, treat them as system headers to suppress warnings
get_property(ABC_INCLUDE_DIRS TARGET libabc PROPERTY INCLUDE_DIRECTORIES)
target_include_directories(libabc SYSTEM INTERFACE ${ABC_INCLUDE_DIRS})
#We don't control the ABC cmake file, so we need to manually unset the IPO flags
#to avoid cmake dev warnings due to it's old cmake version policy
set_target_properties(abc libabc libabc-pic PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
endif()
#PugiXml has some deliberate switch fallthrough cases (as indicated by comments), but they
#are tagged as warnings with g++-7 (the comments don't match g++-7's suppression regexes).
#Since we don't want to change PugiXml (it is developed externally), we relax the warning
#level so no fallthrough warnings are generated
CHECK_CXX_COMPILER_FLAG("-Wimplicit-fallthrough=0" CXX_COMPILER_SUPPORTS_-Wimplicit-fallthrough=0)
if(CXX_COMPILER_SUPPORTS_-Wimplicit-fallthrough=0)
target_compile_options(libpugixml PRIVATE "-Wimplicit-fallthrough=0")
endif()
#
#
# Code Autoformatting
#
#
list(APPEND DIRS_TO_FORMAT_CPP "${CMAKE_CURRENT_SOURCE_DIR}/vpr")
list(APPEND DIRS_TO_FORMAT_CPP "${CMAKE_CURRENT_SOURCE_DIR}/libs/libarchfpga")
list(APPEND DIRS_TO_FORMAT_CPP "${CMAKE_CURRENT_SOURCE_DIR}/libs/libvtrutil")
list(APPEND DIRS_TO_FORMAT_CPP "${CMAKE_CURRENT_SOURCE_DIR}/libs/libpugiutil")
list(APPEND DIRS_TO_FORMAT_CPP "${CMAKE_CURRENT_SOURCE_DIR}/libs/liblog")
list(APPEND DIRS_TO_FORMAT_CPP "${CMAKE_CURRENT_SOURCE_DIR}/libs/librtlnumber")
list(APPEND DIRS_TO_FORMAT_CPP "${CMAKE_CURRENT_SOURCE_DIR}/odin_ii")
include(AutoClangFormat)
list(APPEND DIRS_TO_FORMAT_PY "${CMAKE_CURRENT_SOURCE_DIR}/odin_ii")
list(APPEND DIRS_TO_FORMAT_PY "${CMAKE_CURRENT_SOURCE_DIR}/ace2")
list(APPEND DIRS_TO_FORMAT_PY "${CMAKE_CURRENT_SOURCE_DIR}/dev")
list(APPEND DIRS_TO_FORMAT_PY "${CMAKE_CURRENT_SOURCE_DIR}/doc")
list(APPEND DIRS_TO_FORMAT_PY "${CMAKE_CURRENT_SOURCE_DIR}/vpr")
list(APPEND DIRS_TO_FORMAT_PY "${CMAKE_CURRENT_SOURCE_DIR}/vtr_flow")
include(AutoPyFormat)
#
# Python Environment setup
#
include(PyEnv)