| 1 |
# SPDX-FileCopyrightText: 2008,2010,2011 by Volker Lanz <[email protected]> |
| 2 |
# SPDX-License-Identifier: BSD-2-Clause |
| 3 |
# |
| 4 |
# Redistribution and use in source and binary forms, with or without |
| 5 |
# modification, are permitted provided that the following conditions |
| 6 |
# are met: |
| 7 |
# |
| 8 |
# 1. Redistributions of source code must retain the above copyright |
| 9 |
# notice, this list of conditions and the following disclaimer. |
| 10 |
# 2. Redistributions in binary form must reproduce the above copyright |
| 11 |
# notice, this list of conditions and the following disclaimer in the |
| 12 |
# documentation and/or other materials provided with the distribution. |
| 13 |
# |
| 14 |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 15 |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 16 |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 17 |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 18 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 19 |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 20 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 21 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 |
|
| 25 |
include(CheckCSourceCompiles) |
| 26 |
include(CheckFunctionExists) |
| 27 |
|
| 28 |
if (LIBPARTED_INCLUDE_DIR AND LIBPARTED_LIBRARY) |
| 29 |
# Already in cache, be silent |
| 30 |
set(LIBPARTED_FIND_QUIETLY TRUE) |
| 31 |
endif (LIBPARTED_INCLUDE_DIR AND LIBPARTED_LIBRARY) |
| 32 |
|
| 33 |
|
| 34 |
FIND_PATH(LIBPARTED_INCLUDE_DIR parted.h PATH_SUFFIXES parted ) |
| 35 |
|
| 36 |
FIND_LIBRARY(LIBPARTED_LIBRARY NAMES parted) |
| 37 |
FIND_LIBRARY(LIBPARTED_FS_RESIZE_LIBRARY NAMES parted-fs-resize) |
| 38 |
|
| 39 |
INCLUDE(FindPackageHandleStandardArgs) |
| 40 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPARTED DEFAULT_MSG LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR) |
| 41 |
|
| 42 |
if (LIBPARTED_FS_RESIZE_LIBRARY) |
| 43 |
set(LIBPARTED_LIBS ${LIBPARTED_LIBRARY} ${LIBPARTED_FS_RESIZE_LIBRARY}) |
| 44 |
else (LIBPARTED_FS_RESIZE_LIBRARY) |
| 45 |
set(LIBPARTED_LIBS ${LIBPARTED_LIBRARY}) |
| 46 |
endif (LIBPARTED_FS_RESIZE_LIBRARY) |
| 47 |
|
| 48 |
# KDE adds -ansi to the C make flags, parted headers use GNU extensions, so |
| 49 |
# undo that |
| 50 |
unset(CMAKE_C_FLAGS) |
| 51 |
|
| 52 |
set(CMAKE_REQUIRED_INCLUDES ${LIBPARTED_INCLUDE_DIR}) |
| 53 |
set(CMAKE_REQUIRED_LIBRARIES ${LIBPARTED_LIBS}) |
| 54 |
|
| 55 |
CHECK_FUNCTION_EXISTS("ped_file_system_clobber" LIBPARTED_FILESYSTEM_SUPPORT) # parted < 3.0 |
| 56 |
CHECK_FUNCTION_EXISTS("ped_file_system_resize" LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT) # parted != 3.0 |
| 57 |
|
| 58 |
MARK_AS_ADVANCED(LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR LIBPARTED_FILESYSTEM_SUPPORT LIBPARTED_FS_RESIZE_LIBRARY LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT) |