mirror of
https://github.com/open62541/open62541.git
synced 2026-10-18 13:42:32 +08:00
100 lines
3.9 KiB
CMake
100 lines
3.9 KiB
CMake
# - Try to find the CHECK libraries
|
|
# Once done this will define
|
|
#
|
|
# CHECK_FOUND - system has check
|
|
# CHECK_INCLUDE_DIRS - the check include directory
|
|
# CHECK_LIBRARIES - check library
|
|
#
|
|
# 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
|
|
#
|
|
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
|
|
# Copyright (c) 2007 Bjoern Ricks <b.ricks@fh-osnabrueck.de>
|
|
#
|
|
# Redistribution and use is allowed according to the terms of the New
|
|
# BSD license.
|
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
|
|
|
if(WIN32)
|
|
# Manually define CHECK_INSTALL_DIR if vcpkg is not used
|
|
if(DEFINED VCPKG_INSTALLED_DIR)
|
|
set(CHECK_INSTALL_DIR "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}")
|
|
# find_package(check CONFIG REQUIRED)
|
|
else()
|
|
if(NOT CHECK_INSTALL_DIR)
|
|
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
|
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
|
else()
|
|
set(_progfiles_x86 "ProgramFiles(x86)")
|
|
if(NOT "$ENV{${_progfiles_x86}}" STREQUAL "")
|
|
# under windows 64 bit machine
|
|
file(TO_CMAKE_PATH "$ENV{${_progfiles_x86}}" _programfiles)
|
|
else()
|
|
# under windows 32 bit machine
|
|
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _programfiles)
|
|
endif()
|
|
unset(_progfiles_x86)
|
|
endif()
|
|
if(EXISTS ${_programfiles}/Check/lib/check.lib)
|
|
MESSAGE(STATUS "${_programfiles}/Check/lib/check.lib exists")
|
|
set(CHECK_INSTALL_DIR "${_programfiles}/Check")
|
|
endif()
|
|
unset (_programfiles)
|
|
endif()
|
|
endif()
|
|
else()
|
|
# Take care about check.pc settings
|
|
find_package(PkgConfig REQUIRED)
|
|
PKG_SEARCH_MODULE( CHECK check )
|
|
endif()
|
|
|
|
# pkg-config exports the plural CHECK_INCLUDE_DIRS and linker flags with the
|
|
# architecture-specific library directory. Mirror them to the singular
|
|
# CHECK_INCLUDE_DIR and CHECK_LIBRARIES that this module documents and the build
|
|
# expects. Do not resolve the library again with find_library(), because that can
|
|
# pick a host-architecture library during multilib/cross builds.
|
|
IF( CHECK_FOUND )
|
|
IF( NOT CHECK_INCLUDE_DIR )
|
|
SET( CHECK_INCLUDE_DIR ${CHECK_INCLUDE_DIRS} )
|
|
ENDIF()
|
|
IF( CHECK_LDFLAGS )
|
|
SET( CHECK_LIBRARIES ${CHECK_LDFLAGS} )
|
|
IF( CHECK_LDFLAGS_OTHER )
|
|
LIST( APPEND CHECK_LIBRARIES ${CHECK_LDFLAGS_OTHER} )
|
|
ENDIF()
|
|
ENDIF()
|
|
ENDIF()
|
|
|
|
# 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: ${CHECK_INSTALL_DIR}" )
|
|
SET ( CHECK_INCLUDE_DIRS "${CHECK_INSTALL_DIR}/include" )
|
|
# Find_library() always returns the 64-bit version in "C:/Program Files/Check/lib" no matter what path is passed in
|
|
# FIND_LIBRARY( CHECK_LIBRARIES NAMES check PATHS "${CHECK_INSTALL_DIR}/lib" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH )
|
|
SET ( CHECK_LIBRARIES "${CHECK_INSTALL_DIR}/lib/check.lib" )
|
|
ELSE ( CHECK_INSTALL_DIR )
|
|
FIND_PATH( CHECK_INCLUDE_DIRS check.h )
|
|
FIND_LIBRARY( CHECK_LIBRARIES NAMES check )
|
|
ENDIF ( CHECK_INSTALL_DIR )
|
|
|
|
IF ( CHECK_INCLUDE_DIRS 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_DIRS 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_DIRS AND CHECK_LIBRARIES )
|
|
ENDIF( NOT CHECK_FOUND )
|
|
|
|
# Hide advanced variables from CMake GUIs
|
|
MARK_AS_ADVANCED( CHECK_INCLUDE_DIRS CHECK_LIBRARY_DIRS CHECK_LIBRARIES )
|