@@ -86,6 +86,8 @@ option ("USE_LITE_METADATA" "Use lite metadata" "OFF")
8686option ("USE_RE2" "Use RE2" "OFF" )
8787option ("USE_STD_MAP" "Force the use of std::map" "OFF" )
8888option ("BUILD_STATIC_LIB" "Build static libraries" "ON" )
89+ option ("USE_STDMUTEX" "Use C++ 2011 std::mutex for multi-threading" "OFF" )
90+ option ("USE_POSIX_THREAD" "Use Posix api for multi-threading" "OFF" )
8991
9092if (${USE_ALTERNATE_FORMATS} STREQUAL "ON" )
9193 add_definitions ("-DI18N_PHONENUMBERS_USE_ALTERNATE_FORMATS" )
@@ -104,6 +106,19 @@ if (${USE_BOOST} STREQUAL "ON")
104106 include_directories (${Boost_INCLUDE_DIRS} )
105107endif ()
106108
109+ if (${USE_STDMUTEX} STREQUAL "ON" )
110+ add_definitions ("-DI18N_PHONENUMBERS_USE_STDMUTEX" )
111+ endif ()
112+
113+ if (${USE_POSIX_THREAD} STREQUAL "ON" )
114+ add_definitions ("-DI18N_PHONENUMBERS_HAVE_POSIX_THREAD" )
115+ find_package (Threads REQUIRED )
116+ endif ()
117+
118+ if (${USE_BOOST} STREQUAL "OFF" AND ${USE_STDMUTEX} STREQUAL "OFF" )
119+ find_package (Threads )
120+ endif ()
121+
107122find_or_build_gtest ()
108123
109124if (${USE_RE2} STREQUAL "ON" )
@@ -423,6 +438,15 @@ if (${USE_RE2} STREQUAL "ON")
423438 list (APPEND LIBRARY_DEPS ${RE2_LIB} )
424439endif ()
425440
441+ if (${USE_POSIX_THREAD} STREQUAL "ON" OR ((APPLE OR UNIX ) AND ${USE_BOOST} STREQUAL "OFF" AND ${USE_STDMUTEX} STREQUAL "OFF" ))
442+ if (CMAKE_USE_PTHREADS_INIT)
443+ list (APPEND CMAKE_C_FLAGS "-pthread" )
444+ endif ()
445+ if (CMAKE_THREAD_LIBS_INIT)
446+ list (APPEND LIBRARY_DEPS ${CMAKE_THREAD_LIBS_INIT} )
447+ endif ()
448+ endif ()
449+
426450if (APPLE )
427451 list (APPEND COMMON_DEPS ${COREFOUNDATION_LIB} ${FOUNDATION_LIB} )
428452endif ()
@@ -579,13 +603,22 @@ install (
579603install (FILES
580604 "src/phonenumbers/base/memory/scoped_ptr.h"
581605 "src/phonenumbers/base/memory/singleton.h"
606+ "src/phonenumbers/base/memory/singleton_boost.h"
582607 "src/phonenumbers/base/memory/singleton_posix.h"
608+ "src/phonenumbers/base/memory/singleton_stdmutex.h"
609+ "src/phonenumbers/base/memory/singleton_unsafe.h"
610+ "src/phonenumbers/base/memory/singleton_win32.h"
583611 DESTINATION include/phonenumbers/base/memory/
584612)
585613
586- install (FILES "src/phonenumbers/base/synchronization/lock.h"
587- "src/phonenumbers/base/synchronization/lock_posix.h"
588- DESTINATION include/phonenumbers/base/synchronization/)
614+ install (FILES
615+ "src/phonenumbers/base/synchronization/lock.h"
616+ "src/phonenumbers/base/synchronization/lock_boost.h"
617+ "src/phonenumbers/base/synchronization/lock_posix.h"
618+ "src/phonenumbers/base/synchronization/lock_stdmutex.h"
619+ "src/phonenumbers/base/synchronization/lock_unsafe.h"
620+ "src/phonenumbers/base/synchronization/lock_win32.h"
621+ DESTINATION include/phonenumbers/base/synchronization/)
589622
590623set (LIBDIR ${CMAKE_INSTALL_LIBDIR} )
591624
0 commit comments