-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindGUnit.cmake
More file actions
90 lines (80 loc) · 2.26 KB
/
FindGUnit.cmake
File metadata and controls
90 lines (80 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindGTest
# ---------
#
# Locate GUnit C++ Testing Framework
#
# Imported targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` targets:
#
# ``GUnit::GUnit``
# The GUnit if found; adds GTest::GTest automatically
#
# ``GUnit::Main``
# Wraps GTest::Main
#
#
# Result variables
# ^^^^^^^^^^^^^^^^
#
# This module will set the following variables in your project:
#
# ``GUNIT_FOUND``
# Found the GUnit framework
# ``GUNIT_INCLUDE_DIRS``
# the directory containing the GUnit headers
#
#
# Cache variables
# ^^^^^^^^^^^^^^^
#
# The following cache variables may also be set:
#
# ``GUNIT_ROOT``
# The root directory of the GUnit installation (may also be
# set as an environment variable)
#
#
# Example usage
# ^^^^^^^^^^^^^
#
# ::
#
# find_package(GUnit REQUIRED)
#
# add_executable(foo foo.cc)
# target_link_libraries(foo GUnit::GUnit GUnit::Main)
find_path(GUNIT_INCLUDE_DIR GUnit.h
HINTS
$ENV{GUNIT_ROOT}/include
${GUNIT_ROOT}/include
)
mark_as_advanced(GUNIT_INCLUDE_DIR)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GUnit REQUIRED_VARS GUNIT_INCLUDE_DIR)
if(NOT GUNIT_FOUND)
return()
endif()
message("GUnit found: " ${GUNIT_INCLUDE_DIR})
find_package(GTest REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(Gherkin REQUIRED)
if (NOT TARGET GUnit::GUnit)
add_library(GUnit::GUnit INTERFACE IMPORTED)
# HACK to be removed when GUnit includes <nohlmann/json.hpp> instead of <json.hpp>
get_target_property(JSON_INC_DIR nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
set_target_properties(GUnit::GUnit PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${GUNIT_INCLUDE_DIR}
INTERFACE_INCLUDE_DIRECTORIES "${JSON_INC_DIR}/nlohmann") # HACK
set_target_properties(GUnit::GUnit PROPERTIES
INTERFACE_LINK_LIBRARIES "GTest::GTest;nlohmann_json::nlohmann_json;gherkin::gherkin;gmock")
endif()
if (NOT TARGET GUnit::Main)
add_library(GUnit::Main INTERFACE IMPORTED)
set_target_properties(GUnit::Main PROPERTIES
INTERFACE_LINK_LIBRARIES GTest::Main)
endif()