Fix a couple of issues with the CMake script
authorChristopher Dykes <cdykes@fb.com>
Wed, 3 May 2017 16:28:45 +0000 (09:28 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 3 May 2017 16:37:24 +0000 (09:37 -0700)
Summary:
The first issue is that I was missing a `G` in `LIBGFLAGS_INCLUDE_DIR` meaning that it always claimed it couldn't find gflags even though it did, and worked just fine anyways.
The second issue is that it was passing `/permissive-` to MSVC 2015 builds, even though MSVC 2015 doesn't support the permissive flag.

Reviewed By: yfeldblum

Differential Revision: D4988813

fbshipit-source-id: f1ea009226baee54032409ce7add3c41f1fe7a19

CMake/FindGFlags.cmake
CMake/FollyCompiler.cmake
CMakeLists.txt

index 167bdd4..3217c6f 100755 (executable)
@@ -18,6 +18,6 @@ FIND_LIBRARY(LIBGFLAGS_LIBRARY gflags)
 # handle the QUIETLY and REQUIRED arguments and set LIBGFLAGS_FOUND to TRUE if
 # all listed variables are TRUE
 INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGFLAGS DEFAULT_MSG LIBGFLAGS_LIBRARY LIBFLAGS_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGFLAGS DEFAULT_MSG LIBGFLAGS_LIBRARY LIBGFLAGS_INCLUDE_DIR)
 
 MARK_AS_ADVANCED(LIBGFLAGS_LIBRARY LIBGFLAGS_INCLUDE_DIR)
index e01f656..29d2ca2 100755 (executable)
@@ -54,7 +54,9 @@ function(apply_folly_compile_options_to_target THETARGET)
       /Zc:strictStrings # Don't allow conversion from a string literal to mutable characters.\r
       /Zc:threadSafeInit # Enable thread-safe function-local statics initialization.\r
       /Zc:throwingNew # Assume operator new throws on failure.\r
-      /permissive- # Be mean, don't allow bad non-standard stuff (C++/CLI, __declspec, etc. are all left intact).\r
+\r
+      # This is only supported by MSVC 2017\r
+      $<$<BOOL:${MSVC_IS_2017}>:/permissive-> # Be mean, don't allow bad non-standard stuff (C++/CLI, __declspec, etc. are all left intact).\r
     PRIVATE\r
       /bigobj # Support objects with > 65k sections. Needed due to templates.\r
       /favor:${MSVC_FAVORED_ARCHITECTURE} # Architecture to prefer when generating code.\r
index 3670146..38886d6 100755 (executable)
@@ -7,8 +7,10 @@ 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)
 else()
   message(FATAL_ERROR "This build script only supports building Folly on 64-bit Windows with Visual Studio 2015 or Visual Studio 2017.")
 endif()