cmake: fix the test builds
[folly.git] / CMakeLists.txt
index f1446753b312592d457bad19c4a03db7785f1356..dee718b87439bd541d0929041bae6c2e627e5bba 100755 (executable)
@@ -16,12 +16,12 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 
 project(${PACKAGE_NAME} CXX)
 
-# Check target architecture
-if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
-  message(FATAL_ERROR "Folly requires a 64bit target architecture.")
-endif()
-
 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)
@@ -81,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}")
@@ -196,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}
 )
 
@@ -543,6 +559,7 @@ if (BUILD_TESTS)
     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
@@ -561,7 +578,7 @@ 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
@@ -576,6 +593,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
@@ -585,12 +605,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 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
@@ -608,7 +626,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
@@ -656,14 +674,13 @@ if (BUILD_TESTS)
         SOURCES ProducerConsumerQueueTest.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