X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=CMakeLists.txt;h=573970232975c54a5d3395666d2f35c05f50743d;hb=028d37889a1e80e8a07da1b8945ac706259e5fd8;hp=908daee1a0d1bbebc3c43a9b232fe9fca7b35bef;hpb=b3dea50f3302a21652b31aee8ce0af6a15aeb255;p=platform%2Fupstream%2Fglog.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 908daee..5739702 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,13 +8,13 @@ if (POLICY CMP0063) cmake_policy (SET CMP0063 NEW) endif (POLICY CMP0063) -project (google-glog) +project (glog) enable_testing () set (GLOG_MAJOR_VERSION 0) set (GLOG_MINOR_VERSION 3) -set (GLOG_PATCH_VERSION 4) +set (GLOG_PATCH_VERSION 5) set (GLOG_VERSION ${GLOG_MAJOR_VERSION}.${GLOG_MINOR_VERSION}.${GLOG_PATCH_VERSION}) @@ -28,6 +28,7 @@ set (CPACK_PACKAGE_VERSION ${GLOG_VERSION}) option (WITH_GFLAGS "Use gflags" ON) option (WITH_THREADS "Enable multithreading support" ON) +option (WITH_TLS "Enable Thread Local Storage (TLS) support" ON) list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -47,10 +48,11 @@ include (CTest) include (DetermineGflagsNamespace) include (GNUInstallDirs) +set (CMAKE_DEBUG_POSTFIX d) set (CMAKE_THREAD_PREFER_PTHREAD 1) if (WITH_GFLAGS) - find_package (gflags) + find_package (gflags 2.2.0) if (gflags_FOUND) set (HAVE_LIB_GFLAGS 1) @@ -83,6 +85,7 @@ check_include_file (syslog.h HAVE_SYSLOG_H) check_include_file (ucontext.h HAVE_UCONTEXT_H) check_include_file (unistd.h HAVE_UNISTD_H) check_include_file (unwind.h HAVE_UNWIND_H) +check_include_file (pwd.h HAVE_PWD_H) check_include_file_cxx ("ext/hash_map" HAVE_EXT_HASH_MAP) check_include_file_cxx ("ext/hash_set" HAVE_EXT_HASH_SET) @@ -191,6 +194,32 @@ using namespace Outer::Inner;; int main() { return i; } " HAVE_NAMESPACES) +check_cxx_source_compiles (" +__thread int tls; +int main() { } +" HAVE_GCC_TLS) + +check_cxx_source_compiles (" +__declspec(thread) int tls; +int main() { } +" HAVE_MSVC_TLS) + +check_cxx_source_compiles (" +thread_local int tls; +int main() { } +" HAVE_CXX11_TLS) + +if (WITH_TLS) + # Cygwin does not support the thread attribute. Don't bother. + if (HAVE_GCC_TLS) + set (GLOG_THREAD_LOCAL_STORAGE "__thread") + elseif (HAVE_MSVC_TLS) + set (GLOG_THREAD_LOCAL_STORAGE "__declspec(thread)") + elseif (HAVE_CXX11_TLS) + set (GLOG_THREAD_LOCAL_STORAGE thread_local) + endif (HAVE_GCC_TLS) +endif (WITH_TLS) + set (_PC_FIELDS "gregs[REG_PC]" "gregs[REG_EIP]" @@ -341,7 +370,6 @@ set (CMAKE_CXX_VISIBILITY_PRESET default) set (CMAKE_VISIBILITY_INLINES_HIDDEN 1) set (GLOG_PUBLIC_H - ${CMAKE_CURRENT_BINARY_DIR}/config.h ${CMAKE_CURRENT_BINARY_DIR}/glog/logging.h ${CMAKE_CURRENT_BINARY_DIR}/glog/raw_logging.h ${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h @@ -365,9 +393,9 @@ set (GLOG_SRCS src/vlog_is_on.cc ) -if (HAVE_PTHREAD) +if (HAVE_PTHREAD OR WIN32) list (APPEND GLOG_SRCS src/signalhandler.cc) -endif (HAVE_PTHREAD) +endif (HAVE_PTHREAD OR WIN32) if (WIN32) list (APPEND GLOG_SRCS @@ -398,8 +426,7 @@ if (WIN32 AND HAVE_SNPRINTF) endif (WIN32 AND HAVE_SNPRINTF) if (gflags_FOUND) - target_include_directories (glog PUBLIC $) - target_link_libraries (glog PUBLIC ${gflags_LIBRARIES}) + target_link_libraries (glog PUBLIC gflags) if (NOT BUILD_SHARED_LIBS) # Don't use __declspec(dllexport|dllimport) if this is a static build @@ -461,6 +488,11 @@ if (HAVE_EXECINFO_H) set (HAVE_STACKTRACE 1) endif (HAVE_EXECINFO_H) +if (WIN32) + set (HAVE_STACKTRACE 1) + set (HAVE_SYMBOLIZE 1) +endif (WIN32) + if (UNIX OR (APPLE AND HAVE_DLADDR)) set (HAVE_SYMBOLIZE 1) endif (UNIX OR (APPLE AND HAVE_DLADDR)) @@ -566,8 +598,19 @@ install (TARGETS glog LIBRARY DESTINATION ${_glog_CMake_LIBDIR} ARCHIVE DESTINATION ${_glog_CMake_LIBDIR}) +set (glog_POLICY_VERSION 3.0) + if (gflags_FOUND) - set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION})") + # Ensure clients locate only the package config and not third party find + # modules having the same name. This avoid cmake_policy PUSH/POP errors. + if (CMAKE_VERSION VERSION_LESS 3.9) + set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION})") + else (CMAKE_VERSION VERSION_LESS 3.9) + # Passing additional find_package arguments to find_dependency is possible + # starting with CMake 3.9. + set (glog_POLICY_VERSION 3.9) + set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION} NO_MODULE)") + endif (CMAKE_VERSION VERSION_LESS 3.9) endif (gflags_FOUND) configure_package_config_file (glog-config.cmake.in