Commit b31800c0 authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

Add a few more options to the CMake build

Summary:
The first allows disabling CMake's google test integration, as it doesn't play nice with the Visual Studio IDE itself.
The second allows setting the version of C++ to use when compiling with MSVC.

Reviewed By: yfeldblum

Differential Revision: D7976567

fbshipit-source-id: e6fe3cc28a23334d69e8cd18f633afab2efecd59
parent a1946006
# Some additional configuration options. # Some additional configuration options.
option(MSVC_ENABLE_ALL_WARNINGS "If enabled, pass /Wall to the compiler." ON) option(MSVC_ENABLE_ALL_WARNINGS "If enabled, pass /Wall to the compiler." ON)
option(MSVC_ENABLE_CPP_LATEST "If enabled, pass /std:c++latest to the compiler" ON)
option(MSVC_ENABLE_DEBUG_INLINING "If enabled, enable inlining in the debug configuration. This allows /Zc:inline to be far more effective." OFF) option(MSVC_ENABLE_DEBUG_INLINING "If enabled, enable inlining in the debug configuration. This allows /Zc:inline to be far more effective." OFF)
option(MSVC_ENABLE_FAST_LINK "If enabled, pass /DEBUG:FASTLINK to the linker. This makes linking faster, but the gtest integration for Visual Studio can't currently handle the .pdbs generated." OFF) option(MSVC_ENABLE_FAST_LINK "If enabled, pass /DEBUG:FASTLINK to the linker. This makes linking faster, but the gtest integration for Visual Studio can't currently handle the .pdbs generated." OFF)
option(MSVC_ENABLE_LEAN_AND_MEAN_WINDOWS "If enabled, define WIN32_LEAN_AND_MEAN to include a smaller subset of Windows.h" ON) option(MSVC_ENABLE_LEAN_AND_MEAN_WINDOWS "If enabled, define WIN32_LEAN_AND_MEAN to include a smaller subset of Windows.h" ON)
...@@ -26,6 +25,15 @@ if (NOT MSVC_FAVORED_ARCHITECTURE STREQUAL "blend" AND NOT MSVC_FAVORED_ARCHITEC ...@@ -26,6 +25,15 @@ if (NOT MSVC_FAVORED_ARCHITECTURE STREQUAL "blend" AND NOT MSVC_FAVORED_ARCHITEC
message(FATAL_ERROR "MSVC_FAVORED_ARCHITECTURE must be set to one of exactly, 'blend', 'AMD64', 'INTEL64', or 'ATOM'! Got '${MSVC_FAVORED_ARCHITECTURE}' instead!") message(FATAL_ERROR "MSVC_FAVORED_ARCHITECTURE must be set to one of exactly, 'blend', 'AMD64', 'INTEL64', or 'ATOM'! Got '${MSVC_FAVORED_ARCHITECTURE}' instead!")
endif() endif()
set(MSVC_LANGUAGE_VERSION "c++latest" CACHE STRING "One of 'c++14', 'c++17', or 'c++latest'. This determines which version of C++ to compile as.")
set_property(
CACHE MSVC_LANGUAGE_VERSION
PROPERTY STRINGS
"c++14"
"c++17"
"c++latest"
)
############################################################ ############################################################
# We need to adjust a couple of the default option sets. # We need to adjust a couple of the default option sets.
############################################################ ############################################################
...@@ -81,7 +89,7 @@ function(apply_folly_compile_options_to_target THETARGET) ...@@ -81,7 +89,7 @@ function(apply_folly_compile_options_to_target THETARGET)
/Zc:threadSafeInit # Enable thread-safe function-local statics initialization. /Zc:threadSafeInit # Enable thread-safe function-local statics initialization.
/Zc:throwingNew # Assume operator new throws on failure. /Zc:throwingNew # Assume operator new throws on failure.
$<$<BOOL:${MSVC_ENABLE_CPP_LATEST}>:/std:c++latest> # Build in C++ Latest mode if requested. /std:${MSVC_LANGUAGE_VERSION} # Build in the requested version of C++
# This is only supported by MSVC 2017 # This is only supported by MSVC 2017
$<$<BOOL:${MSVC_IS_2017}>:/permissive-> # Be mean, don't allow bad non-standard stuff (C++/CLI, __declspec, etc. are all left intact). $<$<BOOL:${MSVC_IS_2017}>:/permissive-> # Be mean, don't allow bad non-standard stuff (C++/CLI, __declspec, etc. are all left intact).
......
...@@ -314,9 +314,14 @@ option(BUILD_BROKEN_TESTS "If enabled, compile tests that are known to be broken ...@@ -314,9 +314,14 @@ option(BUILD_BROKEN_TESTS "If enabled, compile tests that are known to be broken
option(BUILD_HANGING_TESTS "If enabled, compile tests that are known to hang." OFF) option(BUILD_HANGING_TESTS "If enabled, compile tests that are known to hang." OFF)
option(BUILD_SLOW_TESTS "If enabled, compile tests that take a while to run in debug mode." OFF) option(BUILD_SLOW_TESTS "If enabled, compile tests that take a while to run in debug mode." OFF)
if (BUILD_TESTS) if (BUILD_TESTS)
option(USE_CMAKE_GOOGLE_TEST_INTEGRATION "If enabled, use the google test integration included in CMake." ON)
find_package(GMock MODULE REQUIRED) find_package(GMock MODULE REQUIRED)
include(GoogleTest OPTIONAL RESULT_VARIABLE HAVE_CMAKE_GTEST) if (USE_CMAKE_GOOGLE_TEST_INTEGRATION)
enable_testing() include(GoogleTest OPTIONAL RESULT_VARIABLE HAVE_CMAKE_GTEST)
enable_testing()
else()
set(HAVE_CMAKE_GTEST OFF)
endif()
# The ThreadLocalTest code uses a helper shared library for one of its tests. # The ThreadLocalTest code uses a helper shared library for one of its tests.
# This can only be built if folly itself was built as a shared library. # This can only be built if folly itself was built as a shared library.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment