-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
731 lines (630 loc) · 19.6 KB
/
CMakeLists.txt
File metadata and controls
731 lines (630 loc) · 19.6 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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
# OpenSTA, Static Timing Analyzer
# Copyright (c) 2026, Parallax Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software.
#
# Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
#
# This notice may not be removed or altered from any source distribution.
cmake_minimum_required (VERSION 3.16)
project(STA VERSION 3.1.0
LANGUAGES CXX
)
option(CUDD_DIR "CUDD BDD package directory")
option(USE_TCL_READLINE "Use TCL readline package" ON)
option(ENABLE_TSAN "Compile with thread santizer enabled" OFF)
option(ENABLE_ASAN "Compile with address santizer enabled" OFF)
# Turn on to debug compiler args.
set(CMAKE_VERBOSE_MAKEFILE OFF)
# Write compile_commands.json to the build directory for clang-tidy.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(STA_HOME ${PROJECT_SOURCE_DIR})
message(STATUS "STA version: ${PROJECT_VERSION}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC STA_GIT_SHA1)
message(STATUS "STA git sha: ${STA_GIT_SHA1}")
# Default to bulding optimnized/release executable.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE)
endif()
message(STATUS "System name: ${CMAKE_SYSTEM_NAME}")
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Build CXX_FLAGS: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
# Enable Link-Time Optimization (LTO) for Release builds.
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error)
if(ipo_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
message(STATUS "IPO/LTO: enabled for Release builds")
else()
message(STATUS "IPO/LTO: not supported - ${ipo_error}")
endif()
################################################################
#
# Source files.
#
################################################################
set(STA_SOURCE
app/StaMain.cc
dcalc/ArcDcalcWaveforms.cc
dcalc/ArcDelayCalc.cc
dcalc/ArnoldiDelayCalc.cc
dcalc/ArnoldiReduce.cc
dcalc/CcsCeffDelayCalc.cc
dcalc/Delay.cc
dcalc/DelayCalc.cc
dcalc/DelayCalcBase.cc
dcalc/DelayNormal.cc
dcalc/DelayScalar.cc
dcalc/DelaySkewNormal.cc
dcalc/DmpCeff.cc
dcalc/DmpDelayCalc.cc
dcalc/FindRoot.cc
dcalc/GraphDelayCalc.cc
dcalc/LumpedCapDelayCalc.cc
dcalc/NetCaps.cc
dcalc/ParallelDelayCalc.cc
dcalc/PrimaDelayCalc.cc
dcalc/UnitDelayCalc.cc
graph/Graph.cc
graph/GraphCmp.cc
liberty/EquivCells.cc
liberty/FuncExpr.cc
liberty/InternalPower.cc
liberty/LeakagePower.cc
liberty/Liberty.cc
liberty/LibertyBuilder.cc
liberty/LibExprReader.cc
liberty/LibertyParser.cc
liberty/LibertyReader.cc
liberty/LibertyWriter.cc
liberty/LinearModel.cc
liberty/Sequential.cc
liberty/TableModel.cc
liberty/TimingArc.cc
liberty/TimingModel.cc
liberty/TimingRole.cc
liberty/Units.cc
liberty/Wireload.cc
network/ConcreteLibrary.cc
network/ConcreteNetwork.cc
network/HpinDrvrLoad.cc
network/Network.cc
network/NetworkCmp.cc
network/ParseBus.cc
network/PortDirection.cc
network/SdcNetwork.cc
network/VerilogNamespace.cc
parasitics/ConcreteParasitics.cc
parasitics/EstimateParasitics.cc
parasitics/Parasitics.cc
parasitics/ReduceParasitics.cc
parasitics/ReportParasiticAnnotation.cc
parasitics/SpefNamespace.cc
parasitics/SpefReader.cc
parasitics/SpefReaderPvt.hh
power/Power.cc
power/ReportPower.cc
power/VcdReader.cc
power/SaifReader.cc
power/VcdParse.cc
sdc/Clock.cc
sdc/ClockGatingCheck.cc
sdc/ClockGroups.cc
sdc/ClockInsertion.cc
sdc/ClockLatency.cc
sdc/CycleAccting.cc
sdc/DataCheck.cc
sdc/DeratingFactors.cc
sdc/DisabledPorts.cc
sdc/ExceptionPath.cc
sdc/FilterObjects.cc
sdc/InputDrive.cc
sdc/PinPair.cc
sdc/PortDelay.cc
sdc/PortExtCap.cc
sdc/Sdc.cc
sdc/SdcCmdComment.cc
sdc/Variables.cc
sdc/WriteSdc.cc
sdf/ReportAnnotation.cc
sdf/SdfReader.cc
sdf/SdfWriter.cc
search/Bdd.cc
search/Bfs.cc
search/CheckMaxSkews.cc
search/CheckMinPeriods.cc
search/CheckMinPulseWidths.cc
search/CheckCapacitances.cc
search/CheckFanouts.cc
search/CheckSlews.cc
search/CheckTiming.cc
search/ClkInfo.cc
search/ClkLatency.cc
search/ClkNetwork.cc
search/ClkSkew.cc
search/Crpr.cc
search/FindRegister.cc
search/GatedClk.cc
search/Genclks.cc
search/Latches.cc
search/Levelize.cc
search/MakeTimingModel.cc
search/Mode.cc
search/Path.cc
search/Path.cc
search/PathEnd.cc
search/PathEnum.cc
search/PathExpanded.cc
search/PathGroup.cc
search/PocvMode.cc
search/Property.cc
search/ReportPath.cc
search/Search.cc
search/SearchPred.cc
search/Scene.cc
search/Sim.cc
search/Sta.cc
search/StaState.cc
search/Tag.cc
search/TagGroup.cc
search/VertexVisitor.cc
search/VisitPathEnds.cc
search/WorstSlack.cc
spice/WritePathSpice.cc
spice/WriteSpice.cc
spice/Xyce.cc
tcl/TclTypeHelpers.cc
util/Debug.cc
util/DispatchQueue.cc
util/Error.cc
util/Fuzzy.cc
util/Hash.cc
util/MinMax.cc
util/PatternMatch.cc
util/Report.cc
util/ReportStd.cc
util/ReportTcl.cc
util/RiseFallMinMax.cc
util/RiseFallMinMaxDelay.cc
util/RiseFallValues.cc
util/Stats.cc
util/StringUtil.cc
util/Transition.cc
verilog/VerilogReader.cc
verilog/VerilogWriter.cc
)
if(APPLE)
list(APPEND STA_SOURCE util/MachineApple.cc)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND STA_SOURCE util/MachineLinux.cc)
elseif(WIN32)
list(APPEND STA_SOURCE util/MachineWin32.cc)
else()
list(APPEND STA_SOURCE util/MachineUnknown.cc)
endif()
# Source files.
set(STA_TCL_FILES
tcl/Init.tcl
tcl/Util.tcl
tcl/CmdArgs.tcl
tcl/CmdUtil.tcl
tcl/Property.tcl
tcl/Sta.tcl
tcl/Splash.tcl
tcl/Variables.tcl
dcalc/DelayCalc.tcl
graph/Graph.tcl
liberty/Liberty.tcl
network/Link.tcl
network/Network.tcl
network/NetworkEdit.tcl
parasitics/Parasitics.tcl
power/Power.tcl
sdc/Sdc.tcl
sdf/Sdf.tcl
search/Search.tcl
spice/WriteSpice.tcl
verilog/Verilog.tcl
)
################################################################
#
# Flex/bison scanner/parsers
#
################################################################
# Earlier versions of flex use 'register' declarations that are illegal in c++17.
#find_package(FLEX 2.6.4)
find_package(FLEX)
find_package(BISON REQUIRED 3.2)
# Verilog scan/parse.
flex_target(VerilogLex ${STA_HOME}/verilog/VerilogLex.ll
${CMAKE_CURRENT_BINARY_DIR}/VerilogLex.cc)
bison_target(VerilogParse ${STA_HOME}/verilog/VerilogParse.yy
${CMAKE_CURRENT_BINARY_DIR}/VerilogParse.cc)
add_flex_bison_dependency(VerilogLex VerilogParse)
# Liberty scan/parse.
flex_target(LibertyLex ${STA_HOME}/liberty/LibertyLex.ll
${CMAKE_CURRENT_BINARY_DIR}/LibertyLex.cc)
bison_target(LibertyParse ${STA_HOME}/liberty/LibertyParse.yy
${CMAKE_CURRENT_BINARY_DIR}/LibertyParse.cc)
add_flex_bison_dependency(LibertyLex LibertyParse)
# Liberty Expr scan/parse.
flex_target(LibExprLex ${STA_HOME}/liberty/LibExprLex.ll
${CMAKE_CURRENT_BINARY_DIR}/LibExprLex.cc)
bison_target(LibExprParse ${STA_HOME}/liberty/LibExprParse.yy
${CMAKE_CURRENT_BINARY_DIR}/LibExprParse.cc)
add_flex_bison_dependency(LibExprLex LibExprParse)
# Sdf scan/parse.
flex_target(SdfLex ${STA_HOME}/sdf/SdfLex.ll
${CMAKE_CURRENT_BINARY_DIR}/SdfLex.cc)
bison_target(SdfParse ${STA_HOME}/sdf/SdfParse.yy
${CMAKE_CURRENT_BINARY_DIR}/SdfParse.cc)
add_flex_bison_dependency(SdfLex SdfParse)
# Spef scan/parse.
flex_target(SpefLex ${STA_HOME}/parasitics/SpefLex.ll
${CMAKE_CURRENT_BINARY_DIR}/SpefLex.cc)
bison_target(SpefParse ${STA_HOME}/parasitics/SpefParse.yy
${CMAKE_CURRENT_BINARY_DIR}/SpefParse.cc)
add_flex_bison_dependency(SpefLex SpefParse)
# Saif scan/parse.
flex_target(SaifLex ${STA_HOME}/power/SaifLex.ll
${CMAKE_CURRENT_BINARY_DIR}/SaifLex.cc)
bison_target(SaifParse ${STA_HOME}/power/SaifParse.yy
${CMAKE_CURRENT_BINARY_DIR}/SaifParse.cc)
add_flex_bison_dependency(SaifLex SaifParse)
# Suppress -Wsign-compare in flex-generated code (yyleng vs int loop counter).
# Only needed with older GCC (e.g. CentOS 7 stock 4.8.5); newer GCC/flex handle it.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(
${FLEX_VerilogLex_OUTPUTS}
${FLEX_LibertyLex_OUTPUTS}
${FLEX_LibExprLex_OUTPUTS}
${FLEX_SdfLex_OUTPUTS}
${FLEX_SpefLex_OUTPUTS}
${FLEX_SaifLex_OUTPUTS}
PROPERTIES COMPILE_FLAGS "-Wno-sign-compare"
)
endif()
################################################################
set(STA_TCL_INIT ${CMAKE_CURRENT_BINARY_DIR}/StaTclInitVar.cc)
# TCL files included as part of the executable are shoved into StaTclInitVar.cc.
# These files are encoded and shipped as part of the executable
# so that they do not have to be installed on the client host.
add_custom_command(OUTPUT ${STA_TCL_INIT}
COMMAND etc/TclEncode.tcl ${STA_TCL_INIT} tcl_inits ${STA_TCL_FILES}
WORKING_DIRECTORY ${STA_HOME}
DEPENDS ${STA_TCL_FILES} etc/TclEncode.tcl
)
################################################################
#
# Library dependencies
#
################################################################
# OSX tcl is deprecated and prints a warning, so look for a user installed
# version before using the system version.
# I tried to override the library search order instead but failed.
# CMAKE_FIND_FRAMEWORK LAST bypasses the version in the framework directory
# but not the one in /usr/lib.
# This calls cmake/FindTCL.cmake
# Do not use REQUIRED because it also requires TK, which is not used by OpenSTA.
find_package(TCL)
# Referenced by util/StaConfig.hh.cmake
set(TCL_READLINE 0)
# check for tclReadline
if (USE_TCL_READLINE)
set(TCL_READLINE_POSSIBLE_NAMES
tclreadline-2.1.0
tclreadline-2.3.2
tclreadline-2.3.6
tclreadline-2.3.7
tclreadline-2.3.8
)
find_library(TCL_READLINE_LIBRARY
NAMES tclreadline ${TCL_READLINE_POSSIBLE_NAMES}
PATHS ${TCL_LIB_PATHS}
)
if (TCL_READLINE_LIBRARY)
message(STATUS "TCL readline library: ${TCL_READLINE_LIBRARY}")
else()
message(STATUS "TCL readline library: NOT FOUND")
endif()
find_path(TCL_READLINE_INCLUDE tclreadline.h)
if (TCL_READLINE_INCLUDE)
message(STATUS "TCL readline header: ${TCL_READLINE_INCLUDE}/tclreadline.h")
else()
message(STATUS "TCL readline header: NOT FOUND")
endif()
if (TCL_READLINE_LIBRARY AND TCL_READLINE_INCLUDE)
set(TCL_READLINE 1)
endif()
endif()
# Zlib
include(FindZLIB)
find_package(Threads)
find_package(Eigen3 REQUIRED)
# See if std::format is available and if nor install fmt.
include(CheckCXXSourceCompiles)
set(_sta_fmt_check_saved_flags "${CMAKE_REQUIRED_FLAGS}")
if(MSVC)
string(APPEND CMAKE_REQUIRED_FLAGS " /std:c++20")
else()
string(APPEND CMAKE_REQUIRED_FLAGS " -std=c++20")
endif()
check_cxx_source_compiles("
#include <format>
#include <string>
int main() { (void)std::format(\"{}\", 42); return 0; }
" HAVE_CXX_STD_FORMAT)
set(CMAKE_REQUIRED_FLAGS "${_sta_fmt_check_saved_flags}")
if(HAVE_CXX_STD_FORMAT)
message(STATUS "std::format: available")
else()
# Use spdlog's bundled fmt when available to avoid ODR violations.
find_package(spdlog QUIET)
if(spdlog_FOUND)
message(STATUS "std::format: using spdlog's bundled fmt")
set(STA_USE_SPDLOG_FMT TRUE)
get_target_property(_spdlog_inc spdlog::spdlog INTERFACE_INCLUDE_DIRECTORIES)
set(_fmt_dir "${CMAKE_CURRENT_BINARY_DIR}/_spdlog_fmt")
file(MAKE_DIRECTORY "${_fmt_dir}")
file(CREATE_LINK "${_spdlog_inc}/spdlog/fmt/bundled" "${_fmt_dir}/fmt" SYMBOLIC)
else()
message(STATUS "std::format: building fmt library")
include(FetchContent)
FetchContent_Declare(fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 11.0.2
)
FetchContent_MakeAvailable(fmt)
endif()
endif()
include(cmake/FindCUDD.cmake)
# configure a header file to pass some of the CMake settings
configure_file(${STA_HOME}/util/StaConfig.hh.cmake
${CMAKE_CURRENT_BINARY_DIR}/include/sta/StaConfig.hh
)
###########################################################
# Swig
###########################################################
find_package(SWIG 3.0 REQUIRED)
message(STATUS "SWIG version: ${SWIG_VERSION}")
include(UseSWIG)
set(STA_SWIG_FILE app/StaApp.i)
set_property(SOURCE ${STA_SWIG_FILE}
PROPERTY CPLUSPLUS ON
)
# SWIG flags (CMake UseSWIG).
set_property(SOURCE ${STA_SWIG_FILE}
PROPERTY COMPILE_OPTIONS
-module sta
-namespace
-prefix sta
)
set(SWIG_FILES
${STA_HOME}/dcalc/DelayCalc.i
${STA_HOME}/graph/Graph.i
${STA_HOME}/liberty/Liberty.i
${STA_HOME}/network/Network.i
${STA_HOME}/network/NetworkEdit.i
${STA_HOME}/parasitics/Parasitics.i
${STA_HOME}/power/Power.i
${STA_HOME}/sdc/Sdc.i
${STA_HOME}/sdf/Sdf.i
${STA_HOME}/search/Property.i
${STA_HOME}/search/Search.i
${STA_HOME}/spice/WriteSpice.i
${STA_HOME}/tcl/Exception.i
${STA_HOME}/tcl/StaTclTypes.i
${STA_HOME}/util/Util.i
${STA_HOME}/verilog/Verilog.i
)
set_property(SOURCE ${STA_SWIG_FILE}
PROPERTY DEPENDS ${SWIG_FILES}
)
swig_add_library(sta_swig
LANGUAGE tcl
TYPE STATIC
SOURCES ${STA_SWIG_FILE}
)
get_target_property(STA_SWIG_CXX_FILE sta_swig SOURCES)
set_source_files_properties(${STA_SWIG_CXX_FILE}
PROPERTIES
# No simple way to modify the swig template that emits code full of warnings
# so suppress them.
COMPILE_OPTIONS "-Wunused-variable;-Wno-cast-qual;-Wno-missing-braces;-Wno-deprecated-declarations"
)
target_link_libraries(sta_swig
PUBLIC
OpenSTA
)
# result build/CMakeFiles/sta_swig.dir/StaAppTCL_wrap.cxx
target_include_directories(sta_swig
PUBLIC
include/sta
PRIVATE
${STA_HOME}
${TCL_INCLUDE_PATH}
${CMAKE_CURRENT_BINARY_DIR}/include/sta
)
# Pass sta_swig include directories to SWIG as -I (same paths as the C++ build).
set_property(TARGET sta_swig PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
###########################################################
# Library
###########################################################
add_library(OpenSTA)
target_sources(OpenSTA
PRIVATE
${STA_SOURCE}
${STA_TCL_INIT}
${FLEX_LibExprLex_OUTPUTS}
${BISON_LibExprParse_OUTPUTS}
${FLEX_LibertyLex_OUTPUTS}
${BISON_LibertyParse_OUTPUTS}
${FLEX_SpefLex_OUTPUTS}
${BISON_SpefParse_OUTPUTS}
${FLEX_SdfLex_OUTPUTS}
${BISON_SdfParse_OUTPUTS}
${FLEX_VerilogLex_OUTPUTS}
${BISON_VerilogParse_OUTPUTS}
${FLEX_SaifLex_OUTPUTS}
${BISON_SaifParse_OUTPUTS}
)
target_link_libraries(OpenSTA
Eigen3::Eigen
${TCL_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
${CUDD_LIB}
)
if(NOT HAVE_CXX_STD_FORMAT)
if(STA_USE_SPDLOG_FMT)
target_include_directories(OpenSTA PUBLIC "${_fmt_dir}")
target_link_libraries(OpenSTA spdlog::spdlog)
else()
target_link_libraries(OpenSTA fmt::fmt)
endif()
endif()
if (ZLIB_LIBRARIES)
target_link_libraries(OpenSTA ${ZLIB_LIBRARIES})
endif()
target_include_directories(OpenSTA
PUBLIC
include
${TCL_INCLUDE_PATH}
${FLEX_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}/include/sta
PRIVATE
include/sta
${STA_HOME}
${CUDD_INCLUDE}
# For flex to find location.hh
${CMAKE_CURRENT_BINARY_DIR}
)
if (TCL_READLINE)
target_link_libraries(OpenSTA ${TCL_READLINE_LIBRARY})
target_include_directories(OpenSTA
PUBLIC
${TCL_READLINE_INCLUDE})
endif()
# common to gcc/clang
set(CXX_FLAGS -Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls
-Wformat-security -Werror=misleading-indentation -Wundef)
if(ENABLE_TSAN)
message(STATUS "Thread sanitizer: ${ENABLE_TSAN}")
set(CXX_FLAGS "${CXX_FLAGS};-fsanitize=thread")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fsanitize=thread")
endif()
if(ENABLE_ASAN)
message(STATUS "Address sanitizer: ${ENABLE_ASAN}")
set(CXX_FLAGS "${CXX_FLAGS};-fsanitize=address")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fsanitize=address")
endif()
target_compile_options(OpenSTA
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:${CXX_FLAGS} -Wno-format-zero-length>
$<$<CXX_COMPILER_ID:Clang>:${CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments>
$<$<CXX_COMPILER_ID:AppleClang>:${CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments>
)
# Disable compiler specific extensions like gnu++11.
set_target_properties(OpenSTA PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(OpenSTA PUBLIC cxx_std_20)
message(STATUS "STA library: ${CMAKE_BINARY_DIR}/libOpenSTA.a")
###########################################################
# Executable
###########################################################
# Note executable and lib name cannot be the same because
# on osx something is case insensitive. Using STA for the
# lib name results in "No rule to make target ../depend.
add_executable(sta app/Main.cc)
target_link_libraries(sta
PRIVATE
sta_swig
OpenSTA
)
message(STATUS "STA executable: ${CMAKE_BINARY_DIR}/sta")
################################################################
# Install
# cmake .. -DCMAKE_INSTALL_PREFIX=<prefix_path>
# executable
install(TARGETS sta DESTINATION bin)
# library
install(TARGETS OpenSTA DESTINATION lib)
# include
install(DIRECTORY include/sta DESTINATION include)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/sta DESTINATION include)
################################################################
add_custom_target(sta_tags
COMMAND etags -o TAGS
${STA_SOURCE}
*/*.hh
include/sta/*.hh
${CMAKE_CURRENT_BINARY_DIR}/include/sta/*.hh
${SWIG_FILES}
${SWIG_FILES}
# Append tcl tags.
# Note that the regexp used for tcl files is broken in etags so provide one that works.
COMMAND etags -a -o TAGS --language=none
--regex='/^[ \\t]*proc[ \\t]+[a-zA-Z0-9_]+/'
${STA_TCL_FILES}
WORKING_DIRECTORY ${STA_HOME}
)
add_custom_command(
TARGET OpenSTA
POST_BUILD
COMMAND ${STA_HOME}/etc/FindMessages.tcl > ${STA_HOME}/doc/messages.txt || true
WORKING_DIRECTORY ${STA_HOME}
)
################################################################
# Tests
################################################################
option(BUILD_TESTS "Build unit tests" ON)
if(BUILD_TESTS)
enable_testing()
find_package(GTest REQUIRED)
include(GoogleTest)
# Helper: register a list of Tcl tests for a module.
# Usage:
# sta_module_tests("search" TESTS timing analysis ...)
function(sta_module_tests module_name)
cmake_parse_arguments(ARG "" "" "TESTS" ${ARGN})
foreach(test_name ${ARG_TESTS})
add_test(
NAME tcl.${module_name}.${test_name}
COMMAND bash ${STA_HOME}/test/regression.sh $<TARGET_FILE:sta> ${module_name}_${test_name}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_tests_properties(tcl.${module_name}.${test_name} PROPERTIES LABELS "tcl;module_${module_name}")
endforeach()
endfunction()
add_subdirectory(test)
# Per-module tests
add_subdirectory(util/test)
add_subdirectory(liberty/test)
add_subdirectory(graph/test)
add_subdirectory(network/test)
add_subdirectory(sdc/test)
add_subdirectory(sdf/test)
add_subdirectory(dcalc/test)
add_subdirectory(search/test)
add_subdirectory(parasitics/test)
add_subdirectory(power/test)
add_subdirectory(verilog/test)
add_subdirectory(spice/test)
endif()