@@ -28,13 +28,16 @@ set(DBSTA_HOME ${PROJECT_SOURCE_DIR}/src/dbSta)
2828set (RESIZER_HOME ${PROJECT_SOURCE_DIR} /src/rsz)
2929set (GUI_HOME ${PROJECT_SOURCE_DIR} /src/gui)
3030
31- set (OPENROAD_SOURCE
31+ set (OPENROAD_LIB_SOURCE
3232 Design.cc
3333 Timing.cc
3434 Tech.cc
3535 OpenRoad.cc
36+ )
37+
38+ set (OPENROAD_SOURCE
3639 Main.cc
37- )
40+ )
3841
3942if (USE_SYSTEM_BOOST)
4043 set (Boost_USE_STATIC_LIBS OFF )
@@ -285,10 +288,18 @@ add_subdirectory(est)
285288
286289################################################################
287290
291+ add_library (openroad_lib
292+ ${OPENROAD_LIB_SOURCE}
293+ )
288294add_executable (openroad
289295 ${OPENROAD_SOURCE}
290296)
291297
298+ target_compile_options (openroad_lib
299+ PRIVATE
300+ -Wextra -pedantic -Wcast-qual
301+ )
302+
292303set_target_properties (openroad PROPERTIES
293304 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin"
294305)
@@ -298,26 +309,34 @@ target_compile_options(openroad
298309 -Wextra -pedantic -Wcast-qual
299310)
300311
312+
301313# Needed for boost stacktrace
302314if (APPLE )
303- target_compile_definitions (openroad PUBLIC "-D_GNU_SOURCE" )
315+ target_compile_definitions (openroad_lib PUBLIC "-D_GNU_SOURCE" )
304316endif ()
305317
306318
319+ set_target_properties (openroad_lib PROPERTIES
320+ # Disable compiler specific extensions like gnu++11.
321+ CXX_EXTENSIONS OFF
322+ # Export symbols for stack trace printing
323+ ENABLE_EXPORTS ON
324+ )
307325set_target_properties (openroad PROPERTIES
308326 # Disable compiler specific extensions like gnu++11.
309327 CXX_EXTENSIONS OFF
310328 # Export symbols for stack trace printing
311329 ENABLE_EXPORTS ON
312330)
313- target_compile_features (openroad PUBLIC cxx_std_17)
331+ target_compile_features (openroad_lib PUBLIC cxx_std_17)
314332
315- target_include_directories (openroad
333+ target_include_directories (openroad_lib
316334 PUBLIC
317335 ../include
318336)
319337
320- target_link_libraries (openroad
338+ target_link_libraries (openroad_lib
339+ PUBLIC
321340 ifp
322341 pad
323342 ord
@@ -357,12 +376,20 @@ target_link_libraries(openroad
357376 ${Boost_LIBRARIES}
358377)
359378
379+ target_link_libraries (openroad
380+ PRIVATE
381+ openroad_lib
382+ cts
383+ ${TCL_LIBRARY}
384+ )
385+
386+ target_compile_definitions (openroad_lib PRIVATE BUILD_TYPE ="${CMAKE_BUILD_TYPE} " )
360387target_compile_definitions (openroad PRIVATE BUILD_TYPE ="${CMAKE_BUILD_TYPE} " )
361388
362389# tclReadline
363390if (TCL_READLINE_LIBRARY AND TCL_READLINE_H)
364391 target_compile_definitions (openroad PRIVATE ENABLE_READLINE)
365- target_link_libraries (openroad ${TCL_READLINE_LIBRARY} )
392+ target_link_libraries (openroad PRIVATE ${TCL_READLINE_LIBRARY} )
366393 target_include_directories (openroad PRIVATE ${TCL_READLINE_H} )
367394 message (STATUS "TCL readline enabled" )
368395else ()
@@ -371,24 +398,25 @@ endif()
371398
372399if (BUILD_TCLX AND TCLX_LIBRARY AND TCLX_H)
373400 target_compile_definitions (openroad PRIVATE ENABLE_TCLX)
374- target_link_libraries (openroad ${TCLX_LIBRARY} )
401+ target_link_libraries (openroad PRIVATE ${TCLX_LIBRARY} )
375402 target_include_directories (openroad PRIVATE ${TCLX_H} )
376403 message (STATUS "Tcl Extended enabled" )
377404else ()
378405 message (STATUS "Tcl Extended disabled" )
379406endif ()
380407
381408if (ZLIB_FOUND)
382- target_link_libraries (openroad ${ZLIB_LIBRARIES} )
409+ target_link_libraries (openroad_lib PUBLIC ${ZLIB_LIBRARIES} )
383410endif ()
384411
385412# Optional CUDD library for OpenSTA
386413if (CUDD_LIB)
387- target_link_libraries (openroad ${CUDD_LIB} )
414+ target_link_libraries (openroad_lib PUBLIC ${CUDD_LIB} )
388415endif ()
389416
390417if (Python3_FOUND AND BUILD_PYTHON)
391418 message (STATUS "Python3 enabled" )
419+ target_compile_definitions (openroad_lib PUBLIC ENABLE_PYTHON3)
392420 target_compile_definitions (openroad PRIVATE ENABLE_PYTHON3)
393421
394422 swig_lib(NAME ord_py
@@ -404,8 +432,9 @@ if (Python3_FOUND AND BUILD_PYTHON)
404432 odb
405433 OpenSTA
406434 ifp
435+ openroad_lib
407436 )
408- target_link_libraries (openroad
437+ target_link_libraries (openroad PRIVATE
409438 ord_py
410439 odb_py
411440 ifp_py
@@ -434,6 +463,13 @@ else()
434463 message (STATUS "Python3 disabled" )
435464endif ()
436465
466+ messages(
467+ TARGET openroad_lib
468+ SOURCE_DIR .
469+ OUTPUT_DIR ..
470+ LOCAL
471+ )
472+
437473messages(
438474 TARGET openroad
439475 SOURCE_DIR .
@@ -447,7 +483,7 @@ messages(
447483if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
448484 AND CMAKE_SYSTEM_NAME STREQUAL "Linux" )
449485 find_library (LIBRT rt)
450- target_link_libraries (openroad ${LIBRT} )
486+ target_link_libraries (openroad_lib PUBLIC ${LIBRT} )
451487endif ()
452488
453489################################################################
@@ -460,6 +496,7 @@ install(TARGETS openroad DESTINATION bin)
460496################################################################
461497
462498add_custom_target (openroad_tags etags -o TAGS
499+ ${OPENROAD_LIB_SOURCE}
463500 ${OPENROAD_SOURCE}
464501 ${OPENROAD_HOME} /include /ord/*.hh
465502 ${OPENROAD_HOME} /src/dbSta/src/*.hh
@@ -468,5 +505,5 @@ add_custom_target(openroad_tags etags -o TAGS
468505 ${RESIZER_HOME} /src/*.hh
469506 ${RESIZER_HOME} /src/*.cc
470507 WORKING_DIRECTORY ${OPENROAD_HOME} /src
471- DEPENDS ${OPENROAD_SOURCE} ${OPENROAD_HEADERS} ${OPENROAD_TCL_FILES}
508+ DEPENDS ${OPENROAD_LIB_SOURCE} ${ OPENROAD_SOURCE} ${OPENROAD_HEADERS} ${OPENROAD_TCL_FILES}
472509)
0 commit comments