UseSWIG cmake support for swig

This commit is contained in:
James Cherry 2020-01-25 10:38:03 -07:00
parent f7171d9bf4
commit 1068813b59
7 changed files with 84 additions and 38 deletions

View File

@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required (VERSION 3.9)
cmake_minimum_required (VERSION 3.9...3.16)
project(STA VERSION 2.0.17)
project(STA VERSION 2.0.18)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 11)
@ -37,16 +37,6 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE)
endif()
# Compiler specific options.
# Note -Wno-deprecated-register is to suppress bison errors.
if (CMAKE_CXX_COMPILER_ID MATCHES AppleClang|Clang)
set(STA_COMPILE_OPTIONS -Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls -Wformat-security -Wno-deprecated-register)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(STA_COMPILE_OPTIONS -Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls -Wformat-security)
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}")
@ -385,6 +375,20 @@ set(STA_HEADERS
verilog/VerilogWriter.hh
)
set(STA_INCLUDE_DIRS
app
dcalc
graph
liberty
network
parasitics
sdc
sdf
search
util
verilog
)
# Source files.
set(STA_TCL_FILES
tcl/Util.tcl
@ -406,17 +410,6 @@ set(STA_TCL_FILES
verilog/Verilog.tcl
)
set(STA_SWIG_FILES
tcl/NetworkEdit.i
tcl/StaException.i
sdf/Sdf.i
dcalc/DelayCalc.i
parasitics/Parasitics.i
verilog/Verilog.i
tcl/StaTcl.i
app/StaApp.i
)
################################################################
#
# Flex/bison scanner/parsers
@ -428,8 +421,7 @@ find_package(BISON)
# LibertyExpr scan/parse.
flex_target(LibertyExprLex liberty/LibertyExprLex.ll ${CMAKE_CURRENT_BINARY_DIR}/LibertyExprLex.cc
COMPILE_FLAGS --prefix=LibertyExprLex_
)
COMPILE_FLAGS --prefix=LibertyExprLex_)
bison_target(LibertyExprParser liberty/LibertyExprParse.yy ${CMAKE_CURRENT_BINARY_DIR}/LibertyExprParse.cc
COMPILE_FLAGS --name-prefix=LibertyExprParse_
)
@ -474,21 +466,38 @@ add_flex_bison_dependency(SdfLex SdfParser)
################################################################
set(SWIG_REQUIRED_VERSION "2.0")
# all hell breaks loose with cmake 3.16.2
#cmake_policy(SET CMP<0078> NEW)
#set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
find_package(SWIG REQUIRED)
if(${SWIG_VERSION} VERSION_LESS ${SWIG_REQUIRED_VERSION})
message(FATAL_ERROR "SWIG version ${SWIG_VERSION} must be at least ${SWIG_REQUIRED_VERSION}")
endif()
include(UseSWIG)
set(STA_WRAP ${CMAKE_CURRENT_BINARY_DIR}/StaApp_wrap.cc)
add_custom_command(OUTPUT ${STA_WRAP}
COMMAND ${SWIG_EXECUTABLE} -tcl8 -c++ -namespace -prefix sta -I${STA_HOME}/tcl -I${STA_HOME}/sdf -I${STA_HOME}/dcalc -I${STA_HOME}/parasitics -I${STA_HOME}/verilog -o ${STA_WRAP} ${STA_HOME}/app/StaApp.i
COMMAND ${STA_HOME}/etc/SwigCleanup.tcl ${STA_WRAP}
WORKING_DIRECTORY ${STA_HOME}
DEPENDS ${STA_SWIG_FILES}
set(STA_SWIG_FILE
app/StaApp.i
)
set_source_files_properties(${STA_SWIG_FILE}
PROPERTIES CPLUSPLUS ON
)
set(CMAKE_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
)
swig_add_library(sta_swig
LANGUAGE tcl
TYPE STATIC
SOURCES ${STA_SWIG_FILE}
)
swig_link_libraries(sta_swig
PUBLIC
OpenSTA
)
################################################################
set(STA_TCL_INIT ${CMAKE_CURRENT_BINARY_DIR}/StaTclInitVar.cc)
@ -602,7 +611,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${STA_HOME}/app)
add_library(OpenSTA
${STA_SOURCE}
${STA_WRAP}
${STA_TCL_INIT}
${FLEX_LibertyExprLex_OUTPUTS}
@ -641,10 +649,18 @@ 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.
add_executable(sta app/Main.cc ${STA_WRAP})
add_executable(sta app/Main)
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>
)
target_link_libraries(sta
OpenSTA
sta_swig
${TCL_LIBRARY}
${CUDD_LIB}
)

View File

@ -19,6 +19,7 @@
// Liberty function expression lexical analyzer
#include "Machine.hh"
#include "FlexPragma.hh"
#include "Debug.hh"
#include "StringUtil.hh"
#include "LibertyExprPvt.hh"

View File

@ -15,6 +15,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Machine.hh"
#include "FlexPragma.hh"
#include <ctype.h>
#include <string.h>
#include "Machine.hh"

View File

@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Machine.hh"
#include "FlexPragma.hh"
#include <string.h>
#include <string>
#include "Machine.hh"

View File

@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Machine.hh"
#include "FlexPragma.hh"
#include "Sdf.hh"
#include "SdfParse.hh"

23
util/FlexPragma.hh Normal file
View File

@ -0,0 +1,23 @@
#define DIAG_STR(s) #s
#define DIAG_JOINSTR(x,y) DIAG_STR(x ## y)
#ifdef _MSC_VER
#define DIAG_DO_PRAGMA(x) __pragma (#x)
#define DIAG_PRAGMA(compiler,x) DIAG_DO_PRAGMA(warning(x))
#else
#define DIAG_DO_PRAGMA(x) _Pragma (#x)
#define DIAG_PRAGMA(compiler,x) DIAG_DO_PRAGMA(compiler diagnostic x)
#endif
#if defined(__clang__)
# define DISABLE_WARNING(gcc_unused,clang_option,msvc_unused) DIAG_PRAGMA(clang,push) DIAG_PRAGMA(clang,ignored DIAG_JOINSTR(-W,clang_option))
#elif defined(_MSC_VER)
# define DISABLE_WARNING(gcc_unused,clang_unused,msvc_errorcode) DIAG_PRAGMA(msvc,push) DIAG_DO_PRAGMA(warning(disable:##msvc_errorcode))
#elif defined(__GNUC__)
#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
# define DISABLE_WARNING(gcc_option,clang_unused,msvc_unused) DIAG_PRAGMA(GCC,push) DIAG_PRAGMA(GCC,ignored DIAG_JOINSTR(-W,gcc_option))
#else
# define DISABLE_WARNING(gcc_option,clang_unused,msvc_unused) DIAG_PRAGMA(GCC,ignored DIAG_JOINSTR(-W,gcc_option))
#endif
#endif
DISABLE_WARNING(deprecated-register,deprecated-register,00)

View File

@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Machine.hh"
#include "FlexPragma.hh"
#include "Debug.hh"
#include "VerilogNamespace.hh"
#include "VerilogReaderPvt.hh"