OpenSTA/CMakeLists.txt

516 lines
13 KiB
CMake
Raw Normal View History

2019-03-29 22:18:08 +01:00
# OpenSTA, Static Timing Analyzer
2020-03-07 03:50:37 +01:00
# Copyright (c) 2020, Parallax Software, Inc.
2019-01-06 01:44:56 +01:00
#
2019-03-29 22:18:08 +01:00
# 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/>.
2019-01-06 01:44:56 +01:00
2020-01-27 19:50:00 +01:00
cmake_minimum_required (VERSION 3.9)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
2020-01-27 19:50:00 +01:00
# Use standard target names
cmake_policy(SET CMP0078 NEW)
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14)
2020-01-27 19:50:00 +01:00
# Allows SWIG_MODULE_NAME to be set
cmake_policy(SET CMP0086 NEW)
2020-01-28 04:45:29 +01:00
endif()
2019-01-01 21:27:23 +01:00
2020-04-12 06:31:48 +02:00
project(STA VERSION 2.1.0
LANGUAGES CXX
)
2019-01-01 21:27:23 +01:00
2020-04-05 00:53:51 +02:00
option(CUDD_DIR "CUDD BDD package directory")
2019-01-01 21:27:23 +01:00
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Disable compiler specific extensions like gnu++11.
2019-01-01 21:27:23 +01:00
set(CMAKE_CXX_EXTENSIONS OFF)
set(STA_HOME ${PROJECT_SOURCE_DIR})
message(STATUS "STA version: ${PROJECT_VERSION}")
2019-07-07 18:58:47 +02:00
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}")
2019-01-01 21:27:23 +01:00
# 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 "STA CXX_FLAGS: ${STA_COMPILE_OPTIONS}")
2019-01-01 21:27:23 +01:00
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
################################################################
#
# Source files.
#
################################################################
set(STA_SOURCE
app/StaMain.cc
2019-01-01 21:27:23 +01:00
dcalc/ArcDelayCalc.cc
dcalc/ArnoldiDelayCalc.cc
dcalc/ArnoldiReduce.cc
dcalc/DcalcAnalysisPt.cc
dcalc/DelayCalc.cc
dcalc/DmpCeff.cc
dcalc/DmpDelayCalc.cc
dcalc/GraphDelayCalc.cc
dcalc/GraphDelayCalc1.cc
dcalc/LumpedCapDelayCalc.cc
dcalc/NetCaps.cc
dcalc/RCDelayCalc.cc
dcalc/SimpleRCDelayCalc.cc
dcalc/UnitDelayCalc.cc
2019-01-01 21:27:23 +01:00
graph/DelayFloat.cc
2019-03-22 00:19:16 +01:00
graph/DelayNormal1.cc
2019-01-01 21:27:23 +01:00
graph/DelayNormal2.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/LibertyExpr.cc
liberty/LibertyExprPvt.hh
liberty/LibertyParser.cc
liberty/LibertyReader.cc
liberty/LinearModel.cc
liberty/Sequential.cc
liberty/TableModel.cc
liberty/TimingArc.cc
liberty/TimingRole.cc
liberty/Transition.cc
liberty/Units.cc
liberty/Wireload.cc
2019-01-01 21:27:23 +01:00
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/NullParasitics.cc
parasitics/Parasitics.cc
parasitics/ReduceParasitics.cc
parasitics/SpefNamespace.cc
parasitics/SpefReader.cc
parasitics/SpefReaderPvt.hh
2019-01-01 21:27:23 +01:00
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/InputDrive.cc
sdc/PinPair.cc
sdc/PortDelay.cc
sdc/PortExtCap.cc
sdc/RiseFallMinMax.cc
sdc/RiseFallValues.cc
sdc/Sdc.cc
sdc/SdcCmdComment.cc
sdc/WriteSdc.cc
sdf/ReportAnnotation.cc
sdf/SdfReader.cc
sdf/SdfWriter.cc
2019-01-01 21:27:23 +01:00
search/Bfs.cc
search/CheckMaxSkews.cc
search/CheckMinPeriods.cc
search/CheckMinPulseWidths.cc
search/CheckSlewLimits.cc
search/CheckTiming.cc
search/ClkInfo.cc
search/ClkSkew.cc
search/Corner.cc
search/Crpr.cc
search/FindRegister.cc
search/GatedClk.cc
search/Genclks.cc
search/Latches.cc
search/Levelize.cc
search/Path.cc
search/PathAnalysisPt.cc
search/PathEnd.cc
search/PathEnum.cc
search/PathEnumed.cc
search/PathExpanded.cc
search/PathGroup.cc
search/PathRef.cc
search/PathVertex.cc
search/PathVertexRep.cc
search/Power.cc
search/Property.cc
search/ReportPath.cc
search/Search.cc
search/SearchPred.cc
search/Sim.cc
search/Sta.cc
search/StaState.cc
search/Tag.cc
search/TagGroup.cc
search/VertexVisitor.cc
search/VisitPathEnds.cc
search/VisitPathGroupVertices.cc
search/WorstSlack.cc
2019-01-04 01:14:15 +01:00
search/WritePathSpice.cc
2019-01-01 21:27:23 +01:00
util/Debug.cc
2019-11-11 16:48:27 +01:00
util/DispatchQueue.cc
2019-01-01 21:27:23 +01:00
util/Error.cc
util/Fuzzy.cc
2019-07-08 20:50:41 +02:00
util/Hash.cc
2019-01-01 21:27:23 +01:00
util/Machine.cc
util/MinMax.cc
util/PatternMatch.cc
util/Report.cc
util/ReportStd.cc
util/ReportTcl.cc
util/Stats.cc
util/StringSeq.cc
util/StringSet.cc
util/StringUtil.cc
util/TokenParser.cc
2019-01-01 21:27:23 +01:00
verilog/VerilogReader.cc
2019-06-17 06:08:00 +02:00
verilog/VerilogWriter.cc
)
2019-01-01 21:27:23 +01:00
# Source files.
set(STA_TCL_FILES
tcl/Util.tcl
tcl/Graph.tcl
tcl/Liberty.tcl
tcl/Link.tcl
tcl/Network.tcl
tcl/NetworkEdit.tcl
tcl/Sdc.tcl
tcl/Search.tcl
tcl/Cmds.tcl
tcl/Variables.tcl
tcl/Sta.tcl
tcl/Power.tcl
tcl/Splash.tcl
dcalc/DelayCalc.tcl
parasitics/Parasitics.tcl
sdf/Sdf.tcl
verilog/Verilog.tcl
)
2019-01-01 21:27:23 +01:00
################################################################
#
# Flex/bison scanner/parsers
#
################################################################
find_package(FLEX)
find_package(BISON)
# LibertyExpr scan/parse.
2020-01-27 21:14:45 +01:00
flex_target(LibertyExprLex ${STA_HOME}/liberty/LibertyExprLex.ll ${CMAKE_CURRENT_BINARY_DIR}/LibertyExprLex.cc
2020-01-25 18:38:03 +01:00
COMPILE_FLAGS --prefix=LibertyExprLex_)
2020-01-27 21:14:45 +01:00
bison_target(LibertyExprParser ${STA_HOME}/liberty/LibertyExprParse.yy ${CMAKE_CURRENT_BINARY_DIR}/LibertyExprParse.cc
COMPILE_FLAGS --name-prefix=LibertyExprParse_
)
add_flex_bison_dependency(LibertyExprLex LibertyExprParser)
# Liberty scan/parse.
2020-01-27 21:14:45 +01:00
flex_target(LibertyLex ${STA_HOME}/liberty/LibertyLex.ll ${CMAKE_CURRENT_BINARY_DIR}/LibertyLex.cc
COMPILE_FLAGS --prefix=LibertyLex_
)
2020-01-27 21:14:45 +01:00
bison_target(LibertyParser ${STA_HOME}/liberty/LibertyParse.yy ${CMAKE_CURRENT_BINARY_DIR}/LibertyParse.cc
COMPILE_FLAGS --name-prefix=LibertyParse_
)
add_flex_bison_dependency(LibertyLex LibertyParser)
# Spef scan/parse.
2020-01-27 21:14:45 +01:00
flex_target(SpefLex ${STA_HOME}/parasitics/SpefLex.ll ${CMAKE_CURRENT_BINARY_DIR}/SpefLex.cc
COMPILE_FLAGS --prefix=SpefLex_
)
2020-01-27 21:14:45 +01:00
bison_target(SpefParser ${STA_HOME}/parasitics/SpefParse.yy ${CMAKE_CURRENT_BINARY_DIR}/SpefParse.cc
COMPILE_FLAGS --name-prefix=SpefParse_
)
add_flex_bison_dependency(SpefLex SpefParser)
# Verilog scan/parse.
2020-01-27 21:14:45 +01:00
flex_target(VerilogLex ${STA_HOME}/verilog/VerilogLex.ll ${CMAKE_CURRENT_BINARY_DIR}/VerilogLex.cc
COMPILE_FLAGS --prefix=VerilogLex_
)
2020-01-27 21:14:45 +01:00
bison_target(VerilogParser ${STA_HOME}/verilog/VerilogParse.yy ${CMAKE_CURRENT_BINARY_DIR}/VerilogParse.cc
COMPILE_FLAGS --name-prefix=VerilogParse_
)
add_flex_bison_dependency(VerilogLex VerilogParser)
# Sdf scan/parse.
2020-01-27 21:14:45 +01:00
flex_target(SdfLex ${STA_HOME}/sdf/SdfLex.ll ${CMAKE_CURRENT_BINARY_DIR}/SdfLex.cc
COMPILE_FLAGS --prefix=SdfLex_
)
2020-01-27 21:14:45 +01:00
bison_target(SdfParser ${STA_HOME}/sdf/SdfParse.yy ${CMAKE_CURRENT_BINARY_DIR}/SdfParse.cc
COMPILE_FLAGS --name-prefix=SdfParse_
)
add_flex_bison_dependency(SdfLex SdfParser)
################################################################
2020-01-25 20:12:00 +01:00
find_package(SWIG REQUIRED 3.0)
2020-01-25 18:38:03 +01:00
include(UseSWIG)
2020-01-25 20:12:00 +01:00
set(STA_SWIG_FILE app/StaApp.i)
2020-01-25 20:12:00 +01:00
set_property(SOURCE ${STA_SWIG_FILE}
PROPERTY CPLUSPLUS ON
)
2020-01-26 00:06:54 +01:00
# Ubuntu 18.04 cmake version 3.10.2 does not support the
# COMPILE_OPTIONS and INCLUDE_DIRECTORIES properties, so cram
2020-01-25 22:20:23 +01:00
# them into SWIG_FLAGS for the time being.
set_property(SOURCE ${STA_SWIG_FILE}
PROPERTY SWIG_FLAGS
-module sta
-namespace -prefix sta
-I${STA_HOME}/tcl
-I${STA_HOME}/sdf
-I${STA_HOME}/dcalc
-I${STA_HOME}/parasitics
-I${STA_HOME}/verilog
2020-01-25 18:38:03 +01:00
)
set_property(SOURCE ${STA_SWIG_FILE}
PROPERTY DEPENDS
${STA_HOME}/tcl/Exception.i
2020-03-09 22:29:48 +01:00
${STA_HOME}/tcl/StaTcl.i
2020-03-09 22:31:55 +01:00
${STA_HOME}/verilog/Verilog.i
${STA_HOME}/tcl/NetworkEdit.i
${STA_HOME}/sdf/Sdf.i
${STA_HOME}/parasitics/Parasitics.i
2020-04-05 20:35:51 +02:00
${STA_HOME}/dcalc/DelayCalc.i
)
2020-01-25 18:38:03 +01:00
swig_add_library(sta_swig
LANGUAGE tcl
TYPE STATIC
SOURCES ${STA_SWIG_FILE}
)
swig_link_libraries(sta_swig
PUBLIC
OpenSTA
)
2020-04-05 20:35:51 +02:00
target_include_directories(sta_swig
PUBLIC
include/sta
PRIVATE
${STA_HOME}
2020-04-07 23:37:52 +02:00
${TCL_INCLUDE_PATH}
2020-04-05 20:35:51 +02:00
)
################################################################
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
)
2019-01-01 21:27:23 +01:00
################################################################
2019-01-06 01:09:27 +01:00
#
2019-01-01 21:27:23 +01:00
# Library dependencies
2019-01-06 01:09:27 +01:00
#
2019-01-01 21:27:23 +01:00
################################################################
2020-01-08 02:08:53 +01:00
# 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.
find_package(TCL)
2019-12-13 06:31:22 +01:00
2019-01-06 01:09:27 +01:00
# Zlib
2019-01-01 21:27:23 +01:00
include(FindZLIB)
2019-01-06 01:09:27 +01:00
################################################################
#
2020-04-03 18:23:27 +02:00
# Locate CUDD bdd package.
#
2020-04-05 00:53:51 +02:00
set(CUDD 0)
2020-04-03 18:23:27 +02:00
find_library(CUDD_LIB
2020-04-05 00:53:51 +02:00
NAME cudd
PATHS ${CUDD_DIR}
PATH_SUFFIXES lib lib/cudd
2020-04-03 18:23:27 +02:00
)
if (CUDD_LIB)
message(STATUS "CUDD library: ${CUDD_LIB}")
get_filename_component(CUDD_LIB_DIR "${CUDD_LIB}" PATH)
get_filename_component(CUDD_LIB_PARENT1 "${CUDD_LIB_DIR}" PATH)
find_file(CUDD_HEADER cudd.h
PATHS ${CUDD_LIB_PARENT1}/include ${CUDD_LIB_PARENT1}/include/cudd)
if (CUDD_HEADER)
get_filename_component(CUDD_INCLUDE "${CUDD_HEADER}" PATH)
message(STATUS "CUDD header: ${CUDD_HEADER}")
# CUDD referenced by StaConfig.hh.cmake
set(CUDD 1)
else()
message(STATUS "CUDD header: not found")
endif()
else()
2019-03-13 01:25:53 +01:00
message(STATUS "CUDD library: not found")
2019-01-01 21:27:23 +01:00
endif()
2019-01-06 01:09:27 +01:00
if("${SSTA}" STREQUAL "")
set(SSTA 0)
endif()
2019-03-13 01:25:53 +01:00
message(STATUS "SSTA: ${SSTA}")
2019-01-06 01:09:27 +01:00
2020-04-05 23:53:44 +02:00
# configure a header file to pass some of the CMake settings
2019-02-16 21:07:59 +01:00
configure_file(${STA_HOME}/util/StaConfig.hh.cmake
2020-04-05 23:53:44 +02:00
${STA_HOME}/include/sta/StaConfig.hh
)
2019-01-01 21:27:23 +01:00
###########################################################
2019-06-05 20:29:28 +02:00
# Library
2019-01-01 21:27:23 +01:00
###########################################################
# compatibility with configure
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${STA_HOME}/app)
add_library(OpenSTA
${STA_SOURCE}
${STA_TCL_INIT}
${FLEX_LibertyExprLex_OUTPUTS}
${BISON_LibertyExprParser_OUTPUTS}
${FLEX_LibertyLex_OUTPUTS}
${BISON_LibertyParser_OUTPUTS}
${FLEX_SpefLex_OUTPUTS}
${BISON_SpefParser_OUTPUTS}
${FLEX_SdfLex_OUTPUTS}
${BISON_SdfParser_OUTPUTS}
${FLEX_VerilogLex_OUTPUTS}
${BISON_VerilogParser_OUTPUTS}
)
2019-01-01 21:27:23 +01:00
2019-12-13 06:31:22 +01:00
target_include_directories(OpenSTA
2020-04-05 00:53:51 +02:00
PUBLIC
2020-04-06 00:56:27 +02:00
include
2020-04-07 05:37:20 +02:00
${TCL_INCLUDE_PATH}
2020-04-05 02:07:43 +02:00
PRIVATE
2020-04-06 00:56:27 +02:00
include/sta
${STA_HOME}
2020-04-07 23:37:52 +02:00
${CUDD_INCLUDE}
2019-12-13 06:31:22 +01:00
)
2019-01-01 21:27:23 +01:00
target_compile_features(OpenSTA
PUBLIC cxx_auto_type
)
2019-01-01 21:27:23 +01:00
2019-05-28 07:46:24 +02:00
target_compile_options(OpenSTA PUBLIC ${STA_COMPILE_OPTIONS})
2019-01-01 21:27:23 +01:00
###########################################################
# Executable
###########################################################
# compatibility with configure
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${STA_HOME}/app)
# 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.
2020-04-07 05:37:20 +02:00
add_executable(sta app/Main.cc)
2020-01-25 18:38:03 +01:00
target_compile_options(sta
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls -Wformat-security>
$<$<CXX_COMPILER_ID:AppleClang>:-Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls -Wformat-security>
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls -Wformat-security>
)
2019-11-17 02:11:25 +01:00
2019-01-01 21:27:23 +01:00
target_link_libraries(sta
OpenSTA
2020-01-25 18:38:03 +01:00
sta_swig
2020-01-08 01:17:19 +01:00
${TCL_LIBRARY}
)
2020-04-12 06:31:48 +02:00
if (ZLIB_LIBRARIES)
target_link_libraries(sta ${ZLIB_LIBRARIES})
endif()
2020-04-05 01:12:41 +02:00
if (CUDD_LIB)
2020-04-12 06:31:48 +02:00
target_link_libraries(sta ${CUDD_LIB})
2020-04-05 01:12:41 +02:00
endif()
2019-01-01 21:27:23 +01:00
message(STATUS "STA executable: ${STA_HOME}/app/sta")
# g++ std::thread apparently still needs -pthreads.
2019-03-13 01:25:53 +01:00
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_libraries(sta -pthread)
endif()
2019-03-27 00:07:32 +01:00
target_compile_options(sta PUBLIC ${STA_COMPILE_OPTIONS})
2019-01-01 21:27:23 +01:00
################################################################
# Install
# cmake .. -DCMAKE_INSTALL_PREFIX=<prefix_path>
# executable
install(TARGETS sta DESTINATION bin)
# library
2019-06-05 20:29:28 +02:00
install(TARGETS OpenSTA DESTINATION lib)
2019-01-01 21:27:23 +01:00
# include
2020-04-06 00:56:27 +02:00
install(DIRECTORY include/sta DESTINATION include)
2019-01-23 05:41:32 +01:00
################################################################
2020-04-06 00:56:27 +02:00
add_custom_target(tags etags -o TAGS ${STA_SOURCE} */*.hh include/sta/*.hh ${SWIG_TCL_FILES}
WORKING_DIRECTORY ${STA_HOME}
)