# FindGARFIELD # ---------- # # Find the GARFIELD includes and library. # # IMPORTED Targets # ^^^^^^^^^^^^^^^^ # # This module defines :prop_tgt:`IMPORTED` target ``GARFIELD::GARFIELD``, if # GARFIELD has been found. # # Result Variables # ^^^^^^^^^^^^^^^^ # # This module defines the following variables: # # :: # # GARFIELD_HOME - location of sources, build and install # GARFIELD_INCLUDE_DIRS - where to find Track.h, etc. # GARFIELD_LIBRARIES - List of libraries when using garfield. # GARFIELD_FOUND - True if garfield found. # # :: # # As GARFIELD does not have a file where we could read out the build / found version we do NOT define: # GARFIELD_VERSION_STRING # GARFIELD_VERSION_MAJOR # GARFIELD_VERSION_MINOR # GARFIELD_VERSION_PATCH # as a consequence we will/can NOT check for a specific requested version! # # Hints # ^^^^^ # # A user may set ``GARFIELD_ROOT`` to a garfield installation root to tell this # module where to look. # manager COMET Software Group # author andreas.jansen@tu-dresden.de set(_GARFIELD_SEARCHES) # Search GARFIELD_ROOT first if it is set. if(GARFIELD_ROOT) set(_GARFIELD_SEARCH_ROOT PATHS ${GARFIELD_ROOT} NO_DEFAULT_PATH) list(APPEND _GARFIELD_SEARCHES _GARFIELD_SEARCH_ROOT) endif() # Normal search. set(_GARFIELD_SEARCH_NORMAL PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\GARFIELD;InstallPath]" "$ENV{PROGRAMFILES}/garfield" ) list(APPEND _GARFIELD_SEARCHES _GARFIELD_SEARCH_NORMAL) # Try each find GarfieldConfig.cmake, than use it to configure foreach(search ${_GARFIELD_SEARCHES}) find_file(GARFIELD_CONFIG NAMES GarfieldConfig.cmake ${${search}} PATH_SUFFIXES cmake) endforeach() # Sets GARFIELD_INCLUDE_DIRS and GARFIELD_LIBRARIES (we override GARFIELD_LIBRARIES manually later!!) include(${GARFIELD_CONFIG}) # Allow GARFIELD_LIBRARY to be set manually, as the location of the garfield library # prefer lib64 if available! if(NOT GARFIELD_LIBRARY) foreach(search ${_GARFIELD_SEARCHES}) find_library(GARFIELD_LIBRARY_RELEASE NAMES ${GARFIELD_LIBRARIES} ${${search}} PATH_SUFFIXES lib64 lib) find_library(GARFIELD_LIBRARY_DEBUG NAMES ${GARFIELD_LIBRARIES} ${${search}} PATH_SUFFIXES lib64 lib) endforeach() include(SelectLibraryConfigurations) select_library_configurations(GARFIELD) endif() unset(GARFIELD_LIBRARIES) # handle the QUIETLY and REQUIRED arguments and set GARFIELD_FOUND to TRUE if # all listed variables are TRUE include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GARFIELD REQUIRED_VARS GARFIELD_LIBRARY GARFIELD_INCLUDE_DIRS) # Sets GARFIELD_HOME and GARFIELD_HEED_DATABASE get_filename_component(GARFIELD_HOME ${GARFIELD_LIBRARY}/../../../ ABSOLUTE) foreach(search ${GARFIELD_INCLUDE_DIRS}) string(REGEX MATCH "[^\;]+GARFIELD/[^/]+/Heed/heed\\+\\+" GARFIELD_HEED "${GARFIELD_INCLUDE_DIRS}") endforeach() set(GARFIELD_HEED_DATABASE ${GARFIELD_HEED}/database) if(GARFIELD_FOUND) set(GARFIELD_INCLUDE_DIR ${GARFIELD_INCLUDE_DIRS} ${GARFIELD_HEED}/..) if(NOT GARFIELD_LIBRARIES) set(GARFIELD_LIBRARIES ${GARFIELD_LIBRARY}) endif() if(NOT TARGET GARFIELD::GARFIELD) add_library(GARFIELD::GARFIELD UNKNOWN IMPORTED) set_target_properties(GARFIELD::GARFIELD PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GARFIELD_INCLUDE_DIRS}") if(GARFIELD_LIBRARY_RELEASE) set_property(TARGET GARFIELD::GARFIELD APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(GARFIELD::GARFIELD PROPERTIES IMPORTED_LOCATION_RELEASE "${GARFIELD_LIBRARY_RELEASE}") endif() if(GARFIELD_LIBRARY_DEBUG) set_property(TARGET GARFIELD::GARFIELD APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_target_properties(GARFIELD::GARFIELD PROPERTIES IMPORTED_LOCATION_DEBUG "${GARFIELD_LIBRARY_DEBUG}") endif() if(NOT GARFIELD_LIBRARY_RELEASE AND NOT GARFIELD_LIBRARY_DEBUG) set_property(TARGET GARFIELD::GARFIELD APPEND PROPERTY IMPORTED_LOCATION "${GARFIELD_LIBRARY}") endif() endif() endif() unset(GARFIELD_HEED)