summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Gansterer <paroga@paroga.com>2019-02-05 05:51:20 (GMT)
committerBrad King <brad.king@kitware.com>2019-02-06 16:20:57 (GMT)
commitdd45f23b0142fb92de17458dd69b2b6f967f94bd (patch)
tree7154ac3c3a25cc991489ba32ac9299f99cc3deee
parent062cfd991faac000d484c74e5af7d65726c655dc (diff)
downloadCMake-dd45f23b0142fb92de17458dd69b2b6f967f94bd.zip
CMake-dd45f23b0142fb92de17458dd69b2b6f967f94bd.tar.gz
CMake-dd45f23b0142fb92de17458dd69b2b6f967f94bd.tar.bz2
FindCups: add imported target
-rw-r--r--Help/release/dev/FindCups-imported-target.rst4
-rw-r--r--Modules/FindCups.cmake48
-rw-r--r--Tests/CMakeLists.txt4
-rw-r--r--Tests/FindCups/CMakeLists.txt10
-rw-r--r--Tests/FindCups/Test/CMakeLists.txt16
-rw-r--r--Tests/FindCups/Test/main.c12
6 files changed, 85 insertions, 9 deletions
diff --git a/Help/release/dev/FindCups-imported-target.rst b/Help/release/dev/FindCups-imported-target.rst
new file mode 100644
index 0000000..0fd9178
--- /dev/null
+++ b/Help/release/dev/FindCups-imported-target.rst
@@ -0,0 +1,4 @@
+FindCups-imported-target
+------------------------
+
+* The :module:`FindCups` module now provides imported targets.
diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake
index 10ce229..27105b9 100644
--- a/Modules/FindCups.cmake
+++ b/Modules/FindCups.cmake
@@ -5,18 +5,38 @@
FindCups
--------
-Try to find the Cups printing system
+Find the CUPS printing system.
-Once done this will define
+Set CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE to TRUE if you need a version which
+features this function (i.e. at least 1.1.19)
-::
+Imported targets
+^^^^^^^^^^^^^^^^
- CUPS_FOUND - system has Cups
- CUPS_INCLUDE_DIR - the Cups include directory
- CUPS_LIBRARIES - Libraries needed to use Cups
- CUPS_VERSION_STRING - version of Cups found (since CMake 2.8.8)
- Set CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE to TRUE if you need a version which
- features this function (i.e. at least 1.1.19)
+This module defines :prop_tgt:`IMPORTED` target ``Cups::Cups``, if Cups has
+been found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``CUPS_FOUND``
+ true if CUPS headers and libraries were found
+``CUPS_INCLUDE_DIRS``
+ the directory containing the Cups headers
+``CUPS_LIBRARIES``
+ the libraries to link against to use CUPS.
+``CUPS_VERSION_STRING``
+ the version of CUPS found (since CMake 2.8.8)
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``CUPS_INCLUDE_DIR``
+ the directory containing the Cups headers
#]=======================================================================]
find_path(CUPS_INCLUDE_DIR cups/cups.h )
@@ -66,3 +86,13 @@ else ()
endif ()
mark_as_advanced(CUPS_INCLUDE_DIR CUPS_LIBRARIES)
+
+if (CUPS_FOUND)
+ set(CUPS_INCLUDE_DIRS "${CUPS_INCLUDE_DIR}")
+ if (NOT TARGET Cups::Cups)
+ add_library(Cups::Cups INTERFACE IMPORTED)
+ set_target_properties(Cups::Cups PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${CUPS_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${CUPS_INCLUDE_DIR}")
+ endif ()
+endif ()
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index ed98d97..b5bcdd5 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1413,6 +1413,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
add_subdirectory(FindCURL)
endif()
+ if(CMake_TEST_FindCups)
+ add_subdirectory(FindCups)
+ endif()
+
if(CMake_TEST_FindDoxygen)
add_subdirectory(FindDoxygen)
endif()
diff --git a/Tests/FindCups/CMakeLists.txt b/Tests/FindCups/CMakeLists.txt
new file mode 100644
index 0000000..5be1ac1
--- /dev/null
+++ b/Tests/FindCups/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindCups.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindCups/Test"
+ "${CMake_BINARY_DIR}/Tests/FindCups/Test"
+ ${build_generator_args}
+ --build-project FindCups
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindCups/Test/CMakeLists.txt b/Tests/FindCups/Test/CMakeLists.txt
new file mode 100644
index 0000000..9e90553
--- /dev/null
+++ b/Tests/FindCups/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindCups C)
+include(CTest)
+
+find_package(Cups REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_CUPS_VERSION="${CUPS_VERSION_STRING}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt Cups::Cups)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${CUPS_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${CUPS_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindCups/Test/main.c b/Tests/FindCups/Test/main.c
new file mode 100644
index 0000000..b69d621
--- /dev/null
+++ b/Tests/FindCups/Test/main.c
@@ -0,0 +1,12 @@
+#include <cups/cups.h>
+
+int main()
+{
+ int num_options = 0;
+ cups_option_t* options = NULL;
+
+ num_options = cupsAddOption(CUPS_COPIES, "1", num_options, &options);
+ cupsFreeOptions(num_options, options);
+
+ return 0;
+}