make `usingJEMalloc()` a constexpr when USE_JEMALLOC is defined
[folly.git] / CMakeLists.txt
index 371529741739aa888d0abd38d3f02b7efe7d60d2..ec5a985cc91ccfc00c2cf04fd069d186b1a719dc 100755 (executable)
@@ -24,12 +24,12 @@ 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
+# Check target architecture
 if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
-  message(FATAL_ERROR "Folly requires a 64bit OS")
+  message(FATAL_ERROR "Folly requires a 64bit target architecture.")
 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 the makefile.")
 endif()
 
 set(FOLLY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/folly")
@@ -149,9 +149,36 @@ set(FOLLY_SHINY_DEPENDENCIES
 
 set(FOLLY_LINK_LIBRARIES
   ${DOUBLE_CONVERSION_LIBRARY}
-  ${LIBEVENT_LIB}
-  ${LIBGFLAGS_LIBRARY}
-  ${LIBGLOG_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()
+
+
+set(FOLLY_LINK_LIBRARIES
+  ${FOLLY_LINK_LIBRARIES}
   Iphlpapi.lib
   Ws2_32.lib
 
@@ -160,15 +187,13 @@ set(FOLLY_LINK_LIBRARIES
 
 target_include_directories(folly_base
   PUBLIC
-    ${DOUBLE_CONVERSION_INCLUDE_DIR}
-    ${LIBGFLAGS_INCLUDE_DIR}
-    ${LIBGLOG_INCLUDE_DIR}
-    ${LIBEVENT_INCLUDE_DIR}
+    ${FOLLY_INCLUDE_DIRECTORIES}
     $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
 )
 
 foreach (LIB ${FOLLY_SHINY_DEPENDENCIES})
   target_include_directories(folly_base PUBLIC $<TARGET_PROPERTY:${LIB},INCLUDE_DIRECTORIES>)
+  target_compile_definitions(folly_base PUBLIC $<TARGET_PROPERTY:${LIB},INTERFACE_COMPILE_DEFINITIONS>)
 endforeach()
 
 if (FOLLY_HAVE_PTHREAD)
@@ -302,10 +327,14 @@ 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 enumerate_test SOURCES EnumerateTest.cpp
       TEST evicting_cache_map_test SOURCES EvictingCacheMapTest.cpp
@@ -356,6 +385,7 @@ if (BUILD_TESTS)
 
     DIRECTORY experimental/logging/test/
       TEST async_file_writer_test SOURCES AsyncFileWriterTest.cpp
+      TEST config_parser_test SOURCES ConfigParserTest.cpp
       TEST glog_formatter_test SOURCES GlogFormatterTest.cpp
       TEST immediate_file_writer_test SOURCES ImmediateFileWriterTest.cpp
       TEST log_category_test SOURCES LogCategoryTest.cpp