72 lines
2.7 KiB
CMake
72 lines
2.7 KiB
CMake
# /****************************************************************************
|
|
# * <Novell-copyright>
|
|
# * Copyright (c) 2001 Novell, Inc. All Rights Reserved.
|
|
# *
|
|
# * This program is free software; you can redistribute it and/or
|
|
# * modify it under the terms of version 2 of the GNU General Public License
|
|
# * as published by the Free Software Foundation.
|
|
# *
|
|
# * This program is distributed in the hope that it will be useful,
|
|
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# * GNU General Public License for more details.
|
|
# *
|
|
# * You should have received a copy of the GNU General Public License
|
|
# * along with this program; if not, contact Novell, Inc.
|
|
# *
|
|
# * To contact Novell about this file by physical or electronic mail, you
|
|
# * may find current contact information at www.novell.com.
|
|
# * </Novell-copyright>
|
|
# ****************************************************************************/
|
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
find_package(LibIcal CONFIG QUIET NO_MODULE)
|
|
endif()
|
|
|
|
if(LibIcal_FOUND AND TARGET ical)
|
|
if(NOT TARGET LibIcal::ical)
|
|
add_library(LibIcal::ical ALIAS ical)
|
|
endif()
|
|
if(NOT LibIcal_INCLUDE_DIR)
|
|
get_target_property(LibIcal_INCLUDE_DIR ical INTERFACE_INCLUDE_DIRECTORIES)
|
|
endif()
|
|
return()
|
|
endif()
|
|
|
|
find_path(LibIcal_INCLUDE_DIR NAMES libical/ical.h ical.h)
|
|
find_library(LibIcal_LIBRARY NAMES ical)
|
|
|
|
if(LibIcal_INCLUDE_DIR)
|
|
if(EXISTS "${LibIcal_INCLUDE_DIR}/libical/ical.h")
|
|
set(_LibIcal_VERSION_HEADER "${LibIcal_INCLUDE_DIR}/libical/ical.h")
|
|
else()
|
|
set(_LibIcal_VERSION_HEADER "${LibIcal_INCLUDE_DIR}/ical.h")
|
|
endif()
|
|
file(STRINGS "${_LibIcal_VERSION_HEADER}" _LibIcal_VERSION_LINES
|
|
REGEX "^#define ICAL_(MAJOR|MINOR|PATCH)_VERSION[ \t]+\\([0-9]+\\)")
|
|
foreach(_component MAJOR MINOR PATCH)
|
|
string(REGEX MATCH "ICAL_${_component}_VERSION[ \t]+\\(([0-9]+)\\)"
|
|
_LibIcal_VERSION_MATCH "${_LibIcal_VERSION_LINES}")
|
|
set(_LibIcal_VERSION_${_component} "${CMAKE_MATCH_1}")
|
|
endforeach()
|
|
if(DEFINED _LibIcal_VERSION_MAJOR AND DEFINED _LibIcal_VERSION_MINOR AND
|
|
DEFINED _LibIcal_VERSION_PATCH)
|
|
set(LibIcal_VERSION
|
|
"${_LibIcal_VERSION_MAJOR}.${_LibIcal_VERSION_MINOR}.${_LibIcal_VERSION_PATCH}")
|
|
endif()
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(LibIcal
|
|
REQUIRED_VARS LibIcal_LIBRARY LibIcal_INCLUDE_DIR
|
|
VERSION_VAR LibIcal_VERSION)
|
|
|
|
if(LibIcal_FOUND AND NOT TARGET LibIcal::ical)
|
|
add_library(LibIcal::ical UNKNOWN IMPORTED)
|
|
set_target_properties(LibIcal::ical PROPERTIES
|
|
IMPORTED_LOCATION "${LibIcal_LIBRARY}"
|
|
INTERFACE_INCLUDE_DIRECTORIES "${LibIcal_INCLUDE_DIR}")
|
|
endif()
|
|
|
|
mark_as_advanced(LibIcal_INCLUDE_DIR LibIcal_LIBRARY)
|