From d3cc60a4abb4e874e7f3f59dbd0fcd315ca0d47a Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 18 Aug 2010 20:34:47 +0000 Subject: [PATCH] * ./vlsisapd/src/bootstrap: - Change: FindLEFDEF moved here from crlcore. - Change: In FindLEFDEF, when LEF/DEF is not found sets the include and library pathes to the empty chain "" instead of NOTFOUND which prevents usage in derived CMakeLists. --- bootstrap/cmake_modules/CMakeLists.txt | 1 + bootstrap/cmake_modules/FindLEFDEF.cmake | 120 +++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 bootstrap/cmake_modules/FindLEFDEF.cmake diff --git a/bootstrap/cmake_modules/CMakeLists.txt b/bootstrap/cmake_modules/CMakeLists.txt index 245e83bb..a9fbadd5 100644 --- a/bootstrap/cmake_modules/CMakeLists.txt +++ b/bootstrap/cmake_modules/CMakeLists.txt @@ -2,6 +2,7 @@ set ( finders FindFLEX.cmake FindBISON.cmake FindPythonSitePackages.cmake + FindLEFDEF.cmake FindBootstrap.cmake ) diff --git a/bootstrap/cmake_modules/FindLEFDEF.cmake b/bootstrap/cmake_modules/FindLEFDEF.cmake new file mode 100644 index 00000000..e4aee2e9 --- /dev/null +++ b/bootstrap/cmake_modules/FindLEFDEF.cmake @@ -0,0 +1,120 @@ +# - Find the LEF/DEF includes and libraries. +# The following variables are set if LEF/DEF is found. If LEF/DEF is not +# found, LEFDEF_FOUND is set to false. +# LEFDEF_FOUND - True when LEF/DEF is found. +# LEFDEF_INCLUDE_DIR - the path to where the LEF/DEF include files are. +# LEFDEF_LIBRARIES - The path to where the LEF/DEF library files are. +# +# The DEF C API library: LEFDEF_CDEF_LIBRARY +# LEFDEF_CDEF_LIBRARY_RELEASE +# LEFDEF_CDEF_LIBRARY_DEBUG +# +# The DEF C API library (zlib) : LEFDEF_ZCDEF_LIBRARY +# LEFDEF_ZCDEF_LIBRARY_RELEASE +# LEFDEF_ZCDEF_LIBRARY_DEBUG +# +# The DEF C++ API library: LEFDEF_DEF_LIBRARY +# LEFDEF_DEF_LIBRARY_RELEASE +# LEFDEF_DEF_LIBRARY_DEBUG +# +# The DEF C++ API library (zlib) : LEFDEF_ZDEF_LIBRARY +# LEFDEF_ZDEF_LIBRARY_RELEASE +# LEFDEF_ZDEF_LIBRARY_DEBUG +# +# The LEF C API library: LEFDEF_CLEF_LIBRARY +# LEFDEF_CLEF_LIBRARY_RELEASE +# LEFDEF_CLEF_LIBRARY_DEBUG +# +# The LEF C API library (zlib) : LEFDEF_ZCLEF_LIBRARY +# LEFDEF_ZCLEF_LIBRARY_RELEASE +# LEFDEF_ZCLEF_LIBRARY_DEBUG +# +# The LEF C++ API library: LEFDEF_LEF_LIBRARY +# LEFDEF_LEF_LIBRARY_RELEASE +# LEFDEF_LEF_LIBRARY_DEBUG +# +# The LEF C++ API library (zlib) : LEFDEF_ZLEF_LIBRARY +# LEFDEF_ZLEF_LIBRARY_RELEASE +# LEFDEF_ZLEF_LIBRARY_DEBUG + + +macro ( _find_lefdef_lib varname libname ) + find_library ( LEFDEF_${varname}_LIBRARY_RELEASE NAMES ${libname} PATHS ${LEFDEF_LIBRARY_DIR} ) + find_library ( LEFDEF_${varname}_LIBRARY_DEBUG NAMES ${libname}_Debug PATHS ${LEFDEF_LIBRARY_DIR} ) + + if ( LEFDEF_${varname}_LIBRARY_RELEASE AND NOT LEFDEF_${varname}_LIBRARY_DEBUG ) + set ( LEFDEF_${varname}_LIBRARY_DEBUG ${LEFDEF_${varname}_LIBRARY_RELEASE} CACHE STRING "Path to a library" FORCE ) + endif ( LEFDEF_${varname}_LIBRARY_RELEASE AND NOT LEFDEF_${varname}_LIBRARY_DEBUG ) + + if ( LEFDEF_${varname}_LIBRARY_DEBUG AND NOT LEFDEF_${varname}_LIBRARY_RELEASE ) + set ( LEFDEF_${varname}_LIBRARY_RELEASE LEFDEF_${varname}_LIBRARY_DEBUG CACHE STRING "Path to a library" FORCE ) + endif ( LEFDEF_${varname}_LIBRARY_DEBUG AND NOT LEFDEF_${varname}_LIBRARY_RELEASE ) + + if ( LEFDEF_${varname}_LIBRARY_RELEASE ) + list ( APPEND LEFDEF_LIBRARIES "optimized" ${LEFDEF_${varname}_LIBRARY_RELEASE} + "debug" ${LEFDEF_${varname}_LIBRARY_DEBUG} ) + set ( LEFDEF_${varname}_LIBRARY_FOUND 1 ) + mark_as_advanced ( LEFDEF_${varname}_LIBRARY_RELEASE + LEFDEF_${varname}_LIBRARY_DEBUG ) + else ( LEFDEF_${varname}_LIBRARY_RELEASE ) + set ( LEFDEF_FOUND "NO" ) + endif ( LEFDEF_${varname}_LIBRARY_RELEASE ) +endmacro ( _find_lefdef_lib ) + + +set ( LEFDEF_INCLUDE_DIR_DESCRIPTION "directory containing the LEF/DEF include files. E.g /opt/lefdef-5.6/include" ) +set ( LEFDEF_LIBRARY_DIR_DESCRIPTION "directory containing the LEF/DEF library files. E.g /opt/lefdef-5.6/lib" ) +set ( LEFDEF_DIR_MESSAGE "Set the LEFDEF_INCLUDE_DIR cmake cache entry to the ${LEFDEF_INCLUDE_DIR_DESCRIPTION}" ) + + +# Don't even bother under Win32 +if ( UNIX ) + set ( LEFDEF_FOUND "YES" ) + set ( LEFDEF_SEARCH_PATH $ENV{LEFDEF_TOP} + "/usr" + "/opt/lefdef-5.6" + "/opt/lefdef-5.7" + "/opt/lefdef") + + set ( LEFDEF_LIBRARIES "" ) + set ( LEFDEF_LIBRARY_SEARCH_PATH "" ) + + find_path ( LEFDEF_INCLUDE_DIR NAMES "defiDefs.h" + PATHS ${LEFDEF_SEARCH_PATH} + PATH_SUFFIXES "include" "include/lefdef" + DOC "The ${LEFDEF_INCLUDE_DIR_DESCRIPTION}" ) + + find_path ( LEFDEF_LIBRARY_DIR NAMES "libdef.a" "libdef_Debug.a" + PATHS ${LEFDEF_LIBRARY_SEARCH_PATH} + PATH_SUFFIXES "lib" + DOC "The ${LEFDEF_LIBRARY_DIR_DESCRIPTION}" ) + + if ( LEFDEF_INCLUDE_DIR AND LEFDEF_LIBRARY_DIR ) + _find_lefdef_lib ( "CDEF" "cdef" ) + _find_lefdef_lib ( "ZCDEF" "cdefzlib" ) + _find_lefdef_lib ( "DEF" "def" ) + _find_lefdef_lib ( "ZDEF" "defzlib" ) + _find_lefdef_lib ( "CLEF" "clef" ) + _find_lefdef_lib ( "ZCLEF" "clefzlib" ) + _find_lefdef_lib ( "LEF" "lef" ) + _find_lefdef_lib ( "ZLEF" "lefzlib" ) + else ( LEFDEF_INCLUDE_DIR AND LEFDEF_LIBRARY_DIR ) + set ( LEFDEF_FOUND "NO" ) + endif ( LEFDEF_INCLUDE_DIR AND LEFDEF_LIBRARY_DIR ) + + if ( LEFDEF_FOUND ) + add_definitions ( -DHAVE_LEFDEF ) + if ( NOT LEFDEF_FIND_QUIETLY ) + message ( STATUS "Found LEF/DEF" ) + endif ( NOT LEFDEF_FIND_QUIETLY ) + else ( LEFDEF_FOUND ) + set ( LEFDEF_LIBRARIES "" ) + set ( LEFDEF_INCLUDE_DIR "" ) + set ( LEFDEF_LIBRARY_DIR "" ) + if ( LEFDEF_FIND_REQUIRED ) + message ( STATUS "LEF/DEF libraries and/or includes NOT found!" ) + endif ( LEFDEF_FIND_REQUIRED ) + endif ( LEFDEF_FOUND ) + + mark_as_advanced ( LEFDEF_INCLUDE_DIR LEFDEF_LIBRARY_DIR LEFDEF_LIBRARIES ) +endif ( UNIX )