Fix build with Ninja generator
[folly.git] / CMakeLists.txt
index 367014648760a9f887e069620cd18f8563cdce69..97f9bcf97959e0a786cf6d6d24626e59ba00ce9b 100755 (executable)
@@ -7,8 +7,13 @@ cmake_minimum_required(VERSION 3.4.0 FATAL_ERROR)
 # the alternatives are far, far worse.
 if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio 15( 2017)? Win64")
   set(CMAKE_GENERATOR_TOOLSET "v141</PlatformToolset></PropertyGroup><ItemDefinitionGroup Condition=\"'$(ProjectName)'=='folly'\"><ProjectReference><LinkLibraryDependencies>true</LinkLibraryDependencies></ProjectReference></ItemDefinitionGroup><PropertyGroup><PlatformToolset>v141")
+  set(MSVC_IS_2017 ON)
 elseif ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 14 2015 Win64")
   set(CMAKE_GENERATOR_TOOLSET "v140</PlatformToolset></PropertyGroup><ItemDefinitionGroup Condition=\"'$(ProjectName)'=='folly'\"><ProjectReference><LinkLibraryDependencies>true</LinkLibraryDependencies></ProjectReference></ItemDefinitionGroup><PropertyGroup><PlatformToolset>v140")
+  set(MSVC_IS_2017 OFF)
+elseif ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
+  message("Folly is being built with Ninja, so assuming VS 2017 is being used.")
+  set(MSVC_IS_2017 ON)
 else()
   message(FATAL_ERROR "This build script only supports building Folly on 64-bit Windows with Visual Studio 2015 or Visual Studio 2017.")
 endif()
@@ -261,6 +266,10 @@ if (BUILD_TESTS)
     ${FOLLY_DIR}/io/async/test/UndelayedDestruction.h
     ${FOLLY_DIR}/io/async/test/Util.h
   )
+  target_compile_definitions(folly_test_support
+    PUBLIC
+      ${LIBGMOCK_DEFINES}
+  )
   target_include_directories(folly_test_support
     PUBLIC
       ${LIBGMOCK_INCLUDE_DIR}