[script] reworking cmakefile for swig integration

This commit is contained in:
tangxifan 2022-12-01 12:06:27 -08:00
parent 10d52f1f8b
commit 0574efa9b3
2 changed files with 27 additions and 22 deletions

View File

@ -68,6 +68,7 @@ option(OPENFPGA_WITH_YOSYS "Enable building Yosys" ON)
option(OPENFPGA_WITH_YOSYS_PLUGIN "Enable building Yosys plugin" ON)
option(OPENFPGA_WITH_TEST "Enable testing build for codebase. Once enabled, make test can be run" ON)
option(OPENFPGA_WITH_VERSION "Enable version always-up-to-date when building codebase. Disable only when you do not care an accurate version number" ON)
option(OPENFPGA_WITH_SWIG "Enable SWIG interface when building codebase. Disable when you do not need high-level interfaces, such as Tcl/Python" ON)
# Options pass on to VTR
set(WITH_ABC ON CACHE BOOL "Enable building ABC in Verilog-to-Routing")

View File

@ -10,6 +10,32 @@ files_to_dirs(LIB_HEADERS LIB_INCLUDE_DIRS)
#Remove test executable from library
list(REMOVE_ITEM LIB_SOURCES ${EXEC_SOURCE})
if (OPENFPGA_WITH_SWIG)
#Find SWIG
find_package(SWIG 3.0 REQUIRED)
if (SWIG_VERSION VERSION_GREATER_EQUAL "4.1.0")
message(WARNING "Using SWIG >= ${SWIG_VERSION} -flatstaticmethod flag for python")
endif()
include(UseSWIG)
# SWIG library
swig_lib(NAME openfpga_swig
I_FILE openfpga.i)
target_link_libraries(openfpga_swig
PRIVATE
libarchopenfpga
libopenfpgashell
libopenfpgautil
libfabrickey
libfpgabitstream
libini
libpcf
libvtrutil
libbusgroup
libpugixml
libvpr)
endif()
#Create the library
#Static linked library for other C++ libraries
add_library(libopenfpga STATIC
@ -32,28 +58,6 @@ target_link_libraries(libopenfpga
libpugixml
libvpr)
#Dynamic linked library for high-level interfaces, e.g., Tcl
add_library(libopenfpga_shared SHARED
${LIB_HEADERS}
${LIB_SOURCES})
target_include_directories(libopenfpga_shared PUBLIC ${LIB_INCLUDE_DIRS})
set_target_properties(libopenfpga_shared PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
#Specify link-time dependancies
target_link_libraries(libopenfpga_shared
libarchopenfpga
libopenfpgashell
libopenfpgautil
libfabrickey
libfpgabitstream
libini
libpcf
libvtrutil
libbusgroup
libpugixml
libvpr)
#Create the test executable
add_executable(openfpga ${EXEC_SOURCE})
target_link_libraries(openfpga libopenfpga)