mirror of
https://github.com/reactos/CMake.git
synced 2025-02-12 06:51:00 +00:00
FindGnuTLS: add target GnuTLS::GnuTLS
Also add a test case for the module.
This commit is contained in:
parent
729c928c7b
commit
44e8b8f1f2
4
Help/release/dev/FindGnuTLS-target.rst
Normal file
4
Help/release/dev/FindGnuTLS-target.rst
Normal file
@ -0,0 +1,4 @@
|
||||
FindGnuTLS-target
|
||||
-----------------
|
||||
|
||||
* The :module:`FindGnuTLS` module now provides an imported target.
|
@ -7,16 +7,25 @@ FindGnuTLS
|
||||
|
||||
Find the GNU Transport Layer Security library (gnutls)
|
||||
|
||||
IMPORTED Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines :prop_tgt:`IMPORTED` target ``GnuTLS::GnuTLS``, if
|
||||
gnutls has been found.
|
||||
|
||||
Once done this will define
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
GNUTLS_FOUND - System has gnutls
|
||||
GNUTLS_INCLUDE_DIR - The gnutls include directory
|
||||
GNUTLS_LIBRARIES - The libraries needed to use gnutls
|
||||
GNUTLS_DEFINITIONS - Compiler switches required for using gnutls
|
||||
``GNUTLS_FOUND``
|
||||
System has gnutls
|
||||
``GNUTLS_INCLUDE_DIR``
|
||||
The gnutls include directory
|
||||
``GNUTLS_LIBRARIES``
|
||||
The libraries needed to use gnutls
|
||||
``GNUTLS_DEFINITIONS``
|
||||
Compiler switches required for using gnutls
|
||||
``GNUTLS_VERSION``
|
||||
version of gnutls.
|
||||
#]=======================================================================]
|
||||
|
||||
# Note that this doesn't try to find the gnutls-extra package.
|
||||
@ -34,6 +43,8 @@ if (NOT WIN32)
|
||||
find_package(PkgConfig QUIET)
|
||||
PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
|
||||
set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})
|
||||
set(GNUTLS_VERSION ${PC_GNUTLS_VERSION})
|
||||
# keep for backward compatibility
|
||||
set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION})
|
||||
endif ()
|
||||
|
||||
@ -59,4 +70,13 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS
|
||||
if(GNUTLS_FOUND)
|
||||
set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY})
|
||||
set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
|
||||
|
||||
if(NOT TARGET GnuTLS::GnuTLS)
|
||||
add_library(GnuTLS::GnuTLS UNKNOWN IMPORTED)
|
||||
set_target_properties(GnuTLS::GnuTLS PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${GNUTLS_INCLUDE_DIRS}"
|
||||
INTERFACE_COMPILE_DEFINITIONS "${GNUTLS_DEFINITIONS}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${GNUTLS_LIBRARIES}")
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1394,6 +1394,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
|
||||
GIF
|
||||
Git
|
||||
GLEW
|
||||
GnuTLS
|
||||
GSL
|
||||
GTK2
|
||||
Iconv
|
||||
|
10
Tests/FindGnuTLS/CMakeLists.txt
Normal file
10
Tests/FindGnuTLS/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
add_test(NAME FindGnuTLS.Test COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/FindGnuTLS/Test"
|
||||
"${CMake_BINARY_DIR}/Tests/FindGnuTLS/Test"
|
||||
${build_generator_args}
|
||||
--build-project TestFindGnuTLS
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
17
Tests/FindGnuTLS/Test/CMakeLists.txt
Normal file
17
Tests/FindGnuTLS/Test/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
project(TestFindGnuTLS C)
|
||||
include(CTest)
|
||||
|
||||
find_package(GnuTLS REQUIRED)
|
||||
|
||||
add_definitions(-DCMAKE_EXPECTED_GNUTLS_VERSION="${GNUTLS_VERSION}")
|
||||
|
||||
add_executable(test_tgt main.c)
|
||||
target_link_libraries(test_tgt GnuTLS::GnuTLS)
|
||||
add_test(NAME test_tgt COMMAND test_tgt)
|
||||
|
||||
add_executable(test_var main.c)
|
||||
target_include_directories(test_var PRIVATE ${GNUTLS_INCLUDE_DIRS})
|
||||
target_link_libraries(test_var PRIVATE ${GNUTLS_LIBRARIES})
|
||||
target_compile_definitions(test_var PRIVATE ${GNUTLS_DEFINITIONS})
|
||||
add_test(NAME test_var COMMAND test_var)
|
22
Tests/FindGnuTLS/Test/main.c
Normal file
22
Tests/FindGnuTLS/Test/main.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gnutls/gnutls.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// test the linker
|
||||
gnutls_session_t session;
|
||||
if (gnutls_init(&session, GNUTLS_CLIENT)) {
|
||||
gnutls_deinit(session);
|
||||
}
|
||||
|
||||
// check the version
|
||||
char gnutls_version_string[16];
|
||||
snprintf(gnutls_version_string, 16, "%i.%i.%i", GNUTLS_VERSION_MAJOR,
|
||||
GNUTLS_VERSION_MINOR, GNUTLS_VERSION_PATCH);
|
||||
assert(strcmp(gnutls_version_string, CMAKE_EXPECTED_GNUTLS_VERSION) == 0);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user