From: <dg...@su...> - 2009-01-09 10:48:31
|
Author: henrik Date: Fri Jan 9 11:47:55 2009 New Revision: 5061 URL: http://www.opensync.org/changeset/5061 Log: Look for Thunderbird and Sunbird files in usual paths. Useful if Thunderbird/Sunbird was not installed from packages Modified: branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Modified: branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake ============================================================================== --- branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Fri Jan 9 11:36:29 2009 (r5060) +++ branches/3rd-party-cmake-modules/modules/FindThunderbirdXpcom.cmake Fri Jan 9 11:47:55 2009 (r5061) @@ -4,166 +4,167 @@ # $Id$ # ====================================================== -# ---------- First we look for thunderbird -PKG_SEARCH_MODULE(THUNDERBIRDXPCOM REQUIRED thunderbird-xpcom icedove-xpcom ) - -# ---------- If we found thunderbird all is fine, set the required directories -IF( THUNDERBIRDXPCOM_FOUND ) - - MESSAGE( STATUS "THUNDERBIRDXPCOM_INCLUDE_DIRS ${THUNDERBIRDXPCOM_INCLUDE_DIRS}" ) - - MESSAGE( STATUS "-- Found thunderbird-xpcom" ) - #If we found the thunderbird package, look for one of the includes, just to be sure - FIND_PATH(_LIBTBXPCOM_INCLUDE_DIR mozilla-config.h - PATHS ${THUNDERBIRDXPCOM_INCLUDE_DIRS} ) - IF( NOT _LIBTBXPCOM_INCLUDE_DIR ) - MESSAGE( FATAL_ERROR "Found thunderbird-xpcom, but not mozilla-config.h" ) - ENDIF ( NOT _LIBTBXPCOM_INCLUDE_DIR ) - - SET( XPCOM_INCLUDE_DIRS - ${_LIBTBXPCOM_INCLUDE_DIR} - ${_LIBTBXPCOM_INCLUDE_DIR}/xpcom - ${_LIBTBXPCOM_INCLUDE_DIR}/nspr - ${_LIBTBXPCOM_INCLUDE_DIR}/necko - ${_LIBTBXPCOM_INCLUDE_DIR}/rdf - ${_LIBTBXPCOM_INCLUDE_DIR}/string - ${_LIBTBXPCOM_INCLUDE_DIR}/addrbook - ${_LIBTBXPCOM_INCLUDE_DIR}/js - ${_LIBTBXPCOM_INCLUDE_DIR}/xpcom_obsolete - ${_LIBTBXPCOM_INCLUDE_DIR}/xulapp - ${_LIBTBXPCOM_INCLUDE_DIR}/extensions - ${THUNDERBIRDXPCOM_INCLUDE_DIRS} +# The purpose of this CMake file is to find Thunderbird and Sunbird files. +# At the end, we whould have the following variables set: +# XPCOM_INCLUDE_DIRS +# XPCOM_LIBRARY_DIRS +# XPCOM_LIBRARIES +# SUNBIRD_VERSION + +# First we look for a Thunderbird package +PKG_SEARCH_MODULE ( THUNDERBIRD_XPCOM thunderbird-xpcom icedove-xpcom ) + +IF ( THUNDERBIRD_XPCOM_FOUND ) + + # If we found the Thunderbird package, look for one of the includes, just to be sure + FIND_PATH ( THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR mozilla-config.h + PATHS ${THUNDERBIRD_XPCOM_INCLUDE_DIRS} ) + IF( NOT THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR ) + MESSAGE ( FATAL_ERROR "*** *** Found Thunderbird package, but not mozilla-config.h" ) + ENDIF ( NOT THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR ) + # We also need NSPR, so let's make sure it is there + FIND_PATH ( NSPR_MAIN_INCLUDE_DIR nspr.h + PATHS ${THUNDERBIRD_XPCOM_INCLUDE_DIRS} ) + IF( NOT NSPR_MAIN_INCLUDE_DIR ) + MESSAGE ( FATAL_ERROR "*** *** Found Thunderbird package, but not nspr.h" ) + ENDIF ( NOT NSPR_MAIN_INCLUDE_DIR ) + +ELSE( THUNDERBIRD_XPCOM_FOUND ) + + # We did not find a Thunderbird package, so let us look for the files manually + MESSAGE ( STATUS " did not find thunderbird package; now looking for thunderbird files" ) + FIND_PATH (THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR mozilla-config.h + PATH_SUFFIXES thunderbird icedove + PATHS + /opt/local/include/ + /sw/include/ + /usr/local/include/ + /usr/include/ ) - # xpcom_obsolete is needed because nsIABDirectory pulls in nsFileSpec.h - # However, in thunderbird-addressbook.cpp we define _FILESPEC_H_ - # so we avoid any dependencies on obsolete - # Hope mozilla gets this fixed ASAP. - - SET( _LIBDIRS ${THUNDERBIRDXPCOM_LIBRARY_DIRS} ) - -# ---------- If we did *NOT* find thunderbird, we must look for xulrunner and nspr (for openSUSE) -ELSE( THUNDERBIRDXPCOM_FOUND ) - - # If we did not find thunderbird package, let's try xulrunner. - # This is needed on OpenSUSE, where there is no thunderbird-devel package - PKGCONFIG( xulrunner-xpcom - _LIBXULRUNNERIncDir _LIBXULRUNNERLinkDir _LIBXULRUNNERLinkFlags _LIBXULRUNNERCflags ) - IF( NOT _LIBXULRUNNERIncDir ) - MESSAGE( FATAL_ERROR "Did not find thunderbird-xpcom, nor xulrunner-xpcom" ) - ENDIF( NOT _LIBXULRUNNERIncDir ) - - FIND_PATH( _LIBXULRUNNER_INCLUDE_DIR nsXPCOM.h - PATHS ${_LIBXULRUNNERIncDir} ) - IF( NOT _LIBXULRUNNER_INCLUDE_DIR ) - MESSAGE( FATAL_ERROR "Found xulrunner-xpcom, but not nsXPCOM.h" ) - ENDIF( NOT _LIBXULRUNNER_INCLUDE_DIR ) - - # xulrunner-xpcom also needs nspr - PKGCONFIG( nspr - _LIBSNPRIncDir _LIBSNPRLinkDir _LIBSNPRLinkFlags _LIBSNPRCflags ) - IF( NOT _LIBSNPRIncDir ) - MESSAGE( FATAL_ERROR "Found xulrunner-xpcom, but not nspr" ) - ENDIF( NOT _LIBSNPRIncDir ) - - FIND_PATH( _LIBSNPR_INCLUDE_DIR prtypes.h - PATHS ${_LIBSNPRIncDir} ) - IF( NOT _LIBSNPR_INCLUDE_DIR ) - MESSAGE( FATAL_ERROR "Found nspr, but not prtypes.h" ) - ENDIF( NOT _LIBSNPR_INCLUDE_DIR ) - - FIND_PATH( _TB_AB_INCLUDE_DIR nsIAbDirectory.h - PATHS "/usr/src/debug/mozilla/dist/include/addrbook" ) - IF( NOT _TB_AB_INCLUDE_DIR ) - MESSAGE( FATAL_ERROR "Found xulrunner-xpcom and nspr, but not the thunderbird headers" ) - ENDIF( NOT _TB_AB_INCLUDE_DIR ) - - SET( XPCOM_INCLUDE_DIRS - ${_LIBXULRUNNER_INCLUDE_DIR} - ${_LIBXULRUNNER_INCLUDE_DIR}/xpcom - ${_LIBSNPR_INCLUDE_DIR} - ${_LIBXULRUNNER_INCLUDE_DIR}/rdf - ${_LIBXULRUNNER_INCLUDE_DIR}/string - ${_TB_AB_INCLUDE_DIR} - ${_LIBXULRUNNER_INCLUDE_DIR}/xpcom_obsolete + IF ( NOT THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR ) + MESSAGE ( FATAL_ERROR "*** *** Did not find Thunderbird include directory with mozilla-config.h" ) + ENDIF ( NOT THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR ) + FIND_PATH ( NSPR_MAIN_INCLUDE_DIR nspr.h + PATH_SUFFIXES nspr nspr4 + PATHS + /opt/local/include/ + /sw/include/ + /usr/local/include/ + /usr/include/ ) - - SET( _LIBDIRS ${THUNDERBIRDXPCOM_LIBRARY_DIRS} ) - -ENDIF( THUNDERBIRDXPCOM_FOUND ) - -#SET( EXTRA_INC_PATHS "/usr/src/debug/mozilla/dist/include/xpcom" PATH ) - -MESSAGE( STATUS "XPCOM_INCLUDE_DIRS ${XPCOM_INCLUDE_DIRS}" ) - -FIND_PATH(THUNDERBIRD_EXTENSION_DIR extensions - PATHS ${_LIBDIRS} ) - -MESSAGE( STATUS "THUNDERBIRD_EXTENSION_DIR ${THUNDERBIRD_EXTENSION_DIR}" ) - -# ---------- Find the xpcom library, and make sure it is not under xulrunner -FIND_LIBRARY( LIBTBXPCOM_XPCOM - NAMES xpcom - PATHS ${_LIBDIRS} ENV LD_LIBRARY_PATH ) -IF( NOT LIBTBXPCOM_XPCOM ) - MESSAGE( FATAL_ERROR "Could not find xpcom library" ) -ENDIF( NOT LIBTBXPCOM_XPCOM ) - -STRING(REGEX MATCH ".*xulrunner.*" _XULRUNNER ${LIBTBXPCOM_XPCOM}) -IF( _XULRUNNER ) - MESSAGE( FATAL_ERROR - "Found xpcom library under xulrunner; should have been under thunderbird. Check LD_LIBRARY_PATH" ) -ENDIF( _XULRUNNER ) - - -# ---------- GRE_DIR needed just to put it into the test scripts -GET_FILENAME_COMPONENT(GRE_DIR ${LIBTBXPCOM_XPCOM} PATH) -MESSAGE( STATUS "GRE_DIR ${GRE_DIR}" ) - - -# ---------- Ensure we found NSPR library -FIND_LIBRARY( LIBTBXPCOM_NSPR4 - NAMES nspr4 - PATHS ${_LIBDIRS} ENV LD_LIBRARY_PATH ) -IF( NOT LIBTBXPCOM_NSPR4 ) - MESSAGE( FATAL_ERROR "Could not find nspr library" ) -ENDIF( NOT LIBTBXPCOM_NSPR4 ) - - - -# ---------- Find sunbird include directory - -PKG_SEARCH_MODULE( SUNBIRD REQUIRED sunbird-xpcom iceowl-xpcom ) - -IF( SUNBIRD_FOUND ) - MESSAGE( "-- Found sunbird" ) - MESSAGE( "SUNBIRD_INCLUDE_DIRS ${SUNBIRD_INCLUDE_DIRS}" ) - + IF( NOT NSPR_MAIN_INCLUDE_DIR ) + MESSAGE ( FATAL_ERROR "*** *** Found Thunderbird include directory, but not nspr.h" ) + ENDIF ( NOT NSPR_MAIN_INCLUDE_DIR ) + # Usually all the libraries are in one directory, so let us try to find it + FIND_LIBRARY ( _xpcom_lib NAMES xpcom libxpcom + PATH_SUFFIXES thunderbird icedove + PATHS + /opt/local/lib + /sw/lib + /usr/lib + /usr/local/lib + /usr/lib64 + /usr/local/lib64 + /opt/lib64 + ) + IF ( NOT _xpcom_lib ) + MESSAGE ( FATAL_ERROR "*** *** Found Thunderbird, but not the xpcom library" ) + ENDIF ( NOT _xpcom_lib ) + # We got the actual library, but we need the directory + GET_FILENAME_COMPONENT ( THUNDERBIRD_XPCOM_LIBRARY_DIRS "${_xpcom_lib}" PATH ) + # Usually the only library we need is the xpcom + SET ( THUNDERBIRD_XPCOM_LIBRARIES "xpcom" ) + +ENDIF( THUNDERBIRD_XPCOM_FOUND ) + +# So, by now we should have the following variables set: +MESSAGE ( STATUS " THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR ${THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR}" ) +MESSAGE ( STATUS " NSPR_MAIN_INCLUDE_DIR ${NSPR_MAIN_INCLUDE_DIR}" ) +MESSAGE ( STATUS " THUNDERBIRD_XPCOM_LIBRARY_DIRS ${THUNDERBIRD_XPCOM_LIBRARY_DIRS}" ) +MESSAGE ( STATUS " THUNDERBIRD_XPCOM_LIBRARIES ${THUNDERBIRD_XPCOM_LIBRARIES}" ) + +# Those are the include directories we actually need +SET ( XPCOM_INCLUDE_DIRS + ${NSPR_MAIN_INCLUDE_DIR} + ${THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR} + ${THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR}/addrbook + ${THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR}/extensions + ${THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR}/rdf + ${THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR}/string + ${THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR}/xpcom_obsolete + ${THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR}/xpcom + ${THUNDERBIRD_XPCOM_MAIN_INCLUDE_DIR}/xulapp +) + + +# Now look for a Subird package +PKG_SEARCH_MODULE ( SUNBIRD sunbird-xpcom iceowl-xpcom ) + +IF ( SUNBIRD_FOUND ) + # If we found the Thunderbird package, let us try to find the main include dir + MESSAGE ( " SUNBIRD_INCLUDE_DIRS ${SUNBIRD_INCLUDE_DIRS}" ) # ---------- We just need the first directory, which should be the main directory # The rest will point to xpcom and friends; and we do not want that. # But, let's also handle the special case of only one direcory reported, just in case - - STRING(REGEX MATCH ";" _SEVERAL_INCLUDE_DIRS "${SUNBIRD_INCLUDE_DIRS}" ) - IF( _SEVERAL_INCLUDE_DIRS ) - MESSAGE( "SEVERAL") - STRING(REGEX REPLACE "([^;]*);.*" "\\1" SUNBIRD_MAIN_INCLUDE_DIR "${SUNBIRD_INCLUDE_DIRS}" ) - ELSE( _SEVERAL_INCLUDE_DIRS ) - SET( SUNBIRD_MAIN_INCLUDE_DIR "${SUNBIRD_INCLUDE_DIRS}" ) - ENDIF( _SEVERAL_INCLUDE_DIRS ) - #MESSAGE( "SUNBIRD_MAIN_INCLUDE_DIR ${SUNBIRD_MAIN_INCLUDE_DIR}" ) - - FIND_FILE(_SUNBIRD_CALENDAR calbase/calICalendar.h ${SUNBIRD_MAIN_INCLUDE_DIR} ) - IF( NOT _SUNBIRD_CALENDAR ) - MESSAGE( FATAL_ERROR "Found sunbird, but not calICalendar.h" ) - ENDIF ( NOT _SUNBIRD_CALENDAR ) - - - SET ( XPCOM_INCLUDE_DIRS "${XPCOM_INCLUDE_DIRS};${SUNBIRD_MAIN_INCLUDE_DIR}" ) - MESSAGE( "XPCOM_INCLUDE_DIRS ${XPCOM_INCLUDE_DIRS}" ) + STRING ( REGEX MATCH ";" _SEVERAL_INCLUDE_DIRS "${SUNBIRD_INCLUDE_DIRS}" ) + IF ( _SEVERAL_INCLUDE_DIRS ) + MESSAGE ( "SEVERAL") + STRING ( REGEX REPLACE "([^;]*);.*" "\\1" SUNBIRD_MAIN_INCLUDE_DIR "${SUNBIRD_INCLUDE_DIRS}" ) + ELSE ( _SEVERAL_INCLUDE_DIRS ) + SET ( SUNBIRD_MAIN_INCLUDE_DIR "${SUNBIRD_INCLUDE_DIRS}" ) + ENDIF ( _SEVERAL_INCLUDE_DIRS ) ELSE( SUNBIRD_FOUND ) - MESSAGE( FATAL_ERROR "Could not find sunbird library" ) -ENDIF( SUNBIRD_FOUND ) - -MESSAGE ( STATUS "SUNBIRD_VERSION [${SUNBIRD_VERSION}]" ) - -MARK_AS_ADVANCED( THUNDERBIRDXPCOM_INCLUDE_DIRS THUNDERBIRDXPCOM_LIBRARIES ) + # We did not find a Sunbird package, so let us look for the files manually + MESSAGE ( STATUS " did not find sunbird package; now looking for sunbird files" ) + FIND_PATH ( SUNBIRD_MAIN_INCLUDE_DIR calbase/calIICSService.h + PATH_SUFFIXES sunbird iceowl + PATHS + /opt/local/include/ + /sw/include/ + /usr/local/include/ + /usr/include/ + ) + IF ( NOT SUNBIRD_MAIN_INCLUDE_DIR ) + MESSAGE ( FATAL_ERROR "*** *** Did not find Sunbird include directory with mozilla-config.h" ) + ENDIF ( NOT SUNBIRD_MAIN_INCLUDE_DIR ) + + # We need the Sunbird version number + EXEC_PROGRAM ( sunbird ARGS "--version" + OUTPUT_VARIABLE _SUNBIRD_VERSION + RETURN_VALUE _SUNBIRD_VERSION_RET ) + IF ( _SUNBIRD_VERSION_RET ) + + EXEC_PROGRAM ( iceowl ARGS "--version" + OUTPUT_VARIABLE _SUNBIRD_VERSION + RETURN_VALUE _ICEOWL_VERSION_RET ) + IF ( _ICEOWL_VERSION_RET ) + MESSAGE ( FATAL_ERROR "*** *** Unable execute sunbird/iceowl to get its version" ) + ENDIF ( _ICEOWL_VERSION_RET ) + ENDIF ( _SUNBIRD_VERSION_RET ) + + STRING ( REGEX MATCH ".*([0-9]\\.[0-9]).*" _SUNBIRD_VERSION_OK "${_SUNBIRD_VERSION}" ) + IF ( _SUNBIRD_VERSION_OK ) + STRING ( REGEX REPLACE ".*([0-9]\\.[0-9]).*" "\\1" SUNBIRD_VERSION "${_SUNBIRD_VERSION}" ) + ELSE ( _SUNBIRD_VERSION_OK ) + MESSAGE ( STATUS "sunbird --version returned ${_SUNBIRD_VERSION}" ) + MESSAGE ( FATAL_ERROR "*** *** Unable to interpret sunbird --version" ) + ENDIF ( _SUNBIRD_VERSION_OK ) + +ENDIF ( SUNBIRD_FOUND ) + +# So, by now we should have the following variables set: +MESSAGE ( STATUS " SUNBIRD_MAIN_INCLUDE_DIR ${SUNBIRD_MAIN_INCLUDE_DIR}" ) +MESSAGE ( STATUS " SUNBIRD_VERSION ${SUNBIRD_VERSION}" ) + +# Set the final output variables +SET ( XPCOM_INCLUDE_DIRS "${XPCOM_INCLUDE_DIRS};${SUNBIRD_MAIN_INCLUDE_DIR}" ) +SET ( XPCOM_LIBRARY_DIRS "${THUNDERBIRD_XPCOM_LIBRARY_DIRS}" ) +SET ( XPCOM_LIBRARIES "${THUNDERBIRD_XPCOM_LIBRARIES}" ) + +# And here is what we found out: +MESSAGE ( STATUS "Found xpcom (thunderbird and sunbird):" ) +MESSAGE ( STATUS " XPCOM_INCLUDE_DIRS ${XPCOM_INCLUDE_DIRS}" ) +MESSAGE ( STATUS " XPCOM_LIBRARY_DIRS ${XPCOM_LIBRARY_DIRS}" ) +MESSAGE ( STATUS " XPCOM_LIBRARIES ${XPCOM_LIBRARIES}" ) +MESSAGE ( STATUS " SUNBIRD_VERSION ${SUNBIRD_VERSION}" ) |