X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=CMakeLists.txt;h=d581616537aad708c1c681be566ac37e5be8d134;hp=dee718b87439bd541d0929041bae6c2e627e5bba;hb=3d02424285435ed6b70d7207d37304a28c5e5707;hpb=e96129da65d3ad2b20aae5a2bf2d22d2d72b8feb diff --git a/CMakeLists.txt b/CMakeLists.txt index dee718b8..d5816165 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) project(${PACKAGE_NAME} CXX) -if("${CMAKE_SYSTEM_NAME}" STREQUAL "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.") @@ -34,12 +34,6 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") "MSVC version '${MSVC_VERSION}' is not supported." ) endif() -else() - message( - FATAL_ERROR - "The CMake build should only be used on Windows. " - "For every other platform, use autoconf." - ) endif() set(FOLLY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/folly") @@ -78,11 +72,8 @@ add_custom_command( ) include(folly-deps) # Find the required packages -if (LIBPTHREAD_FOUND) - set(FOLLY_HAVE_PTHREAD ON) -endif() -if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") include(FollyCompilerMSVC) else() include(FollyCompilerUnix) @@ -99,15 +90,14 @@ configure_file( 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/" @@ -117,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 @@ -160,59 +180,12 @@ 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 -) - -set(FOLLY_LINK_LIBRARIES - ${DOUBLE_CONVERSION_LIBRARY} -) - -set(FOLLY_INCLUDE_DIRECTORIES - ${DOUBLE_CONVERSION_INCLUDE_DIR} -) - -if(TARGET gflags) - set(FOLLY_SHINY_DEPENDENCIES ${FOLLY_SHINY_DEPENDENCIES} gflags) -else() - set(FOLLY_LINK_LIBRARIES ${FOLLY_LINK_LIBRARIES} ${LIBGFLAGS_LIBRARY}) - set(FOLLY_INCLUDE_DIRECTORIES ${FOLLY_INCLUDE_DIRECTORIES} ${LIBGFLAGS_INCLUDE_DIR}) -endif() - -if(TARGET glog::glog) - set(FOLLY_SHINY_DEPENDENCIES ${FOLLY_SHINY_DEPENDENCIES} glog::glog) -else() - set(FOLLY_LINK_LIBRARIES ${FOLLY_LINK_LIBRARIES} ${LIBGLOG_LIBRARY}) - set(FOLLY_INCLUDE_DIRECTORIES ${FOLLY_INCLUDE_DIRECTORIES} ${LIBGLOG_INCLUDE_DIR}) -endif() - -if(TARGET event) - set(FOLLY_SHINY_DEPENDENCIES ${FOLLY_SHINY_DEPENDENCIES} event) -else() - set(FOLLY_LINK_LIBRARIES ${FOLLY_LINK_LIBRARIES} ${LIBEVENT_LIB}) - set(FOLLY_INCLUDE_DIRECTORIES ${FOLLY_INCLUDE_DIRECTORIES} ${LIBEVENT_INCLUDE_DIR}) -endif() - - -if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(FOLLY_LINK_LIBRARIES ${FOLLY_LINK_LIBRARIES} Iphlpapi.lib Ws2_32.lib ) -else() - set(FOLLY_LINK_LIBRARIES - ${FOLLY_LINK_LIBRARIES} - dl - ) endif() set(FOLLY_LINK_LIBRARIES @@ -233,7 +206,6 @@ 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 @@ -320,8 +292,11 @@ 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 @@ -370,13 +345,15 @@ if (BUILD_TESTS) 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 bit_iterator_test SOURCES BitIteratorTest.cpp - TEST enumerate_test SOURCES EnumerateTest.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 @@ -394,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