diff --git a/CMakeLists.txt b/CMakeLists.txt index 748735ad0..0ece0b4d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/openfpga/CMakeLists.txt b/openfpga/CMakeLists.txt index 81f68a566..ccdb50cd0 100644 --- a/openfpga/CMakeLists.txt +++ b/openfpga/CMakeLists.txt @@ -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)