af4680da3e01e01641be65ebf15120c8225c91d5
[platform/upstream/glog.git] / CMakeLists.txt
1 cmake_minimum_required (VERSION 3.0)
2
3 if (POLICY CMP0042)
4   cmake_policy (SET CMP0042 NEW)
5 endif (POLICY CMP0042)
6
7 if (POLICY CMP0063)
8   cmake_policy (SET CMP0063 NEW)
9 endif (POLICY CMP0063)
10
11 project (google-glog)
12
13 enable_testing ()
14
15 set (GLOG_MAJOR_VERSION 0)
16 set (GLOG_MINOR_VERSION 3)
17 set (GLOG_PATCH_VERSION 5)
18
19 set (GLOG_VERSION
20   ${GLOG_MAJOR_VERSION}.${GLOG_MINOR_VERSION}.${GLOG_PATCH_VERSION})
21
22 set (CPACK_PACKAGE_NAME glog)
23 set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "")
24 set (CPACK_PACKAGE_VERSION_MAJOR ${GLOG_MAJOR_VERSION})
25 set (CPACK_PACKAGE_VERSION_MINOR ${GLOG_MINOR_VERSION})
26 set (CPACK_PACKAGE_VERSION_PATCH ${GLOG_PATCH_VERSION})
27 set (CPACK_PACKAGE_VERSION ${GLOG_VERSION})
28
29 option (WITH_GFLAGS "Use gflags" ON)
30 option (WITH_THREADS "Enable multithreading support" ON)
31
32 list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
33
34 include (CheckCSourceCompiles)
35 include (CheckCXXCompilerFlag)
36 include (CheckCXXSourceCompiles)
37 include (CheckFunctionExists)
38 include (CheckIncludeFile)
39 include (CheckIncludeFileCXX)
40 include (CheckLibraryExists)
41 include (CheckStructHasMember)
42 include (CheckSymbolExists)
43 include (CheckTypeSize)
44 include (CMakePackageConfigHelpers)
45 include (CPack)
46 include (CTest)
47 include (DetermineGflagsNamespace)
48
49 set (CMAKE_THREAD_PREFER_PTHREAD 1)
50
51 if (WITH_GFLAGS)
52   find_package (gflags)
53
54   if (gflags_FOUND)
55     set (HAVE_LIB_GFLAGS 1)
56     determine_gflags_namespace (gflags_NAMESPACE)
57   endif (gflags_FOUND)
58 endif (WITH_GFLAGS)
59
60 if (WITH_THREADS)
61   find_package (Threads)
62 endif (WITH_THREADS)
63
64 check_include_file (dlfcn.h HAVE_DLFCN_H)
65 check_include_file (execinfo.h HAVE_EXECINFO_H)
66 check_include_file (glob.h HAVE_GLOB_H)
67 check_include_file (inttypes.h HAVE_INTTYPES_H)
68 check_include_file (libunwind.h HAVE_LIBUNWIND_H)
69 check_include_file (memory.h HAVE_MEMORY_H)
70 check_include_file (pwd.h HAVE_PWD_H)
71 check_include_file (stdint.h HAVE_STDINT_H)
72 check_include_file (stdlib.h HAVE_STDLIB_H)
73 check_include_file (string.h HAVE_STRING_H)
74 check_include_file (strings.h HAVE_STRINGS_H)
75 check_include_file (sys/stat.h HAVE_SYS_STAT_H)
76 check_include_file (sys/syscall.h HAVE_SYS_SYSCALL_H)
77 check_include_file (sys/time.h HAVE_SYS_TIME_H)
78 check_include_file (sys/types.h HAVE_SYS_TYPES_H)
79 check_include_file (sys/utsname.h HAVE_SYS_UTSNAME_H)
80 check_include_file (syscall.h HAVE_SYSCALL_H)
81 check_include_file (syslog.h HAVE_SYSLOG_H)
82 check_include_file (ucontext.h HAVE_UCONTEXT_H)
83 check_include_file (unistd.h HAVE_UNISTD_H)
84 check_include_file (unwind.h HAVE_UNWIND_H)
85
86 check_include_file_cxx ("ext/hash_map" HAVE_EXT_HASH_MAP)
87 check_include_file_cxx ("ext/hash_set" HAVE_EXT_HASH_SET)
88 check_include_file_cxx ("ext/slist" HAVE_EXT_SLIST)
89 check_include_file_cxx ("tr1/unordered_map" HAVE_TR1_UNORDERED_MAP)
90 check_include_file_cxx ("tr1/unordered_set" HAVE_TR1_UNORDERED_SET)
91 check_include_file_cxx ("unordered_map" HAVE_UNORDERED_MAP)
92 check_include_file_cxx ("unordered_set" HAVE_UNORDERED_SET)
93
94 check_type_size ("unsigned __int16" HAVE___UINT16)
95 check_type_size (u_int16_t HAVE_U_INT16_T)
96 check_type_size (uint16_t HAVE_UINT16_T)
97
98 check_function_exists (dladdr HAVE_DLADDR)
99 check_function_exists (fcntl HAVE_FCNTL)
100 check_function_exists (pread HAVE_PREAD)
101 check_function_exists (pwrite HAVE_PWRITE)
102 check_function_exists (sigaction HAVE_SIGACTION)
103 check_function_exists (sigaltstack HAVE_SIGALSTACK)
104
105 # NOTE gcc does not fail if you pass a non-existent -Wno-* option as an
106 # argument. However, it will happily fail if you pass the corresponding -W*
107 # option. So, we check whether options that disable warnings exist by testing
108 # the availability of the corresponding option that enables the warning. This
109 # eliminates the need to check for compiler for several (mainly Clang) options.
110
111 check_cxx_compiler_flag (-Wdeprecated HAVE_NO_DEPRECATED)
112 check_cxx_compiler_flag (-Wunnamed-type-template-args
113     HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS)
114
115 # NOTE: Cannot use check_function_exists here since >=vc-14.0 can define
116 # snprintf as an inline function
117 check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF)
118
119 check_library_exists (unwind get_static_proc_name "" HAVE_LIB_UNWIND)
120
121 find_library (UNWIND_LIBRARY NAMES unwind DOC "unwind library")
122 mark_as_advanced (UNWIND_LIBRARY)
123
124 check_c_source_compiles ("
125 #include <stdlib.h>
126 static void foo(void) __attribute__ ((unused));
127 int main(void) { return 0; }
128 " HAVE___ATTRIBUTE__)
129
130 check_c_source_compiles ("
131 #include <stdlib.h>
132 static void foo(void) __attribute__ ((visibility(\"default\")));
133 int main(void) { return 0; }
134 " HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
135
136 check_c_source_compiles ("
137 #include <stdlib.h>
138 static void foo(void) __attribute__ ((visibility(\"hidden\")));
139 int main(void) { return 0; }
140 " HAVE___ATTRIBUTE__VISIBILITY_HIDDEN)
141
142 check_c_source_compiles ("
143 int main(void) { if (__builtin_expect(0, 0)) return 1; return 0; }
144 " HAVE___BUILTIN_EXPECT)
145
146 check_c_source_compiles ("
147 int main(void)
148 {
149   int a; if (__sync_val_compare_and_swap(&a, 0, 1)) return 1; return 0;
150 }
151 " HAVE___SYNC_VAL_COMPARE_AND_SWAP)
152
153 check_c_source_compiles ("
154 #define _XOPEN_SOURCE 500
155 #include <pthread.h>
156 int main(void)
157 {
158   pthread_rwlock_t l;
159   pthread_rwlock_init(&l, NULL);
160   pthread_rwlock_rdlock(&l);
161   return 0;
162 }
163 " HAVE_RWLOCK)
164
165 check_c_source_compiles ("
166 __declspec(selectany) int a;
167 int main(void) { return 0; }
168 " HAVE___DECLSPEC)
169
170 check_cxx_source_compiles ("
171 #include <vector>
172 vector<int> t; int main() { }
173 " STL_NO_NAMESPACE)
174
175 check_cxx_source_compiles ("
176 #include <vector>
177 std::vector<int> t; int main() { }
178 " STL_STD_NAMESPACE)
179
180 check_cxx_source_compiles ("
181 #include <iostream>
182 std::ostream& operator<<(std::ostream&, struct s);
183 using ::operator<<;
184 int main() { }
185 " HAVE_USING_OPERATOR)
186
187 check_cxx_source_compiles ("
188 namespace Outer { namespace Inner { int i = 0; }}
189 using namespace Outer::Inner;;
190 int main() { return i; }
191 " HAVE_NAMESPACES)
192
193 set (_PC_FIELDS
194   "gregs[REG_PC]"
195   "gregs[REG_EIP]"
196   "gregs[REG_RIP]"
197   "sc_ip"
198   "uc_regs->gregs[PT_NIP]"
199   "gregs[R15]"
200   "arm_pc"
201   "mc_eip"
202   "mc_rip"
203   "__gregs[REG_EIP]"
204   "__gregs[REG_RIP]"
205   "ss.eip"
206   "__ss.__eip"
207   "ss.rip"
208   "__ss.__rip"
209   "ss.srr0"
210   "__ss.__srr0"
211 )
212
213 set (_PC_HEADERS ucontext.h signal.h)
214
215 if (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT)
216   foreach (_PC_FIELD ${_PC_FIELDS})
217     foreach (_PC_HEADER ${_PC_HEADERS})
218       set (_TMP
219       ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/uctfield.c)
220       file (WRITE ${_TMP} "
221 #define _GNU_SOURCE 1
222 #include <${_PC_HEADER}>
223 int main(void)
224 {
225   ucontext_t u;
226   return u.${_PC_FIELD} == 0;
227 }
228 ")
229       try_compile (HAVE_PC_FROM_UCONTEXT ${CMAKE_CURRENT_BINARY_DIR} ${_TMP}
230         COMPILE_DEFINITIONS _GNU_SOURCE=1)
231
232       if (HAVE_PC_FROM_UCONTEXT)
233         set (PC_FROM_UCONTEXT ${_PC_FIELD} CACHE)
234       endif (HAVE_PC_FROM_UCONTEXT)
235     endforeach (_PC_HEADER)
236   endforeach (_PC_FIELD)
237 endif  (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT)
238
239 if (STL_STD_NAMESPACE)
240   set (STL_NAMESPACE std)
241 else (STL_STD_NAMESPACE)
242   set (STL_NAMESPACE "")
243 endif (STL_STD_NAMESPACE)
244
245 set (GOOGLE_NAMESPACE google)
246 set (_START_GOOGLE_NAMESPACE_ "namespace ${GOOGLE_NAMESPACE} {")
247 set (_END_GOOGLE_NAMESPACE_ "}")
248
249 if (HAVE___UINT16)
250   set (ac_cv_have___uint16 1)
251 else (HAVE___UINT16)
252   set (ac_cv_have___uint16 0)
253 endif (HAVE___UINT16)
254
255 if (HAVE_INTTYPES_H)
256   set (ac_cv_have_inttypes_h 1)
257 else (HAVE_INTTYPES_H)
258   set (ac_cv_have_inttypes_h 0)
259 endif (HAVE_INTTYPES_H)
260
261 if (HAVE_LIB_GFLAGS)
262   set (ac_cv_have_libgflags 1)
263 else (HAVE_LIB_GFLAGS)
264   set (ac_cv_have_libgflags 0)
265 endif (HAVE_LIB_GFLAGS)
266
267 if (HAVE_STDINT_H)
268   set (ac_cv_have_stdint_h 1)
269 else (HAVE_STDINT_H)
270   set (ac_cv_have_stdint_h 0)
271 endif (HAVE_STDINT_H)
272
273 if (HAVE_SYS_TYPES_H)
274   set (ac_cv_have_systypes_h 1)
275 else (HAVE_SYS_TYPES_H)
276   set (ac_cv_have_systypes_h 0)
277 endif (HAVE_SYS_TYPES_H)
278
279 if (HAVE_U_INT16_T)
280   set (ac_cv_have_u_int16_t 1)
281 else (HAVE_U_INT16_T)
282   set (ac_cv_have_u_int16_t 0)
283 endif (HAVE_U_INT16_T)
284
285 if (HAVE_UINT16_T)
286   set (ac_cv_have_uint16_t 1)
287 else (HAVE_UINT16_T)
288   set (ac_cv_have_uint16_t 0)
289 endif (HAVE_UINT16_T)
290
291 if (HAVE_UNISTD_H)
292   set (ac_cv_have_unistd_h 1)
293 else (HAVE_UNISTD_H)
294   set (ac_cv_have_unistd_h 0)
295 endif (HAVE_UNISTD_H)
296
297 set (ac_google_namespace ${GOOGLE_NAMESPACE})
298 set (ac_google_end_namespace ${_END_GOOGLE_NAMESPACE_})
299 set (ac_google_start_namespace ${_START_GOOGLE_NAMESPACE_})
300
301 if (HAVE___ATTRIBUTE__)
302   set (ac_cv___attribute___noreturn "__attribute__((noreturn))")
303   set (ac_cv___attribute___noinline "__attribute__((noinline))")
304 elseif (HAVE___DECLSPEC)
305   set (ac_cv___attribute___noreturn "__declspec(noreturn)")
306   #set (ac_cv___attribute___noinline "__declspec(noinline)")
307 endif (HAVE___ATTRIBUTE__)
308
309 if (HAVE___BUILTIN_EXPECT)
310   set (ac_cv_have___builtin_expect 1)
311 else (HAVE___BUILTIN_EXPECT)
312   set (ac_cv_have___builtin_expect 0)
313 endif (HAVE___BUILTIN_EXPECT)
314
315 if (HAVE_USING_OPERATOR)
316   set (ac_cv_cxx_using_operator 1)
317 else (HAVE_USING_OPERATOR)
318   set (ac_cv_cxx_using_operator 0)
319 endif (HAVE_USING_OPERATOR)
320
321 set (SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
322
323 if (WITH_THREADS AND Threads_FOUND)
324   if (CMAKE_USE_PTHREADS_INIT)
325     set (HAVE_PTHREAD 1)
326   endif (CMAKE_USE_PTHREADS_INIT)
327 else (WITH_THREADS AND Threads_FOUND)
328   set (NO_THREADS 1)
329 endif (WITH_THREADS AND Threads_FOUND)
330
331 set (TEST_SRC_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\")
332
333 configure_file (src/config.h.cmake.in config.h)
334 configure_file (src/glog/logging.h.in glog/logging.h @ONLY)
335 configure_file (src/glog/raw_logging.h.in glog/raw_logging.h @ONLY)
336 configure_file (src/glog/stl_logging.h.in glog/stl_logging.h @ONLY)
337 configure_file (src/glog/vlog_is_on.h.in glog/vlog_is_on.h @ONLY)
338
339 set (CMAKE_CXX_VISIBILITY_PRESET default)
340 set (CMAKE_VISIBILITY_INLINES_HIDDEN 1)
341
342 set (GLOG_PUBLIC_H
343   ${CMAKE_CURRENT_BINARY_DIR}/config.h
344   ${CMAKE_CURRENT_BINARY_DIR}/glog/logging.h
345   ${CMAKE_CURRENT_BINARY_DIR}/glog/raw_logging.h
346   ${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h
347   ${CMAKE_CURRENT_BINARY_DIR}/glog/vlog_is_on.h
348   src/glog/log_severity.h
349 )
350
351 set (GLOG_SRCS
352   ${GLOG_PUBLIC_H}
353   src/base/commandlineflags.h
354   src/base/googleinit.h
355   src/base/mutex.h
356   src/demangle.cc
357   src/demangle.h
358   src/logging.cc
359   src/raw_logging.cc
360   src/symbolize.cc
361   src/symbolize.h
362   src/utilities.cc
363   src/utilities.h
364   src/vlog_is_on.cc
365 )
366
367 if (HAVE_PTHREAD)
368   list (APPEND GLOG_SRCS src/signalhandler.cc)
369 endif (HAVE_PTHREAD)
370
371 if (WIN32)
372   list (APPEND GLOG_SRCS
373     src/windows/port.cc
374     src/windows/port.h
375   )
376 endif (WIN32)
377
378 add_compile_options ($<$<BOOL:${HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS}>:-Wno-unnamed-type-template-args>)
379
380 add_library (glog
381   ${GLOG_SRCS}
382 )
383
384 set_target_properties (glog PROPERTIES POSITION_INDEPENDENT_CODE ON)
385
386 if (UNWIND_LIBRARY)
387   target_link_libraries (glog PUBLIC ${UNWIND_LIBRARY})
388 endif (UNWIND_LIBRARY)
389
390 if (HAVE_PTHREAD)
391   target_link_libraries (glog PUBLIC ${CMAKE_THREAD_LIBS_INIT})
392 endif (HAVE_PTHREAD)
393
394 if (WIN32 AND HAVE_SNPRINTF)
395   set_property (SOURCE src/windows/port.cc APPEND PROPERTY COMPILE_DEFINITIONS
396     HAVE_SNPRINTF)
397 endif (WIN32 AND HAVE_SNPRINTF)
398
399 if (gflags_FOUND)
400   target_include_directories (glog PUBLIC $<BUILD_INTERFACE:${gflags_INCLUDE_DIR}>)
401   target_link_libraries (glog PUBLIC ${gflags_LIBRARIES})
402
403   if (NOT BUILD_SHARED_LIBS)
404     # Don't use __declspec(dllexport|dllimport) if this is a static build
405     targeT_compile_definitions (glog PUBLIC GFLAGS_DLL_DECLARE_FLAG= GFLAGS_DLL_DEFINE_FLAG=)
406   endif (NOT BUILD_SHARED_LIBS)
407 endif (gflags_FOUND)
408
409 set_target_properties (glog PROPERTIES VERSION ${GLOG_MAJOR_VERSION})
410 set_target_properties (glog PROPERTIES SOVERSION ${GLOG_VERSION})
411
412 if (WIN32)
413   target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES)
414 endif (WIN32)
415
416 set_target_properties (glog PROPERTIES PUBLIC_HEADER "${GLOG_PUBLIC_H}")
417
418 target_include_directories (glog BEFORE PUBLIC
419   "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
420   "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
421   "$<INSTALL_INTERFACE:include>"
422   PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
423   PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
424
425 if (WIN32)
426   target_include_directories (glog PUBLIC
427     "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/windows>"
428     PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/windows)
429 endif (WIN32)
430
431 set_target_properties (glog PROPERTIES DEFINE_SYMBOL LIBGLOG_EXPORTS)
432
433 if (NOT BUILD_SHARED_LIBS)
434   target_compile_definitions (glog PUBLIC GOOGLE_GLOG_DLL_DECL=)
435 else (NOT BUILD_SHARED_LIBS)
436   target_compile_definitions (glog PRIVATE GOOGLE_GLOG_IS_A_DLL=1)
437
438   if (HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
439     set (_EXPORT "__attribute__((visibility(\"default\")))")
440     set (_IMPORT "")
441   elseif (HAVE___DECLSPEC)
442     set (_EXPORT "__declspec(dllexport)")
443     set (_IMPORT "__declspec(dllimport)")
444   endif (HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
445
446   target_compile_definitions (glog PRIVATE
447     "GOOGLE_GLOG_DLL_DECL=${_EXPORT}")
448   target_compile_definitions (glog INTERFACE
449     "GOOGLE_GLOG_DLL_DECL=${_IMPORT}")
450   target_compile_definitions (glog INTERFACE
451     "GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS=${_IMPORT}")
452 endif (NOT BUILD_SHARED_LIBS)
453
454 if (HAVE_EXECINFO_H)
455   set (HAVE_STACKTRACE 1)
456 endif (HAVE_EXECINFO_H)
457
458 if (WIN32)
459   set (HAVE_STACKTRACE 1)
460   set (HAVE_SYMBOLIZE 1)
461 endif (WIN32)
462
463 if (UNIX OR (APPLE AND HAVE_DLADDR))
464   set (HAVE_SYMBOLIZE 1)
465 endif (UNIX OR (APPLE AND HAVE_DLADDR))
466
467 # Unit testing
468
469 if (BUILD_TESTING)
470   add_executable (logging_unittest
471     src/logging_unittest.cc
472   )
473
474   target_link_libraries (logging_unittest PRIVATE glog)
475
476   add_executable (stl_logging_unittest
477     src/stl_logging_unittest.cc
478   )
479
480   target_link_libraries (stl_logging_unittest PRIVATE glog)
481
482   if (HAVE_NO_DEPRECATED)
483     set_property (TARGET stl_logging_unittest APPEND PROPERTY COMPILE_OPTIONS
484       -Wno-deprecated)
485   endif (HAVE_NO_DEPRECATED)
486
487   if (HAVE_UNORDERED_MAP AND HAVE_UNORDERED_SET)
488     target_compile_definitions (stl_logging_unittest PRIVATE
489       GLOG_STL_LOGGING_FOR_UNORDERED)
490   endif (HAVE_UNORDERED_MAP AND HAVE_UNORDERED_SET)
491
492   if (HAVE_TR1_UNORDERED_MAP AND HAVE_TR1_UNORDERED_SET)
493     target_compile_definitions (stl_logging_unittest PRIVATE
494       GLOG_STL_LOGGING_FOR_TR1_UNORDERED)
495   endif (HAVE_TR1_UNORDERED_MAP AND HAVE_TR1_UNORDERED_SET)
496
497   if (HAVE_EXT_HASH_MAP AND HAVE_EXT_HASH_SET)
498     target_compile_definitions (stl_logging_unittest PRIVATE
499       GLOG_STL_LOGGING_FOR_EXT_HASH)
500   endif (HAVE_EXT_HASH_MAP AND HAVE_EXT_HASH_SET)
501
502   if (HAVE_EXT_SLIST)
503     target_compile_definitions (stl_logging_unittest PRIVATE
504       GLOG_STL_LOGGING_FOR_EXT_SLIST)
505   endif (HAVE_EXT_SLIST)
506
507   if (HAVE_SYMBOLIZE)
508     add_executable (symbolize_unittest
509       src/symbolize_unittest.cc
510     )
511
512     target_link_libraries (symbolize_unittest PRIVATE glog)
513   endif (HAVE_SYMBOLIZE)
514
515   add_executable (demangle_unittest
516     src/demangle_unittest.cc
517   )
518
519   target_link_libraries (demangle_unittest PRIVATE glog)
520
521   if (HAVE_STACKTRACE)
522     add_executable (stacktrace_unittest
523       src/stacktrace_unittest.cc
524     )
525
526     target_link_libraries (stacktrace_unittest PRIVATE glog)
527   endif (HAVE_STACKTRACE)
528
529   add_executable (utilities_unittest
530     src/utilities_unittest.cc
531   )
532
533   target_link_libraries (utilities_unittest PRIVATE glog)
534
535   if (HAVE_STACKTRACE AND HAVE_SYMBOLIZE)
536     add_executable (signalhandler_unittest
537       src/signalhandler_unittest.cc
538     )
539
540     target_link_libraries (signalhandler_unittest PRIVATE glog)
541   endif (HAVE_STACKTRACE AND HAVE_SYMBOLIZE)
542
543   add_test (NAME demangle COMMAND demangle_unittest)
544   add_test (NAME logging COMMAND logging_unittest)
545
546   if (TARGET signalhandler_unittest)
547     add_test (NAME signalhandler COMMAND signalhandler_unittest)
548   endif (TARGET signalhandler_unittest)
549
550   if (TARGET stacktrace_unittest)
551     add_test (NAME stacktrace COMMAND stacktrace_unittest)
552   endif (TARGET stacktrace_unittest)
553
554   add_test (NAME stl_logging COMMAND stl_logging_unittest)
555
556   if (TARGET symbolize_unittest)
557     add_test (NAME symbolize COMMAND symbolize_unittest)
558   endif (TARGET symbolize_unittest)
559 endif (BUILD_TESTING)
560
561 install (TARGETS glog
562   EXPORT glog-targets
563   RUNTIME DESTINATION bin
564   PUBLIC_HEADER DESTINATION include/glog
565   LIBRARY DESTINATION lib
566   ARCHIVE DESTINATION lib)
567
568 if (gflags_FOUND)
569   set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION})")
570 endif (gflags_FOUND)
571
572 configure_package_config_file (glog-config.cmake.in
573   ${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake
574   INSTALL_DESTINATION lib/cmake/glog
575   NO_CHECK_REQUIRED_COMPONENTS_MACRO)
576
577 write_basic_package_version_file (glog-config-version.cmake VERSION
578   ${GLOG_VERSION} COMPATIBILITY SameMajorVersion)
579
580 export (TARGETS glog NAMESPACE glog:: FILE glog-targets.cmake)
581 export (PACKAGE glog)
582
583 install (FILES
584   ${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake
585   ${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake
586   DESTINATION lib/cmake/glog)
587
588 install (EXPORT glog-targets NAMESPACE glog:: DESTINATION lib/cmake/glog)