Files
bongo/cmake/FindSRS2.cmake
T
2026-07-20 11:13:05 +02:00

52 lines
2.0 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>
# ****************************************************************************/
find_path(SRS2_INCLUDE_DIR NAMES srs2.h)
find_library(SRS2_LIBRARY NAMES srs2)
include(CheckCSourceCompiles)
if(SRS2_INCLUDE_DIR)
set(_SRS2_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
set(CMAKE_REQUIRED_INCLUDES "${SRS2_INCLUDE_DIR}")
check_c_source_compiles([=[
#include <srs2.h>
#ifndef SRS2_SECURE_FREE_SECRETS
#error Bongo requires its maintained libsrs2 security patch
#endif
int main(void) { return 0; }
]=] SRS2_HAS_SECURE_FREE_SECRETS)
set(CMAKE_REQUIRED_INCLUDES "${_SRS2_REQUIRED_INCLUDES}")
unset(_SRS2_REQUIRED_INCLUDES)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SRS2 REQUIRED_VARS
SRS2_LIBRARY SRS2_INCLUDE_DIR SRS2_HAS_SECURE_FREE_SECRETS)
if(SRS2_FOUND AND NOT TARGET SRS2::SRS2)
add_library(SRS2::SRS2 UNKNOWN IMPORTED)
set_target_properties(SRS2::SRS2 PROPERTIES
IMPORTED_LOCATION "${SRS2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SRS2_INCLUDE_DIR}")
endif()
mark_as_advanced(SRS2_INCLUDE_DIR SRS2_LIBRARY)