]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | #.rst: |
2 | # PThreads4W config wrap for vcpkg | |
3 | # ------------ | |
4 | # | |
5 | # Find the PThread4W includes and library. | |
6 | # | |
7 | # Result Variables | |
8 | # ^^^^^^^^^^^^^^^^ | |
9 | # | |
10 | # This script defines the following variables: | |
11 | # | |
12 | # ``PThreads4W_FOUND`` | |
13 | # True if PThreads4W library found | |
14 | # | |
15 | # ``PThreads4W_VERSION`` | |
16 | # Containing the PThreads4W version tag (manually defined) | |
17 | # | |
18 | # ``PThreads4W_INCLUDE_DIR`` | |
19 | # Location of PThreads4W headers | |
20 | # | |
21 | # ``PThreads4W_LIBRARY`` | |
22 | # List of libraries to link with when using PThreads4W (no exception handling) | |
23 | # | |
24 | # ``PThreads4W_CXXEXC_LIBRARY`` | |
25 | # List of libraries to link with when using PThreads4W (C++ exception handling) | |
26 | # | |
27 | # ``PThreads4W_STRUCTEXC_LIBRARY`` | |
28 | # List of libraries to link with when using PThreads4W (struct exception handling) | |
29 | # | |
30 | # Result Targets | |
31 | # ^^^^^^^^^^^^^^^^ | |
32 | # | |
33 | # This script defines the following targets: | |
34 | # | |
35 | # ``PThreads4W::PThreads4W`` | |
36 | # Target to use PThreads4W (no exception handling) | |
37 | # | |
38 | # ``PThreads4W::PThreads4W_CXXEXC`` | |
39 | # Target to use PThreads4W (C++ exception handling) | |
40 | # | |
41 | # ``PThreads4W::PThreads4W_STRUCTEXC`` | |
42 | # Target to use PThreads4W (struct exception handling) | |
43 | # | |
44 | ||
45 | include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) | |
46 | include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake) | |
47 | ||
48 | if(NOT PThreads4W_INCLUDE_DIR) | |
49 | find_path(PThreads4W_INCLUDE_DIR NAMES pthread.h) | |
50 | endif() | |
51 | ||
52 | set(PThreads4W_MAJOR_VERSION 3) | |
53 | set(PThreads4W_MINOR_VERSION 0) | |
54 | set(PThreads4W_PATCH_VERSION 0) | |
55 | set(PThreads4W_VERSION "${PThreads4W_MAJOR_VERSION}.${PThreads4W_MINOR_VERSION}.${PThreads4W_PATCH_VERSION}") | |
56 | ||
57 | # Allow libraries to be set manually | |
58 | if(NOT PThreads4W_LIBRARY) | |
59 | find_library(PThreads4W_LIBRARY_RELEASE NAMES pthreadVC${PThreads4W_MAJOR_VERSION}) | |
60 | find_library(PThreads4W_LIBRARY_DEBUG NAMES pthreadVC${PThreads4W_MAJOR_VERSION}d) | |
61 | select_library_configurations(PThreads4W) | |
62 | endif() | |
63 | if(NOT PThreads4W_CXXEXC_LIBRARY) | |
64 | find_library(PThreads4W_CXXEXC_LIBRARY_RELEASE NAMES pthreadVCE${PThreads4W_MAJOR_VERSION}) | |
65 | find_library(PThreads4W_CXXEXC_LIBRARY_DEBUG NAMES pthreadVCE${PThreads4W_MAJOR_VERSION}d) | |
66 | select_library_configurations(PThreads4W_CXXEXC) | |
67 | endif() | |
68 | if(NOT PThreads4W_STRUCTEXC_LIBRARY) | |
69 | find_library(PThreads4W_STRUCTEXC_LIBRARY_RELEASE NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}) | |
70 | find_library(PThreads4W_STRUCTEXC_LIBRARY_DEBUG NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}d) | |
71 | select_library_configurations(PThreads4W_STRUCTEXC) | |
72 | endif() | |
73 | ||
74 | find_package_handle_standard_args(PThreads4W DEFAULT_MSG PThreads4W_LIBRARY PThreads4W_CXXEXC_LIBRARY PThreads4W_STRUCTEXC_LIBRARY PThreads4W_INCLUDE_DIR) | |
75 | mark_as_advanced(PThreads4W_INCLUDE_DIR PThreads4W_LIBRARY PThreads4W_CXXEXC_LIBRARY PThreads4W_STRUCTEXC_LIBRARY) | |
76 | ||
77 | set(PThreads4W_DLL_DIR ${PThreads4W_INCLUDE_DIR}) | |
78 | list(TRANSFORM PThreads4W_DLL_DIR APPEND "/../bin") | |
79 | message(STATUS "PThreads4W_DLL_DIR: ${PThreads4W_DLL_DIR}") | |
80 | ||
81 | find_file(PThreads4W_LIBRARY_RELEASE_DLL NAMES pthreadVC${PThreads4W_MAJOR_VERSION}.dll PATHS ${PThreads4W_DLL_DIR}) | |
82 | find_file(PThreads4W_LIBRARY_DEBUG_DLL NAMES pthreadVC${PThreads4W_MAJOR_VERSION}d.dll PATHS ${PThreads4W_DLL_DIR}) | |
83 | find_file(PThreads4W_CXXEXC_LIBRARY_RELEASE_DLL NAMES pthreadVCE${PThreads4W_MAJOR_VERSION}.dll PATHS ${PThreads4W_DLL_DIR}) | |
84 | find_file(PThreads4W_CXXEXC_LIBRARY_DEBUG_DLL NAMES pthreadVCE${PThreads4W_MAJOR_VERSION}d.dll PATHS ${PThreads4W_DLL_DIR}) | |
85 | find_file(PThreads4W_STRUCTEXC_LIBRARY_RELEASE_DLL NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}.dll PATHS ${PThreads4W_DLL_DIR}) | |
86 | find_file(PThreads4W_STRUCTEXC_LIBRARY_DEBUG_DLL NAMES pthreadVSE${PThreads4W_MAJOR_VERSION}d.dll PATHS ${PThreads4W_DLL_DIR}) | |
87 | ||
88 | #Compatibility definitions, deprecated | |
89 | set(PTHREAD_INCLUDE_DIR ${PThreads4W_INCLUDE_DIR} CACHE PATH "") | |
90 | set(PTHREADS_INCLUDE_DIR ${PThreads4W_INCLUDE_DIR} CACHE PATH "") | |
91 | set(PThreads_windows_INCLUDE_DIR ${PThreads4W_INCLUDE_DIR} CACHE PATH "") | |
92 | set(PTHREAD_LIBRARIES ${PThreads4W_LIBRARY} CACHE STRING "") | |
93 | set(PTHREADS_LIBRARIES ${PThreads4W_LIBRARY} CACHE STRING "") | |
94 | set(PTHREAD_LIBRARY ${PThreads4W_LIBRARY} CACHE STRING "") | |
95 | set(PTHREADS_LIBRARY ${PThreads4W_LIBRARY} CACHE STRING "") | |
96 | set(LIBPTHREAD ${PThreads4W_LIBRARY} CACHE STRING "") | |
97 | set(LIBPTHREADS ${PThreads4W_LIBRARY} CACHE STRING "") | |
98 | set(PThreads_windows_LIBRARY ${PThreads4W_LIBRARY} CACHE STRING "") | |
99 | set(PThreads_VERSION "${PThreads4W_VERSION}") | |
100 | if(PThreads4W_FOUND) | |
101 | set(PThreads_windows_FOUND TRUE) | |
102 | endif() | |
103 | ||
104 | #TARGETS | |
105 | if( PThreads4W_FOUND AND NOT TARGET PThreads4W::PThreads4W_CXXEXC ) | |
106 | if( EXISTS "${PThreads4W_CXXEXC_LIBRARY_RELEASE_DLL}" ) | |
107 | add_library( PThreads4W::PThreads4W_CXXEXC SHARED IMPORTED ) | |
108 | set_target_properties( PThreads4W::PThreads4W_CXXEXC PROPERTIES | |
109 | IMPORTED_LOCATION_RELEASE "${PThreads4W_CXXEXC_LIBRARY_RELEASE_DLL}" | |
110 | IMPORTED_IMPLIB "${PThreads4W_CXXEXC_LIBRARY_RELEASE}" | |
111 | INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" | |
112 | IMPORTED_CONFIGURATIONS Release | |
113 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) | |
114 | if( EXISTS "${PThreads4W_CXXEXC_LIBRARY_DEBUG_DLL}" ) | |
115 | set_property( TARGET PThreads4W::PThreads4W_CXXEXC APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) | |
116 | set_target_properties( PThreads4W::PThreads4W_CXXEXC PROPERTIES | |
117 | IMPORTED_LOCATION_DEBUG "${PThreads4W_CXXEXC_LIBRARY_DEBUG_DLL}" | |
118 | IMPORTED_IMPLIB_DEBUG "${PThreads4W_CXXEXC_LIBRARY_DEBUG}" ) | |
119 | endif() | |
120 | else() | |
121 | add_library( PThreads4W::PThreads4W_CXXEXC UNKNOWN IMPORTED ) | |
122 | set_target_properties( PThreads4W::PThreads4W_CXXEXC PROPERTIES | |
123 | IMPORTED_LOCATION_RELEASE "${PThreads4W_CXXEXC_LIBRARY_RELEASE}" | |
124 | INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" | |
125 | IMPORTED_CONFIGURATIONS Release | |
126 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) | |
127 | if( EXISTS "${PThreads4W_CXXEXC_LIBRARY_DEBUG}" ) | |
128 | set_property( TARGET PThreads4W::PThreads4W_CXXEXC APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) | |
129 | set_target_properties( PThreads4W::PThreads4W_CXXEXC PROPERTIES | |
130 | IMPORTED_LOCATION_DEBUG "${PThreads4W_CXXEXC_LIBRARY_DEBUG}" ) | |
131 | endif() | |
132 | endif() | |
133 | endif() | |
134 | ||
135 | if( PThreads4W_FOUND AND NOT TARGET PThreads4W::PThreads4W_STRUCTEXC ) | |
136 | if( EXISTS "${PThreads4W_STRUCTEXC_LIBRARY_RELEASE_DLL}" ) | |
137 | add_library( PThreads4W::PThreads4W_STRUCTEXC SHARED IMPORTED ) | |
138 | set_target_properties( PThreads4W::PThreads4W_STRUCTEXC PROPERTIES | |
139 | IMPORTED_LOCATION_RELEASE "${PThreads4W_STRUCTEXC_LIBRARY_RELEASE_DLL}" | |
140 | IMPORTED_IMPLIB "${PThreads4W_STRUCTEXC_LIBRARY_RELEASE}" | |
141 | INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" | |
142 | IMPORTED_CONFIGURATIONS Release | |
143 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) | |
144 | if( EXISTS "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG_DLL}" ) | |
145 | set_property( TARGET PThreads4W::PThreads4W_STRUCTEXC APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) | |
146 | set_target_properties( PThreads4W::PThreads4W_STRUCTEXC PROPERTIES | |
147 | IMPORTED_LOCATION_DEBUG "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG_DLL}" | |
148 | IMPORTED_IMPLIB_DEBUG "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG}" ) | |
149 | endif() | |
150 | else() | |
151 | add_library( PThreads4W::PThreads4W_STRUCTEXC UNKNOWN IMPORTED ) | |
152 | set_target_properties( PThreads4W::PThreads4W_STRUCTEXC PROPERTIES | |
153 | IMPORTED_LOCATION_RELEASE "${PThreads4W_STRUCTEXC_LIBRARY_RELEASE}" | |
154 | INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" | |
155 | IMPORTED_CONFIGURATIONS Release | |
156 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) | |
157 | if( EXISTS "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG}" ) | |
158 | set_property( TARGET PThreads4W::PThreads4W_STRUCTEXC APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) | |
159 | set_target_properties( PThreads4W::PThreads4W_STRUCTEXC PROPERTIES | |
160 | IMPORTED_LOCATION_DEBUG "${PThreads4W_STRUCTEXC_LIBRARY_DEBUG}" ) | |
161 | endif() | |
162 | endif() | |
163 | endif() | |
164 | ||
165 | if( PThreads4W_FOUND AND NOT TARGET PThreads4W::PThreads4W ) | |
166 | if( EXISTS "${PThreads4W_LIBRARY_RELEASE_DLL}" ) | |
167 | add_library( PThreads4W::PThreads4W SHARED IMPORTED ) | |
168 | set_target_properties( PThreads4W::PThreads4W PROPERTIES | |
169 | IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE_DLL}" | |
170 | IMPORTED_IMPLIB "${PThreads4W_LIBRARY_RELEASE}" | |
171 | INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" | |
172 | IMPORTED_CONFIGURATIONS Release | |
173 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) | |
174 | if( EXISTS "${PThreads4W_LIBRARY_DEBUG_DLL}" ) | |
175 | set_property( TARGET PThreads4W::PThreads4W APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) | |
176 | set_target_properties( PThreads4W::PThreads4W PROPERTIES | |
177 | IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG_DLL}" | |
178 | IMPORTED_IMPLIB_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) | |
179 | endif() | |
180 | else() | |
181 | add_library( PThreads4W::PThreads4W UNKNOWN IMPORTED ) | |
182 | set_target_properties( PThreads4W::PThreads4W PROPERTIES | |
183 | IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE}" | |
184 | INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" | |
185 | IMPORTED_CONFIGURATIONS Release | |
186 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) | |
187 | if( EXISTS "${PThreads4W_LIBRARY_DEBUG}" ) | |
188 | set_property( TARGET PThreads4W::PThreads4W APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) | |
189 | set_target_properties( PThreads4W::PThreads4W PROPERTIES | |
190 | IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) | |
191 | endif() | |
192 | endif() | |
193 | endif() | |
194 | ||
195 | #Compatibility targets, deprecated | |
196 | if( PThreads4W_FOUND AND NOT TARGET PThreads_windows::PThreads_windows ) | |
197 | if( EXISTS "${PThreads4W_LIBRARY_RELEASE_DLL}" ) | |
198 | add_library( PThreads_windows::PThreads_windows SHARED IMPORTED ) | |
199 | set_target_properties( PThreads_windows::PThreads_windows PROPERTIES | |
200 | IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE_DLL}" | |
201 | IMPORTED_IMPLIB "${PThreads4W_LIBRARY_RELEASE}" | |
202 | INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" | |
203 | IMPORTED_CONFIGURATIONS Release | |
204 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) | |
205 | if( EXISTS "${PThreads4W_LIBRARY_DEBUG_DLL}" ) | |
206 | set_property( TARGET PThreads_windows::PThreads_windows APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) | |
207 | set_target_properties( PThreads_windows::PThreads_windows PROPERTIES | |
208 | IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG_DLL}" | |
209 | IMPORTED_IMPLIB_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) | |
210 | endif() | |
211 | else() | |
212 | add_library( PThreads_windows::PThreads_windows UNKNOWN IMPORTED ) | |
213 | set_target_properties( PThreads_windows::PThreads_windows PROPERTIES | |
214 | IMPORTED_LOCATION_RELEASE "${PThreads4W_LIBRARY_RELEASE}" | |
215 | INTERFACE_INCLUDE_DIRECTORIES "${PThreads4W_INCLUDE_DIR}" | |
216 | IMPORTED_CONFIGURATIONS Release | |
217 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) | |
218 | if( EXISTS "${PThreads4W_LIBRARY_DEBUG}" ) | |
219 | set_property( TARGET PThreads_windows::PThreads_windows APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) | |
220 | set_target_properties( PThreads_windows::PThreads_windows PROPERTIES | |
221 | IMPORTED_LOCATION_DEBUG "${PThreads4W_LIBRARY_DEBUG}" ) | |
222 | endif() | |
223 | endif() | |
224 | endif() |