1
-
2
- macro (require_pkg_directory pkg_name pkg_user_name)
3
- if (hasParent)
4
- # Skip this logic when this macro was not invoked from the
5
- # top-level CMakeLists.txt file under the assumption that this
6
- # package was dropped into another build system using add_subdirectory().
7
- # Note that this will also skip if you call this macro from
8
- # a subdirectory in your own package, so just don't do it!
9
-
10
- #message(STATUS "skipping require_pkg_directory for ${pkg_name}")
11
- else ()
12
- #message(STATUS "require_directory: name=${pkg_name}")
13
- option (${pkg_name} _DIR "Root folder for ${pkg_user_name} installation" OFF )
14
- if (NOT ${pkg_name} _DIR)
15
- message (
16
- FATAL_ERROR
17
- "Please specify ${pkg_user_name} library installation root"
18
- " with -D${pkg_name} _DIR="
19
- )
20
- endif ()
21
- endif ()
22
- endmacro (require_pkg_directory)
23
-
24
- macro (find_package_local pkg_name pkg_directory pkg_other_name)
25
- # Whether we loaded the package in the following loop with find_package()
1
+ macro (find_package_local pkg_name pkg_other_name)
26
2
set (${pkg_name} _PACKAGE_LOADED 0)
27
-
28
3
if (hasParent)
29
4
# Skip this logic when this macro was not invoked from the
30
5
# top-level CMakeLists.txt file under the assumption that this
@@ -34,97 +9,19 @@ macro(find_package_local pkg_name pkg_directory pkg_other_name)
34
9
35
10
# message(STATUS "skipping find_package for ${pkg_name}")
36
11
else ()
37
- message (
38
- STATUS "find_package_local: pkg name=\" ${pkg_name} \" , "
39
- "directory=\" ${pkg_directory} \" "
12
+ message (STATUS "find_package_local: pkg name=\" ${pkg_name} \" " )
13
+
14
+ find_package (
15
+ ${pkg_name}
16
+ NAMES ${pkg_name} ${pkg_other_name}
17
+ NO_CMAKE_PACKAGE_REGISTRY
18
+ NO_CMAKE_BUILDS_PATH
19
+ NO_CMAKE_SYSTEM_PATH
20
+ NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
21
+ NO_SYSTEM_ENVIRONMENT_PATH
22
+ QUIET
23
+ REQUIRED
40
24
)
41
-
42
- # Rest of the arguments are potential relative search paths wrt the
43
- # ${pkg_directory}
44
- set (prefix_args ${ARGN} )
45
-
46
- # Default search paths: root, /cmake and /CMake subdirectories
47
- list (APPEND prefix_args "/" "/cmake" "/CMake" )
48
-
49
- foreach (prefix ${prefix_args} )
50
- set (potential_path ${pkg_directory} /${prefix} )
51
- # message("prefix: ${potential_path}")
52
- if (EXISTS "${potential_path} " )
53
- # message(STATUS "find_package_local: trying path: ${potential_path}")
54
-
55
- # Search locally only for package based on the user's supplied path; if
56
- # this fails try to next one. Even if the directory exists (tested above)
57
- # this might fail if a directory does not have the config file
58
- find_package (
59
- ${pkg_name}
60
- PATHS ${potential_path}
61
- NAMES ${pkg_name} ${pkg_other_name}
62
- NO_CMAKE_PACKAGE_REGISTRY
63
- NO_CMAKE_BUILDS_PATH
64
- NO_CMAKE_SYSTEM_PATH
65
- NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
66
- NO_SYSTEM_ENVIRONMENT_PATH
67
- QUIET
68
- )
69
-
70
- # Break out of the search loop now that we have found the path
71
- if (${${pkg_name} _FOUND})
72
- message (STATUS "find_package_local: found with prefix: ${prefix} " )
73
- set (${pkg_name} _PACKAGE_LOADED 1)
74
- break ()
75
- endif ()
76
- endif ()
77
- endforeach ()
78
-
79
- if (NOT ${${pkg_name} _PACKAGE_LOADED})
80
- message (STATUS "find_package_local: can not find package: ${pkg_name} " )
81
-
82
- foreach (prefix ${prefix_args} )
83
- set (path ${${pkg_name} _DIR}/${prefix} )
84
- message (STATUS "find_package_local: searched: ${path} " )
85
- endforeach ()
86
-
87
- message (
88
- FATAL_ERROR "find_package_local: can not find package: ${pkg_name} "
89
- " tried to find_package(..) with above search paths"
90
- )
91
- endif ()
25
+ set (${pkg_name} _PACKAGE_LOADED 1)
92
26
endif ()
93
27
endmacro (find_package_local)
94
-
95
- macro (optional_pkg_directory pkg_name pkg_user_name assume_found_if_hasparent)
96
- if (hasParent)
97
- # Skip MOST of this logic when this macro was not invoked from the
98
- # top-level CMakeLists.txt file under the assumption that this
99
- # package was dropped into another build system using add_subdirectory().
100
- # Note that this will also skip if you call this macro from
101
- # a subdirectory in your own package, so just don't do it!
102
-
103
- if (${assume_found_if_hasparent} )
104
- # Assume that the package is available even if the directory wasn't specified
105
- set (${pkg_name} _DIR_FOUND 1)
106
- endif ()
107
- else ()
108
- #message(STATUS "optional_pkg_directory: name=${pkg_name}")
109
- option (${pkg_name} _DIR "Root folder for ${pkg_user_name} installation" OFF )
110
- if (NOT ${pkg_name} _DIR)
111
- message (
112
- STATUS
113
- "Path for ${pkg_user_name} library (optional) not specified "
114
- "with -D${pkg_name} _DIR="
115
- )
116
- message (
117
- STATUS
118
- "Building without ${pkg_user_name} library"
119
- )
120
- set (${pkg_name} _DIR_FOUND 0)
121
- else ()
122
- message (
123
- STATUS
124
- "Path for ${pkg_user_name} library (optional) specified "
125
- "with -D${pkg_name} _DIR=${${pkg_name} _DIR}"
126
- )
127
- set (${pkg_name} _DIR_FOUND 1)
128
- endif ()
129
- endif ()
130
- endmacro (optional_pkg_directory)
0 commit comments