-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FindCheck.cmake update. Fixed some issues where tests could not be bu…
…ilt.
- Loading branch information
Showing
1 changed file
with
75 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,79 @@ | ||
# - Try to find the CHECK libraries | ||
# Once done this will define | ||
#.rst: | ||
# FindCheck | ||
# ----------- | ||
# | ||
# CHECK_FOUND - system has check | ||
# CHECK_INCLUDE_DIR - the check include directory | ||
# CHECK_LIBRARIES - check library | ||
# Find Check | ||
# | ||
# This configuration file for finding libcheck is originally from | ||
# the opensync project. The originally was downloaded from here: | ||
# opensync.org/browser/branches/3rd-party-cmake-modules/modules/FindCheck.cmake | ||
# Find Check headers and libraries. | ||
# | ||
# Copyright (c) 2007 Daniel Gollub <[email protected]> | ||
# Copyright (c) 2007 Bjoern Ricks <[email protected]> | ||
# :: | ||
# | ||
# Redistribution and use is allowed according to the terms of the New | ||
# BSD license. | ||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
|
||
|
||
INCLUDE( FindPkgConfig ) | ||
|
||
# Take care about check.pc settings | ||
PKG_SEARCH_MODULE( CHECK check ) | ||
|
||
# Look for CHECK include dir and libraries | ||
IF( NOT CHECK_FOUND ) | ||
IF ( CHECK_INSTALL_DIR ) | ||
MESSAGE ( STATUS "Using override CHECK_INSTALL_DIR to find check" ) | ||
SET ( CHECK_INCLUDE_DIR "${CHECK_INSTALL_DIR}/include" ) | ||
SET ( CHECK_INCLUDE_DIRS "${CHECK_INCLUDE_DIR}" ) | ||
FIND_LIBRARY( CHECK_LIBRARY NAMES check PATHS "${CHECK_INSTALL_DIR}/lib" ) | ||
FIND_LIBRARY( COMPAT_LIBRARY NAMES compat PATHS "${CHECK_INSTALL_DIR}/lib" ) | ||
SET ( CHECK_LIBRARIES "${CHECK_LIBRARY}" "${COMPAT_LIBRARY}" ) | ||
ELSE ( CHECK_INSTALL_DIR ) | ||
FIND_PATH( CHECK_INCLUDE_DIR check.h ) | ||
FIND_LIBRARY( CHECK_LIBRARIES NAMES check ) | ||
ENDIF ( CHECK_INSTALL_DIR ) | ||
|
||
IF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES ) | ||
SET( CHECK_FOUND 1 ) | ||
IF ( NOT Check_FIND_QUIETLY ) | ||
MESSAGE ( STATUS "Found CHECK: ${CHECK_LIBRARIES}" ) | ||
ENDIF ( NOT Check_FIND_QUIETLY ) | ||
ELSE ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES ) | ||
IF ( Check_FIND_REQUIRED ) | ||
MESSAGE( FATAL_ERROR "Could NOT find CHECK" ) | ||
ELSE ( Check_FIND_REQUIRED ) | ||
IF ( NOT Check_FIND_QUIETLY ) | ||
MESSAGE( STATUS "Could NOT find CHECK" ) | ||
ENDIF ( NOT Check_FIND_QUIETLY ) | ||
ENDIF ( Check_FIND_REQUIRED ) | ||
ENDIF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES ) | ||
ENDIF( NOT CHECK_FOUND ) | ||
|
||
# Hide advanced variables from CMake GUIs | ||
MARK_AS_ADVANCED( CHECK_INCLUDE_DIR CHECK_LIBRARIES ) | ||
# CHECK_FOUND - True if Check found. | ||
# CHECK_INCLUDE_DIRS - Where to find check.h. | ||
# CHECK_LIBRARIES - List of libraries when using Check. | ||
# CHECK_VERSION_STRING - The version of Check found. | ||
|
||
#============================================================================= | ||
# Copyright 2018 Silvio Clecio <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public License | ||
# as published by the Free Software Foundation; | ||
# version 2.1 of the License. | ||
# | ||
# This library 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 library. If not, see <http://www.gnu.org/licenses/>. | ||
#============================================================================= | ||
|
||
# Sat Jan 20 23:33:47 -03 2018 | ||
|
||
find_package(PkgConfig QUIET) | ||
pkg_check_modules(PC_CHECK QUIET check) | ||
|
||
find_path(CHECK_INCLUDE_DIR | ||
NAMES check.h | ||
HINTS ${PC_CHECK_INCLUDEDIR} ${PC_CHECK_INCLUDE_DIRS}) | ||
|
||
find_library(CHECK_LIBRARY | ||
NAMES check libcheck | ||
HINTS ${PC_CHECK_LIBDIR} ${PC_CHECK_LIBRARY_DIRS}) | ||
|
||
if (PC_CHECK_VERSION) | ||
set(CHECK_VERSION_STRING ${PC_CHECK_VERSION}) | ||
elseif (CHECK_INCLUDE_DIR AND EXISTS "${CHECK_INCLUDE_DIR}/check.h") | ||
set(check_version_list MAJOR MINOR MICRO) | ||
foreach (v ${check_version_list}) | ||
set(regex_check_version "^#define CHECK_${v}_VERSION +\\(?([0-9]+)\\)?$") | ||
file(STRINGS "${CHECK_INCLUDE_DIR}/check.h" check_version_${v} REGEX "${regex_check_version}") | ||
string(REGEX REPLACE "${regex_check_version}" "\\1" check_version_${v} "${check_version_${v}}") | ||
unset(regex_check_version) | ||
endforeach () | ||
set(CHECK_VERSION_STRING "${check_version_MAJOR}.${check_version_MINOR}.${check_version_MICRO}") | ||
foreach (v check_version_list) | ||
unset(check_version_${v}) | ||
endforeach () | ||
unset(check_version_list) | ||
endif () | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Check | ||
REQUIRED_VARS CHECK_LIBRARY CHECK_INCLUDE_DIR | ||
VERSION_VAR CHECK_VERSION_STRING) | ||
|
||
if (CHECK_FOUND) | ||
set(CHECK_LIBRARIES ${CHECK_LIBRARY}) | ||
set(CHECK_INCLUDE_DIRS ${CHECK_INCLUDE_DIR}) | ||
if (NOT TARGET Check::Check) | ||
add_library(Check::Check UNKNOWN IMPORTED) | ||
set_target_properties(Check::Check PROPERTIES | ||
IMPORTED_LOCATION "${CHECK_LIBRARY}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${CHECK_INCLUDE_DIR}") | ||
endif () | ||
endif () | ||
|
||
mark_as_advanced(CHECK_INCLUDE_DIR CHECK_LIBRARY) |