trf++/cmake
diff -N FindCLHEP.cmake
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FindCLHEP.cmake 8 Aug 2011 21:18:52 -0000 1.1
@@ -0,0 +1,86 @@
+#############################################################
+# cmake module for finding CLHEP
+#
+# returns:
+# CLHEP_FOUND : set to TRUE or FALSE
+# CLHEP_VERSION : package version
+# CLHEP_INCLUDE_DIRS : paths to clhep includes
+# CLHEP_LIBRARY_DIRS : paths to clhep libraries
+# CLHEP_LIBRARIES : list of clhep libraries
+#
+# @author Jan Engels, DESY
+#############################################################
+
+
+# find clhep-config
+SET( CLHEP_CONFIG_EXECUTABLE CLHEP_CONFIG_EXECUTABLE-NOTFOUND )
+MARK_AS_ADVANCED( CLHEP_CONFIG_EXECUTABLE )
+FIND_PROGRAM( CLHEP_CONFIG_EXECUTABLE clhep-config PATHS ${CLHEP_DIR}/bin NO_DEFAULT_PATH )
+IF( NOT CLHEP_DIR )
+ FIND_PROGRAM( CLHEP_CONFIG_EXECUTABLE clhep-config )
+ENDIF()
+
+IF( CLHEP_CONFIG_EXECUTABLE )
+
+ # ==============================================
+ # === CLHEP_PREFIX ===
+ # ==============================================
+
+ EXECUTE_PROCESS( COMMAND "${CLHEP_CONFIG_EXECUTABLE}" --prefix
+ OUTPUT_VARIABLE CLHEP_ROOT
+ RESULT_VARIABLE _exit_code
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ IF( NOT _exit_code EQUAL 0 )
+ SET( CLHEP_ROOT )
+ ENDIF()
+
+
+ # ==============================================
+ # === CLHEP_VERSION ===
+ # ==============================================
+ INCLUDE( MacroCheckPackageVersion )
+
+ EXECUTE_PROCESS( COMMAND "${CLHEP_CONFIG_EXECUTABLE}" --version
+ OUTPUT_VARIABLE _output
+ RESULT_VARIABLE _exit_code
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ IF( _exit_code EQUAL 0 )
+ #SEPARATE_ARGUMENTS( CLHEP_VERSION UNIX_COMMAND "${_output}" ) # needs cmake >= 2.8
+ SET( CLHEP_VERSION ${_output} )
+ SEPARATE_ARGUMENTS( CLHEP_VERSION )
+ LIST( REMOVE_AT CLHEP_VERSION 0 ) # remove CLHEP string from output of 'clhep-config --version'
+ CHECK_PACKAGE_VERSION( CLHEP ${CLHEP_VERSION} )
+ ELSE()
+ SET( CLHEP_VERSION )
+ ENDIF()
+
+ENDIF( CLHEP_CONFIG_EXECUTABLE )
+
+
+# ---------- includes ---------------------------------------------------------
+SET( CLHEP_INCLUDE_DIRS CLHEP_INCLUDE_DIRS-NOTFOUND )
+MARK_AS_ADVANCED( CLHEP_INCLUDE_DIRS )
+
+FIND_PATH( CLHEP_INCLUDE_DIRS NAMES CLHEP/Vector/ThreeVector.h PATHS ${CLHEP_DIR}/include NO_DEFAULT_PATH )
+IF( NOT CLHEP_DIR )
+ FIND_PATH( CLHEP_INCLUDE_DIRS NAMES CLHEP/Vector/ThreeVector.h )
+ENDIF()
+
+
+# ---------- libraries --------------------------------------------------------
+INCLUDE( MacroCheckPackageLibs )
+
+# only standard libraries should be passed as arguments to CHECK_PACKAGE_LIBS
+# additional components are set by cmake in variable PKG_FIND_COMPONENTS
+# first argument should be the package name
+CHECK_PACKAGE_LIBS( CLHEP CLHEP )
+
+
+
+# ---------- final checking ---------------------------------------------------
+INCLUDE( FindPackageHandleStandardArgs )
+# set CLHEP_FOUND to TRUE if all listed variables are TRUE and not empty
+FIND_PACKAGE_HANDLE_STANDARD_ARGS( CLHEP DEFAULT_MSG CLHEP_INCLUDE_DIRS CLHEP_LIBRARIES PACKAGE_VERSION_COMPATIBLE )
+
trf++/cmake
diff -N MacroCheckPackageLibs.cmake
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MacroCheckPackageLibs.cmake 8 Aug 2011 21:18:52 -0000 1.1
@@ -0,0 +1,164 @@
+##############################################################################
+# macro for checkin package libraries in ${PKG_ROOT}/lib
+#
+#
+# macro usage:
+# CHECK_PACKAGE_LIBS( PACKAGE_NAME stdlib1 stdlib2 ... stdlibn )
+# only standard libraries should be passed as arguments to the macro
+# component libraries are set by cmake in PKG_FIND_COMPONENTS (when
+# calling FIND_PACKAGE with COMPONENTS argument) or through the
+# variable PKG_USE_COMPONENTS
+#
+#
+# required variables:
+# PKG_ROOT : path to PKG root directory
+#
+#
+# returns following variables:
+# PKG_LIBRARY_DIRS : list of paths to be used with LINK_DIRECTORIES
+# PGK_LIBRARIES : list of STANDARD libraries (NOT including COMPONENTS)
+# PKG_COMPONENT_LIBRARIES : list of COMPONENT libraries
+# PKG_${COMPONENT}_FOUND : set to TRUE or FALSE for each library
+# PKG_${COMPONENT}_LIBRARY : path to each individual library
+#
+#
+# PKG_LIBRARIES and PKG_LIBRARY_DIRS will be empty if any of the standard
+# libraries is missing
+#
+# @author Jan Engels, Desy
+##############################################################################
+
+
+SET( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE )
+
+MACRO( CHECK_PACKAGE_LIBS _pkgname )
+
+ SET( _std_lib_missing FALSE )
+ SET( _ext_lib_missing FALSE )
+
+ SET( _std_libnames ${ARGN} )
+ SET( _ext_libnames ${${_pkgname}_FIND_COMPONENTS} ${${_pkgname}_USE_COMPONENTS} )
+
+ IF( _ext_libnames )
+ SEPARATE_ARGUMENTS( _ext_libnames )
+ LIST( REMOVE_DUPLICATES _ext_libnames )
+ ENDIF()
+
+ IF( NOT ${_pkgname}_FIND_QUIETLY )
+ MESSAGE( STATUS "Check for ${_pkgname}_LIBRARIES: ${_std_libnames}" )
+ IF( _ext_libnames )
+ MESSAGE( STATUS "Check for ${_pkgname}_COMPONENT_LIBRARIES: ${_ext_libnames}" )
+ ENDIF()
+ ENDIF()
+
+ SET( ${_pkgname}_LIBRARY_DIRS )
+ MARK_AS_ADVANCED( ${_pkgname}_LIBRARY_DIRS )
+
+ SET( ${_pkgname}_LIBRARIES )
+ MARK_AS_ADVANCED( ${_pkgname}_LIBRARIES )
+
+ SET( ${_pkgname}_COMPONENT_LIBRARIES )
+ MARK_AS_ADVANCED( ${_pkgname}_COMPONENT_LIBRARIES )
+
+ SET( ${_pkgname}_COMPONENT_VARIABLES )
+ MARK_AS_ADVANCED( ${_pkgname}_COMPONENT_VARIABLES )
+
+ FOREACH( _libname ${_std_libnames} ${_ext_libnames} )
+
+ # flag to check if it is a standard or a component library
+ LIST( FIND _std_libnames "${_libname}" _aux )
+ IF( ${_aux} LESS 0 )
+ SET( _is_std_lib FALSE )
+ ELSE()
+ SET( _is_std_lib TRUE )
+ ENDIF()
+
+ # libname in upper case
+ STRING( TOUPPER ${_libname} _ulibname )
+
+ SET( ${_pkgname}_${_ulibname}_LIBRARY ${_pkgname}_${_ulibname}_LIBRARY-NOTFOUND )
+ MARK_AS_ADVANCED( ${_pkgname}_${_ulibname}_LIBRARY )
+
+ # WARNING: using PATH_SUFFIXES may cause problems when using variable CMAKE_FIND_ROOT_PATH
+ # this problem does not occur if expanding PATHS
+ # look in FindMySQL.cmake for more info
+ #FIND_LIBRARY( ${_pkgname}_${_ulibname}_LIBRARY NAMES ${_libname} PATHS
+ # ${${_pkgname}_ROOT} ${${_pkgname}_DIR} ${${_pkgname}_LIB_SEARCH_PATH}
+ # PATH_SUFFIXES lib64 lib
+ # NO_DEFAULT_PATH
+ #)
+
+ FIND_LIBRARY( ${_pkgname}_${_ulibname}_LIBRARY NAMES ${_libname} PATHS
+ ${${_pkgname}_ROOT}/lib64 ${${_pkgname}_ROOT}/lib
+ ${${_pkgname}_DIR}/lib64 ${${_pkgname}_DIR}/lib
+ ${${_pkgname}_LIB_SEARCH_PATH} ${${_pkgname}_LIB_SEARCH_PATH}/lib64 ${${_pkgname}_LIB_SEARCH_PATH}/lib
+ NO_DEFAULT_PATH
+ )
+
+ IF( NOT ${_pkgname}_DIR )
+ FIND_LIBRARY( ${_pkgname}_${_ulibname}_LIBRARY NAMES ${_libname} )
+ ENDIF()
+
+ IF( ${_pkgname}_FIND_REQUIRED )
+ LIST( APPEND ${_pkgname}_COMPONENT_VARIABLES ${_pkgname}_${_ulibname}_LIBRARY )
+ ENDIF()
+
+ IF( ${_pkgname}_${_ulibname}_LIBRARY ) # if library found
+
+ SET( ${_pkgname}_${_ulibname}_FOUND TRUE )
+
+ # split libraries in PKG_LIBRARIES and PKG_COMPONENT_LIBRARIES
+ IF( _is_std_lib )
+ LIST( APPEND ${_pkgname}_LIBRARIES ${${_pkgname}_${_ulibname}_LIBRARY} )
+ ELSE()
+ LIST( APPEND ${_pkgname}_COMPONENT_LIBRARIES ${${_pkgname}_${_ulibname}_LIBRARY} )
+ ENDIF()
+
+ GET_FILENAME_COMPONENT( _aux ${${_pkgname}_${_ulibname}_LIBRARY} PATH )
+ LIST( APPEND ${_pkgname}_LIBRARY_DIRS ${_aux} )
+
+ IF( NOT ${_pkgname}_FIND_QUIETLY )
+ MESSAGE( STATUS "Check for ${_pkgname}_${_ulibname}_LIBRARY: ${${_pkgname}_${_ulibname}_LIBRARY} -- ok" )
+ ENDIF()
+
+ ELSE() # library not found
+
+ SET( ${_pkgname}_${_ulibname}_FOUND FALSE )
+
+ IF( _is_std_lib )
+ SET( _std_lib_missing TRUE )
+ ELSE()
+ SET( _ext_lib_missing TRUE )
+ ENDIF()
+
+ IF( NOT ${_pkgname}_FIND_QUIETLY )
+ MESSAGE( STATUS "Check for ${_pkgname}_${_ulibname}_LIBRARY: ${_libname} -- failed" )
+ ENDIF()
+
+ ENDIF()
+
+ ENDFOREACH()
+
+ # clear PKG_LIBRARIES if standard library is missing
+ IF( _std_lib_missing )
+ SET( ${_pkgname}_LIBRARIES )
+ ENDIF()
+
+ # clear PKG_COMPONENT_LIBRARIES if a component library is missing and
+ # FIND_PACKAGE called with REQUIRED argument
+ IF( _ext_lib_missing AND ${_pkgname}_FIND_REQUIRED )
+ SET( ${_pkgname}_COMPONENT_LIBRARIES )
+ ENDIF()
+
+ # remove duplicate paths in PKG_LIBRARY_DIRS
+ IF( ${_pkgname}_LIBRARY_DIRS )
+ LIST( REMOVE_DUPLICATES ${_pkgname}_LIBRARY_DIRS )
+ ENDIF()
+
+ # debug
+ #MESSAGE( STATUS "${_pkgname}_LIBRARIES: ${${_pkgname}_LIBRARIES}" )
+ #MESSAGE( STATUS "${_pkgname}_COMPONENT_LIBRARIES: ${${_pkgname}_COMPONENT_LIBRARIES}" )
+ #MESSAGE( STATUS "${_pkgname}_LIBRARY_DIRS: ${${_pkgname}_LIBRARY_DIRS}" )
+
+ENDMACRO( CHECK_PACKAGE_LIBS _pkgname )
+
trf++/cmake
diff -N MacroCheckPackageVersion.cmake
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MacroCheckPackageVersion.cmake 8 Aug 2011 21:18:52 -0000 1.1
@@ -0,0 +1,108 @@
+##############################################################################
+# macro for checking a package version
+#
+# this macro should be called from your PKGVersion.cmake or from a
+# FindPKG.cmake module with the following arguments:
+# _pkgname : The package name
+# _iversion : The installed version of the package
+#
+#
+# the following conventions are used:
+#
+# if FIND_PACKAGE is called with EXACT argument than the version has to
+# match EXACTLY, i.e.:
+# 1.5 == 1.5
+# 1.5 == 1.5.0
+# 1.5 == 1.5.0.0
+# 1.5.2 == 1.5.2.0
+# 1.5.2.1 == 1.5.2.1
+# 1.5.2 != 1.5.2.1
+# 1.5 != 1.5.0.1
+#
+#
+# otherwise a MINIMUM_REQUIRED version is checked for, i.e. the same
+# behavior as with the cmake variable CMAKE_MINIMUM_REQUIRED, e.g.:
+# searching: 1.2 --> installed: 1.5.2.2 --> compatible
+# searching: 1.5 --> installed: 1.5.2.2 --> compatible
+# searching: 1.5.2.1 --> installed: 1.5.2.2 --> compatible
+# searching: 1.5.2.3 --> installed: 1.5.2.2 --> unsuitable
+# searching: 1.7 --> installed: 1.5.2.2 --> unsuitable
+#
+#
+# following variables are returned (internally to cmake):
+# PACKAGE_VERSION_EXACT : set to TRUE if exact version was found
+# PACKAGE_VERSION_COMPATIBLE : set to TRUE if version is compatible
+# PACKAGE_VERSION_UNSUITABLE : set to TRUE if version found is unsuitable
+#
+#
+# @author Jan Engels, Desy IT
+##############################################################################
+
+# these variables are evaluated internally by the cmake command FIND_PACKAGE to mark this
+# package as suitable or not depending on the required version
+SET( PACKAGE_VERSION_EXACT FALSE )
+SET( PACKAGE_VERSION_COMPATIBLE TRUE )
+SET( PACKAGE_VERSION_UNSUITABLE FALSE )
+
+
+# cmake internal variable PACKAGE_FIND_NAME is not defined on FindPKG.cmake
+# modules, therefore it is passed as an argument to the macro
+# _iversion is the installed version of the package
+# _sversion is the version searched by the user with FIND_PACKAGE
+#MACRO( CHECK_PACKAGE_VERSION _pkgname _iversion )
+MACRO( CHECK_PACKAGE_VERSION _pkgname ) # left with one argument only for backwards compatibility
+
+ IF( NOT "${ARGV1}" STREQUAL "" )
+ SET( _iversion ${ARGV1} )
+ ELSE()
+ SET( _iversion ${${_pkgname}_VERSION_MAJOR}.${${_pkgname}_VERSION_MINOR}.${${_pkgname}_VERSION_PATCH}.${${_pkgname}_VERSION_TWEAK} )
+ ENDIF()
+
+ #SET( _sversion_major ${${_pkgname}_FIND_VERSION_MAJOR} )
+ #SET( _sversion_minor ${${_pkgname}_FIND_VERSION_MINOR} )
+
+ SET( _sversion ${${_pkgname}_FIND_VERSION} )
+
+ IF( NOT ${_pkgname}_FIND_QUIETLY )
+ MESSAGE( STATUS "Check for ${_pkgname} (${_iversion})" )
+ ENDIF()
+
+ # only do work if FIND_PACKAGE called with a version argument
+ IF( _sversion )
+
+ #IF( NOT ${_pkgname}_FIND_QUIETLY )
+ # MESSAGE( STATUS "Check for ${_pkgname}: looking for version ${_sversion}" )
+ #ENDIF()
+
+ IF( ${_iversion} VERSION_EQUAL ${_sversion} ) # if version matches EXACTLY
+ #IF( NOT ${_pkgname}_FIND_QUIETLY )
+ # MESSAGE( STATUS "Check for ${_pkgname}: exact version found: ${_iversion}" )
+ #ENDIF()
+ SET( PACKAGE_VERSION_EXACT TRUE )
+ ELSE() # if version does not match EXACTLY, check if it is compatible/suitable
+
+ # installed version must be greater or equal than version searched by the user, i.e.
+ # like with the CMAKE_MINIMUM_REQUIRED commando
+ # if user asks for version 1.2.5 then any version >= 1.2.5 is suitable/compatible
+ IF( NOT ${_sversion} VERSION_LESS ${_iversion} )
+ SET( PACKAGE_VERSION_UNSUITABLE TRUE )
+ ENDIF()
+ # -------------------------------------------------------------------------------------
+
+ IF( ${_pkgname}_FIND_VERSION_EXACT ) # if exact version was required search must fail!!
+ #IF( NOT ${_pkgname}_FIND_QUIETLY )
+ # MESSAGE( "Check for ${_pkgname}: could not find exact version" )
+ #ENDIF()
+ SET( PACKAGE_VERSION_UNSUITABLE TRUE )
+ ENDIF()
+
+ ENDIF()
+
+ IF( PACKAGE_VERSION_UNSUITABLE )
+ SET( PACKAGE_VERSION_COMPATIBLE FALSE )
+ ENDIF()
+
+ ENDIF( _sversion )
+
+ENDMACRO( CHECK_PACKAGE_VERSION )
+