X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=CMakeLists.txt;h=d581616537aad708c1c681be566ac37e5be8d134;hp=371529741739aa888d0abd38d3f02b7efe7d60d2;hb=614a2213b3d18c09b4fba87795fe5c9923acb085;hpb=c593d8eda8eea90818908fce46409b970ca1f540 diff --git a/CMakeLists.txt b/CMakeLists.txt index 37152974..d5816165 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,20 +16,24 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) project(${PACKAGE_NAME} CXX) -if (MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1920) - set(MSVC_IS_2017 ON) -elseif (MSVC_VERSION EQUAL 1900) - set(MSVC_IS_2017 OFF) -else() - message(FATAL_ERROR "This build script only supports building Folly on 64-bit Windows with Visual Studio 2015 or Visual Studio 2017. MSVC version '${MSVC_VERSION}' is not supported.") -endif() - -# Check architecture OS -if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8) - message(FATAL_ERROR "Folly requires a 64bit OS") -endif() -if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") - message(FATAL_ERROR "You should only be using CMake to build Folly if you are on Windows!") +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + # Check target architecture + if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + message(FATAL_ERROR "Folly requires a 64bit target architecture.") + endif() + + if (MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1920) + set(MSVC_IS_2017 ON) + elseif (MSVC_VERSION EQUAL 1900) + set(MSVC_IS_2017 OFF) + else() + message( + FATAL_ERROR + "This build script only supports building Folly on 64-bit Windows with " + "Visual Studio 2015 or Visual Studio 2017. " + "MSVC version '${MSVC_VERSION}' is not supported." + ) + endif() endif() set(FOLLY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/folly") @@ -38,51 +42,62 @@ set(FOLLY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/folly") find_package(PythonInterp REQUIRED) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/folly/build/EscapeTables.cpp - COMMAND ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_escape_tables.py" + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/folly/build + COMMAND + ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_escape_tables.py" + --install_dir ${CMAKE_CURRENT_BINARY_DIR}/folly/build DEPENDS ${FOLLY_DIR}/build/generate_escape_tables.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/folly/build/ COMMENT "Generating the escape tables..." VERBATIM ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/folly/build/FormatTables.cpp - COMMAND ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_format_tables.py" + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/folly/build + COMMAND + ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_format_tables.py" + --install_dir ${CMAKE_CURRENT_BINARY_DIR}/folly/build DEPENDS ${FOLLY_DIR}/build/generate_format_tables.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/folly/build/ COMMENT "Generating the format tables..." VERBATIM ) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/folly/build/GroupVarintTables.cpp" - COMMAND ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_varint_tables.py" + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/folly/build + COMMAND + ${PYTHON_EXECUTABLE} "${FOLLY_DIR}/build/generate_varint_tables.py" + --install_dir ${CMAKE_CURRENT_BINARY_DIR}/folly/build DEPENDS ${FOLLY_DIR}/build/generate_varint_tables.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/folly/build/ COMMENT "Generating the group varint tables..." VERBATIM ) include(folly-deps) # Find the required packages -if (LIBPTHREAD_FOUND) - set(FOLLY_HAVE_PTHREAD ON) + +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + include(FollyCompilerMSVC) +else() + include(FollyCompilerUnix) endif() +include(FollyFunctions) + +include(FollyConfigChecks) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CMake/folly-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/folly/folly-config.h ) -include(FollyCompiler) -include(FollyFunctions) - # Main folly library files auto_sources(files "*.cpp" "RECURSE" "${FOLLY_DIR}") auto_sources(hfiles "*.h" "RECURSE" "${FOLLY_DIR}") -# No need for tests or benchmarks, and we can't build most experimental stuff. +# Exclude tests, benchmarks, and other standalone utility executables from the +# library sources. Test sources are listed separately below. REMOVE_MATCHES_FROM_LISTS(files hfiles MATCHES "/build/" - "/experimental/exception_tracer/" "/experimental/hazptr/bench/" "/experimental/hazptr/example/" "/experimental/logging/example/" - "/experimental/symbolizer/" "/futures/exercises/" "/test/" "/tools/" @@ -92,30 +107,60 @@ REMOVE_MATCHES_FROM_LISTS(files hfiles "/Benchmark.cpp$" ) list(REMOVE_ITEM files - ${FOLLY_DIR}/Poly.cpp - ${FOLLY_DIR}/Subprocess.cpp - ${FOLLY_DIR}/SingletonStackTrace.cpp ${FOLLY_DIR}/experimental/JSONSchemaTester.cpp - ${FOLLY_DIR}/experimental/RCUUtils.cpp - ${FOLLY_DIR}/experimental/io/AsyncIO.cpp ${FOLLY_DIR}/experimental/io/HugePageUtil.cpp + ${FOLLY_DIR}/experimental/symbolizer/ElfUtil.cpp ${FOLLY_DIR}/futures/test/Benchmark.cpp ) list(REMOVE_ITEM hfiles - ${FOLLY_DIR}/Fingerprint.h - ${FOLLY_DIR}/Poly.h - ${FOLLY_DIR}/Poly-inl.h - ${FOLLY_DIR}/detail/PolyDetail.h - ${FOLLY_DIR}/detail/TypeList.h ${FOLLY_DIR}/detail/SlowFingerprint.h ${FOLLY_DIR}/detail/FingerprintPolynomial.h - ${FOLLY_DIR}/experimental/RCURefCount.h - ${FOLLY_DIR}/experimental/RCUUtils.h - ${FOLLY_DIR}/experimental/io/AsyncIO.h - ${FOLLY_DIR}/poly/Nullable.h - ${FOLLY_DIR}/poly/Regular.h ) +# Exclude specific sources if we do not have third-party libraries +# required to build them. +if (NOT FOLLY_USE_SYMBOLIZER) + REMOVE_MATCHES_FROM_LISTS(files hfiles + MATCHES + "/experimental/exception_tracer/" + "/experimental/symbolizer/" + ) + list(REMOVE_ITEM files + ${FOLLY_DIR}/SingletonStackTrace.cpp + ) +endif() +if (NOT ${LIBURCU_FOUND}) + list(REMOVE_ITEM files + ${FOLLY_DIR}/experimental/RCUUtils.cpp + ) + list(REMOVE_ITEM hfiles + ${FOLLY_DIR}/experimental/RCURefCount.h + ${FOLLY_DIR}/experimental/RCUUtils.h + ) +endif() +if (NOT ${LIBAIO_FOUND}) + list(REMOVE_ITEM files + ${FOLLY_DIR}/experimental/io/AsyncIO.cpp + ) + list(REMOVE_ITEM hfiles + ${FOLLY_DIR}/experimental/io/AsyncIO.h + ) +endif() +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + list(REMOVE_ITEM files + ${FOLLY_DIR}/Poly.cpp + ${FOLLY_DIR}/Subprocess.cpp + ) + list(REMOVE_ITEM hfiles + ${FOLLY_DIR}/Poly.h + ${FOLLY_DIR}/Poly-inl.h + ${FOLLY_DIR}/detail/PolyDetail.h + ${FOLLY_DIR}/detail/TypeList.h + ${FOLLY_DIR}/poly/Nullable.h + ${FOLLY_DIR}/poly/Regular.h + ) +endif() + add_library(folly_base OBJECT ${files} ${hfiles} ${CMAKE_CURRENT_BINARY_DIR}/folly/folly-config.h @@ -135,45 +180,32 @@ source_group("folly\\build" FILES ${CMAKE_CURRENT_BINARY_DIR}/folly/build/GroupVarintTables.cpp ) -set(FOLLY_SHINY_DEPENDENCIES - Boost::chrono - Boost::context - Boost::date_time - Boost::filesystem - Boost::program_options - Boost::regex - Boost::system - OpenSSL::SSL - OpenSSL::Crypto -) +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(FOLLY_LINK_LIBRARIES + ${FOLLY_LINK_LIBRARIES} + Iphlpapi.lib + Ws2_32.lib + ) +endif() set(FOLLY_LINK_LIBRARIES - ${DOUBLE_CONVERSION_LIBRARY} - ${LIBEVENT_LIB} - ${LIBGFLAGS_LIBRARY} - ${LIBGLOG_LIBRARY} - Iphlpapi.lib - Ws2_32.lib - + ${FOLLY_LINK_LIBRARIES} ${FOLLY_SHINY_DEPENDENCIES} ) target_include_directories(folly_base PUBLIC - ${DOUBLE_CONVERSION_INCLUDE_DIR} - ${LIBGFLAGS_INCLUDE_DIR} - ${LIBGLOG_INCLUDE_DIR} - ${LIBEVENT_INCLUDE_DIR} + ${FOLLY_INCLUDE_DIRECTORIES} $ ) foreach (LIB ${FOLLY_SHINY_DEPENDENCIES}) target_include_directories(folly_base PUBLIC $) + target_compile_definitions(folly_base PUBLIC $) endforeach() if (FOLLY_HAVE_PTHREAD) target_include_directories(folly_base PUBLIC ${LIBPTHREAD_INCLUDE_DIRS}) - list(APPEND FOLLY_LINK_LIBRARIES ${LIBPTHREAD_LIBRARIES}) endif() # Now to generate the fingerprint tables @@ -191,9 +223,12 @@ source_group("" FILES ${FOLLY_DIR}/build/GenerateFingerprintTables.cpp) # Compile the fingerprint tables. add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/folly/build/FingerprintTables.cpp - COMMAND GenerateFingerprintTables + COMMAND + ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/folly/build + COMMAND + GenerateFingerprintTables + --install_dir ${CMAKE_CURRENT_BINARY_DIR}/folly/build DEPENDS GenerateFingerprintTables - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/folly/build/ COMMENT "Generating the fingerprint tables..." ) add_library(folly_fingerprint STATIC @@ -257,13 +292,17 @@ option(BUILD_HANGING_TESTS "If enabled, compile tests that are known to hang." O option(BUILD_SLOW_TESTS "If enabled, compile tests that take a while to run in debug mode." OFF) if (BUILD_TESTS) find_package(GMock MODULE REQUIRED) + include(GoogleTest OPTIONAL RESULT_VARIABLE HAVE_CMAKE_GTEST) + enable_testing() add_library(folly_test_support + ${FOLLY_DIR}/test/common/TestMain.cpp ${FOLLY_DIR}/test/DeterministicSchedule.cpp ${FOLLY_DIR}/test/DeterministicSchedule.h ${FOLLY_DIR}/test/SingletonTestStructs.cpp ${FOLLY_DIR}/test/SocketAddressTestHelper.cpp ${FOLLY_DIR}/test/SocketAddressTestHelper.h + ${FOLLY_DIR}/experimental/logging/test/TestLogHandler.cpp ${FOLLY_DIR}/experimental/logging/test/TestLogHandler.h ${FOLLY_DIR}/futures/test/TestExecutor.cpp ${FOLLY_DIR}/futures/test/TestExecutor.h @@ -302,12 +341,19 @@ if (BUILD_TESTS) apply_folly_compile_options_to_target(folly_test_support) folly_define_tests( + DIRECTORY chrono/test/ + TEST chrono_conv_test SOURCES ConvTest.cpp + DIRECTORY compression/test/ - TEST compression_test SOURCES CompressionTest.cpp + TEST compression_test SLOW SOURCES CompressionTest.cpp DIRECTORY container/test/ + TEST access_test SOURCES AccessTest.cpp TEST array_test SOURCES ArrayTest.cpp - TEST enumerate_test SOURCES EnumerateTest.cpp + TEST bit_iterator_test SOURCES BitIteratorTest.cpp + # TODO: CMake's gtest_add_tests() function currently chokes on + # EnumerateTest.cpp since it uses macros to define tests. + #TEST enumerate_test SOURCES EnumerateTest.cpp TEST evicting_cache_map_test SOURCES EvictingCacheMapTest.cpp TEST foreach_test SOURCES ForeachTest.cpp TEST merge_test SOURCES MergeTest.cpp @@ -325,6 +371,7 @@ if (BUILD_TESTS) TEST serial_executor_test SOURCES SerialExecutorTest.cpp TEST thread_pool_executor_test SOURCES ThreadPoolExecutorTest.cpp TEST threaded_executor_test SOURCES ThreadedExecutorTest.cpp + TEST timed_drivable_executor_test SOURCES TimedDrivableExecutorTest.cpp DIRECTORY executors/task_queue/test/ TEST unbounded_blocking_queue_test SOURCES UnboundedBlockingQueueTest.cpp @@ -356,6 +403,9 @@ if (BUILD_TESTS) DIRECTORY experimental/logging/test/ TEST async_file_writer_test SOURCES AsyncFileWriterTest.cpp + TEST config_parser_test SOURCES ConfigParserTest.cpp + TEST config_update_test SOURCES ConfigUpdateTest.cpp + TEST file_handler_factory_test SOURCES FileHandlerFactoryTest.cpp TEST glog_formatter_test SOURCES GlogFormatterTest.cpp TEST immediate_file_writer_test SOURCES ImmediateFileWriterTest.cpp TEST log_category_test SOURCES LogCategoryTest.cpp @@ -484,6 +534,11 @@ if (BUILD_TESTS) DIRECTORY io/async/ssl/test/ TEST ssl_errors_test SOURCES SSLErrorsTest.cpp + DIRECTORY lang/test/ + TEST bits_test SOURCES BitsTest.cpp + TEST cold_class_test SOURCES ColdClassTest.cpp + TEST safe_assert_test SOURCES SafeAssertTest.cpp + DIRECTORY memory/test/ TEST arena_test SOURCES ArenaTest.cpp TEST thread_cached_arena_test SOURCES ThreadCachedArenaTest.cpp @@ -501,11 +556,13 @@ if (BUILD_TESTS) DIRECTORY stats/test/ TEST histogram_test SOURCES HistogramTest.cpp TEST timeseries_histogram_test SOURCES TimeseriesHistogramTest.cpp - TEST timeseries_test SOURCES TimeseriesTest.cpp + TEST timeseries_test SOURCES TimeSeriesTest.cpp DIRECTORY synchronization/test/ + TEST baton_test SOURCES BatonTest.cpp TEST call_once_test SOURCES CallOnceTest.cpp TEST lifo_sem_test SOURCES LifoSemTests.cpp + TEST rw_spin_lock_test SOURCES RWSpinLockTest.cpp DIRECTORY system/test/ TEST memory_mapping_test SOURCES MemoryMappingTest.cpp @@ -514,6 +571,9 @@ if (BUILD_TESTS) TEST thread_id_test SOURCES ThreadIdTest.cpp TEST thread_name_test SOURCES ThreadNameTest.cpp + DIRECTORY synchronization/test/ + TEST atomic_struct_test SOURCES AtomicStructTest.cpp + DIRECTORY test/ TEST ahm_int_stress_test SOURCES AHMIntStressTest.cpp TEST arena_smartptr_test SOURCES ArenaSmartPtrTest.cpp @@ -523,15 +583,10 @@ if (BUILD_TESTS) TEST atomic_hash_map_test HANGING SOURCES AtomicHashMapTest.cpp TEST atomic_linked_list_test SOURCES AtomicLinkedListTest.cpp - TEST atomic_struct_test SOURCES AtomicStructTest.cpp TEST atomic_unordered_map_test SOURCES AtomicUnorderedMapTest.cpp - TEST baton_test SOURCES BatonTest.cpp - TEST bit_iterator_test SOURCES BitIteratorTest.cpp - TEST bits_test SOURCES BitsTest.cpp TEST cacheline_padded_test SOURCES CachelinePaddedTest.cpp TEST clock_gettime_wrappers_test SOURCES ClockGettimeWrappersTest.cpp TEST concurrent_skip_list_test SOURCES ConcurrentSkipListTest.cpp - TEST container_traits_test SOURCES ContainerTraitsTest.cpp TEST conv_test SOURCES ConvTest.cpp TEST cpu_id_test SOURCES CpuIdTest.cpp TEST demangle_test SOURCES DemangleTest.cpp @@ -549,7 +604,7 @@ if (BUILD_TESTS) #TEST file_lock_test SOURCES FileLockTest.cpp TEST file_util_test HANGING SOURCES FileUtilTest.cpp - TEST fingerprint_test SOURCES FingerprintTest.cpp + # TEST fingerprint_test SOURCES FingerprintTest.cpp TEST format_other_test SOURCES FormatOtherTest.cpp TEST format_test SOURCES FormatTest.cpp TEST function_scheduler_test SOURCES FunctionSchedulerTest.cpp @@ -595,17 +650,15 @@ if (BUILD_TESTS) TEST portability_test SOURCES PortabilityTest.cpp TEST producer_consumer_queue_test SLOW SOURCES ProducerConsumerQueueTest.cpp - TEST r_w_spin_lock_test SOURCES RWSpinLockTest.cpp TEST random_test SOURCES RandomTest.cpp TEST range_test SOURCES RangeTest.cpp - TEST safe_assert_test SOURCES SafeAssertTest.cpp TEST scope_guard_test SOURCES ScopeGuardTest.cpp # Heavily dependent on drand and srand48 #TEST shared_mutex_test SOURCES SharedMutexTest.cpp - TEST singleton_test SOURCES SingletonTest.cpp + # SingletonTest requires Subprocess + #TEST singleton_test SOURCES SingletonTest.cpp TEST singleton_test_global SOURCES SingletonTestGlobal.cpp TEST singleton_thread_local_test SOURCES SingletonThreadLocalTest.cpp - TEST singletonvault_c_test SOURCES SingletonVaultCTest.cpp TEST small_vector_test SOURCES small_vector_test.cpp TEST sorted_vector_types_test SOURCES sorted_vector_test.cpp TEST string_test SOURCES StringTest.cpp