<commit_before># Copyright (c) 2019, 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/>.


set(OPENSTA_HOME ${PROJECT_SOURCE_DIR}/src/OpenSTA)

set(OPENDB_HOME ${PROJECT_SOURCE_DIR}/src/OpenDB)

set(RESIZER_HOME ${PROJECT_SOURCE_DIR}/src/resizer)
set(OPENDP_HOME ${PROJECT_SOURCE_DIR}/src/opendp)

set(PDNGEN_HOME ${OPENROAD_HOME}/src/pdngen)

set(IOPLACER_HOME ${PROJECT_SOURCE_DIR}/src/ioPlacer)

set(TRITONCTS_HOME ${PROJECT_SOURCE_DIR}/src/TritonCTS) 

set(FASTROUTE_HOME ${PROJECT_SOURCE_DIR}/src/FastRoute)
set(TAPCELL_HOME ${OPENROAD_HOME}/src/tapcell)
set(OPENRCX_HOME ${OPENROAD_HOME}/src/OpenRCX)

set(MPLACE_HOME ${PROJECT_SOURCE_DIR}/src/TritonMacroPlace)

set(OPENROAD_TCL_INIT ${CMAKE_CURRENT_BINARY_DIR}/OpenRoadTclInitVar.cc)

set(OPENROAD_SOURCE
  OpenRoad.cc
  ${OPENROAD_TCL_INIT}
  Main.cc

  dbReadVerilog.cc
  InitFloorplan.cc
  InitFlute.cc
  )

set(OPENROAD_TCL_FILES
  ${OPENSTA_HOME}/tcl/Util.tcl
  OpenRoad.tcl
  dbReadVerilog.tcl
  InitFloorplan.tcl
  )

add_custom_command(OUTPUT ${OPENROAD_TCL_INIT}
  COMMAND ${OPENSTA_HOME}/etc/TclEncode.tcl ${OPENROAD_TCL_INIT} openroad_tcl_inits ${OPENROAD_TCL_FILES}
  WORKING_DIRECTORY ${OPENROAD_HOME}/src
  DEPENDS ${OPENROAD_TCL_FILES} ${OPENSTA_HOME}/etc/TclEncode.tcl
  )

################################################################

find_package(SWIG REQUIRED 3.0)
include(UseSWIG)
set(OPENDB_SWIG_WARNINGS "-w509,503,501,472,467,402,401,317,325,378,383,389,365,362,314,258,240,203,201")

find_package(Boost)

# OpenDB's swig wrapper is not in the library (and mistakenly exports
# to the global namespace) so make our own.
set(OPENDB_SWIG_FILE ${OPENDB_HOME}/src/swig/tcl/opendbtcl.i)

set_property(SOURCE ${OPENDB_SWIG_FILE}
  PROPERTY CPLUSPLUS ON
)
set_property(SOURCE ${OPENDB_SWIG_FILE}
  PROPERTY COMPILE_OPTIONS
  -module opendbtcl
  -namespace -prefix odb
  ${OPENDB_SWIG_WARNINGS}
)
set_property(SOURCE ${OPENDB_SWIG_FILE}
  PROPERTY INCLUDE_DIRECTORIES
  ${OPENDB_HOME}/include/opendb
  ${OPENDB_HOME}/src/swig/tcl
)

swig_add_library(opendb_swig
  LANGUAGE tcl
  TYPE STATIC
  SOURCES ${OPENDB_SWIG_FILE}
)

target_include_directories(opendb_swig
  PUBLIC
  ${Boost_INCLUDE_DIRS}
  ${TCL_INCLUDE_PATH}
)

swig_link_libraries(opendb_swig
  PUBLIC
  opendb
)

################################################################

set(OPENROAD_SWIG_FILE OpenRoad.i)

set_property(SOURCE ${OPENROAD_SWIG_FILE}
  PROPERTY CPLUSPLUS ON
)
set_property(SOURCE ${OPENROAD_SWIG_FILE}
  PROPERTY COMPILE_OPTIONS
  -module openroad
  -namespace -prefix ord
)
set_property(SOURCE ${OPENROAD_SWIG_FILE}
  PROPERTY INCLUDE_DIRECTORIES
  ${OPENROAD_HOME}/src
  ${OPENDB_HOME}/include
)
set_property(SOURCE ${OPENROAD_SWIG_FILE}
  PROPERTY GENERATED_INCLUDE_DIRECTORIES
  ${OPENROAD_HOME}/src
  ${OPENROAD_HOME}/include

  ${OPENSTA_HOME}/util
  ${OPENSTA_HOME}/sdc
  ${OPENSTA_HOME}/network
  ${OPENSTA_HOME}/parasitics
  ${OPENSTA_HOME}/liberty
  ${OPENSTA_HOME}/graph
  ${OPENSTA_HOME}/search

  ${OPENDB_HOME}/include

  ${TCL_INCLUDE_PATH}
)

swig_add_library(openroad_swig
  LANGUAGE tcl
  TYPE STATIC
  SOURCES ${OPENROAD_SWIG_FILE}
)

swig_link_libraries(openroad_swig
  PUBLIC
  openroad
  # OpenDB public includes incorrectly point to include/opendb so this fails.
  #opendb
)

################################################################
#
# 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.
find_package(TCL)

# Zlib
include(FindZLIB)
# Translate cmake bool to StaConfig.h ifdef bool
if (ZLIB_FOUND)
  set(ZLIB 1)
else()
  set(ZLIB 0)
endif()

################################################################

# Disable OpenDB stand-alone executable builds.<commit_msg>ubuntu compatibility<commit_after># Copyright (c) 2019, 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/>.


set(OPENSTA_HOME ${PROJECT_SOURCE_DIR}/src/OpenSTA)

set(OPENDB_HOME ${PROJECT_SOURCE_DIR}/src/OpenDB)

set(RESIZER_HOME ${PROJECT_SOURCE_DIR}/src/resizer)
set(OPENDP_HOME ${PROJECT_SOURCE_DIR}/src/opendp)

set(PDNGEN_HOME ${OPENROAD_HOME}/src/pdngen)

set(IOPLACER_HOME ${PROJECT_SOURCE_DIR}/src/ioPlacer)

set(TRITONCTS_HOME ${PROJECT_SOURCE_DIR}/src/TritonCTS) 

set(FASTROUTE_HOME ${PROJECT_SOURCE_DIR}/src/FastRoute)
set(TAPCELL_HOME ${OPENROAD_HOME}/src/tapcell)
set(OPENRCX_HOME ${OPENROAD_HOME}/src/OpenRCX)

set(MPLACE_HOME ${PROJECT_SOURCE_DIR}/src/TritonMacroPlace)

set(OPENROAD_TCL_INIT ${CMAKE_CURRENT_BINARY_DIR}/OpenRoadTclInitVar.cc)

set(OPENROAD_SOURCE
  OpenRoad.cc
  ${OPENROAD_TCL_INIT}
  Main.cc

  dbReadVerilog.cc
  InitFloorplan.cc
  InitFlute.cc
  )

set(OPENROAD_TCL_FILES
  ${OPENSTA_HOME}/tcl/Util.tcl
  OpenRoad.tcl
  dbReadVerilog.tcl
  InitFloorplan.tcl
  )

add_custom_command(OUTPUT ${OPENROAD_TCL_INIT}
  COMMAND ${OPENSTA_HOME}/etc/TclEncode.tcl ${OPENROAD_TCL_INIT} openroad_tcl_inits ${OPENROAD_TCL_FILES}
  WORKING_DIRECTORY ${OPENROAD_HOME}/src
  DEPENDS ${OPENROAD_TCL_FILES} ${OPENSTA_HOME}/etc/TclEncode.tcl
  )

################################################################

find_package(SWIG REQUIRED 3.0)
include(UseSWIG)
set(OPENDB_SWIG_WARNINGS "-w509,503,501,472,467,402,401,317,325,378,383,389,365,362,314,258,240,203,201")

find_package(Boost)

# OpenDB's swig wrapper is not in the library (and mistakenly exports
# to the global namespace) so make our own.
set(OPENDB_SWIG_FILE ${OPENDB_HOME}/src/swig/tcl/opendbtcl.i)

set_property(SOURCE ${OPENDB_SWIG_FILE}
  PROPERTY CPLUSPLUS ON
)
# Ubuntu 18.04 cmake version 3.10.2 does not support the
# COMPILE_OPTIONS and INCLUDE_DIRECTORIES properties, so cram
# them into SWIG_FLAGS for the time being.
set_property(SOURCE ${OPENDB_SWIG_FILE}
  PROPERTY SWIG_FLAGS
  -module opendbtcl
  -namespace -prefix odb
  ${OPENDB_SWIG_WARNINGS}
  -I${OPENDB_HOME}/include/opendb
  -I${OPENDB_HOME}/src/swig/tcl
)

swig_add_library(opendb_swig
  LANGUAGE tcl
  TYPE STATIC
  SOURCES ${OPENDB_SWIG_FILE}
)

target_include_directories(opendb_swig
  PUBLIC
  ${Boost_INCLUDE_DIRS}
  ${TCL_INCLUDE_PATH}
)

swig_link_libraries(opendb_swig
  PUBLIC
  opendb
)

################################################################

set(OPENROAD_SWIG_FILE OpenRoad.i)

set_property(SOURCE ${OPENROAD_SWIG_FILE}
  PROPERTY CPLUSPLUS ON
)
# Ubuntu 18.04 cmake version 3.10.2 does not support the
# COMPILE_OPTIONS and INCLUDE_DIRECTORIES properties, so cram
# them into SWIG_FLAGS for the time being.
set_property(SOURCE ${OPENROAD_SWIG_FILE}
  PROPERTY SWIG_FLAGS
  -module openroad
  -namespace -prefix ord
  -I${OPENROAD_HOME}/src
  -I${OPENDB_HOME}/include
)
set_property(SOURCE ${OPENROAD_SWIG_FILE}
  PROPERTY GENERATED_INCLUDE_DIRECTORIES
  ${OPENROAD_HOME}/src
  ${OPENROAD_HOME}/include

  ${OPENSTA_HOME}/util
  ${OPENSTA_HOME}/sdc
  ${OPENSTA_HOME}/network
  ${OPENSTA_HOME}/parasitics
  ${OPENSTA_HOME}/liberty
  ${OPENSTA_HOME}/graph
  ${OPENSTA_HOME}/search

  ${OPENDB_HOME}/include

  ${TCL_INCLUDE_PATH}
)

swig_add_library(openroad_swig
  LANGUAGE tcl
  TYPE STATIC
  SOURCES ${OPENROAD_SWIG_FILE}
)

swig_link_libraries(openroad_swig
  PUBLIC
  openroad
  # OpenDB public includes incorrectly point to include/opendb so this fails.
  #opendb
)

################################################################
#
# Library dependencies
#
################################################################

# Zlib
include(FindZLIB)
# Translate cmake bool to StaConfig.h ifdef bool
if (ZLIB_FOUND)
  set(ZLIB 1)
else()
  set(ZLIB 0)
endif()

################################################################

# Disable OpenDB stand-alone executable builds.
{'fraction_non_alphanumeric': 0.15643434564124972, 'fraction_numerical': 0.016167795499235308, 'mean_word_length': 5.9938884644767, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4581838', 'n_tokens_mistral': 3485, 'n_tokens_neox': 3254, 'n_words': 693}