X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=CMakeLists.txt;h=9f8573bfabaa92c2cd81fb56abac3ee0c127ef79;hp=d390f06183f75e9a1b80b669a7844ecfb837388f;hb=6c511999f92066ed84778bca4491c8d139a3195d;hpb=b3061cbef59895199c3b98aa4757dc3379a6af06 diff --git a/CMakeLists.txt b/CMakeLists.txt index d390f061..9f8573bf 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,20 +16,30 @@ 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) +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() 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!") + 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") @@ -38,23 +48,32 @@ 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 ) @@ -62,14 +81,20 @@ include(folly-deps) # Find the required packages if (LIBPTHREAD_FOUND) set(FOLLY_HAVE_PTHREAD ON) endif() + +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}") @@ -177,11 +202,21 @@ else() endif() +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 ${FOLLY_LINK_LIBRARIES} - Iphlpapi.lib - Ws2_32.lib - ${FOLLY_SHINY_DEPENDENCIES} ) @@ -216,9 +251,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 @@ -289,6 +327,7 @@ if (BUILD_TESTS) ${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 @@ -327,11 +366,16 @@ 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 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 TEST evicting_cache_map_test SOURCES EvictingCacheMapTest.cpp TEST foreach_test SOURCES ForeachTest.cpp @@ -381,6 +425,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 @@ -509,6 +556,10 @@ 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 + DIRECTORY memory/test/ TEST arena_test SOURCES ArenaTest.cpp TEST thread_cached_arena_test SOURCES ThreadCachedArenaTest.cpp @@ -529,8 +580,10 @@ if (BUILD_TESTS) 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 @@ -550,9 +603,6 @@ if (BUILD_TESTS) 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 @@ -620,7 +670,6 @@ 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