cmake: enable running the tests Summary: CMake 3.9+ includes built-in support for gtest. This updates the CMake build scripts to make use of this if the GoogleTest module is available. Reviewed By: meyering Differential Revision: D6745369 fbshipit-source-id: 1ef978874b9a0ef2cc5f48ab1c7a0b55d0f1155e
cmake: build as many source files as possible Summary: The CMakeLists.txt file finds the sources and headers for the main folly library by finding all *.cpp and *.h files, and then excluding specific ones. The CMakeLists.txt file was originally written for Windows builds, and it was hard-coded to exclude a number of files that do not build on Windows. This updates the file to properly check for the dependencies, and build these files if their required third-party dependencies are available. Reviewed By: meyering Differential Revision: D6745368 fbshipit-source-id: 3ee04d54147a68c482aab50d30bc9fe2a4134eef
cmake: add more checks for folly-config.h generation Summary: Update the CMake build files to perform additional checks to set configuration macros in folly-config.h I believe this should largely bring the CMake build on-par with (or even better than) the autoconf build scripts. I believe that the CMake build scripts now perform all of the checks necessary to set macros in folly-config.h correctly. The autoconf-based configure script also appears to have a number of bugs: in several places it accidentally uses different macro names than the ones checked in the source code. Some of it's checks are also broken, and fail to detect features correctly due to compilation errors in the check. Reviewed By: yfeldblum Differential Revision: D6735699 fbshipit-source-id: 5ce48f1deddd63c9d52fcccd5d5ccf6ca35e9a0d
cmake: fix path to FindGLog.cmake Summary: The cmake files refer to this package as "FindGLog", but the file name on disk incorrectly had the 'L' lower cased. This worked on case-insensitive file systems, but caused cmake to fail when used on a case-sensitive file system. This diff fixes the file name to match the name used in the cmake files. This is also more consistent with the existing "FindGFlags" and "FindGMock" packages. Reviewed By: yfeldblum Differential Revision: D6710439 fbshipit-source-id: 19f6824ef6793e505b5a0080c0fefe0b145a41c3
cmake: remove DOS-style line endings Summary: A number of the files in CMake/ had inconsistent line-endings. This updates files using DOS-style CRLF line endings to just use CR instead. On Windows, git is capable of automatically changing CR to CRLF when checking out the repository working directory. Reviewed By: meyering Differential Revision: D6714717 fbshipit-source-id: 82adccf4e522d38fd1cb420869f62e52dbd6c5f1
cmake: add checks to generate folly-config.h correctly Summary: Add proper checks to detect and set the values in folly-config.h correctly. Previously the code simply hard-coded values that were appropriate for Windows. This does not yet define all of the settings produced by the autoconf build, but it lets the CMake-based build largely succeed on Linux systems. Reviewed By: meyering Differential Revision: D6710437 fbshipit-source-id: 80490080ee6322995b740ac2a15181d220c6874a
cmake: set compiler flags for non-Windows platforms Summary: Update CMakeLists.txt to check the current platform, and to set compiler flags correctly. It now uses flags for Microsoft Visual Studio on Windows, and flags for gcc or clang on all other platforms. Previously it unconditionally used MSVC flags. Reviewed By: meyering Differential Revision: D6710435 fbshipit-source-id: dbae3097bcadf1ee4a25879dd7770603387c0e4d
Minor tweaks to the wording of a couple of errors in the CMake build Summary: Tweak the wording of a couple error messages to make them clearer. Also disable the 'digraphs not supported' warning, as none of our supported compilers actually interpret digraphs in any of our supported build configurations. Closes: https://github.com/facebook/folly/issues/706 Reviewed By: yfeldblum Differential Revision: D6299715 fbshipit-source-id: 7c847ac859e082aea711f6751f626b4b43886da4
Fix static linking gflags and glog Summary: gflags and glog require some compile definitions when linking statically /cc Orvid Closes https://github.com/facebook/folly/pull/693 Reviewed By: yfeldblum Differential Revision: D6264382 Pulled By: Orvid fbshipit-source-id: 60c8af429f10e778d9c313f40227892238829f63
Add support for tagging a test as BROKEN in the CMake build Summary: Also use it to disable function_test and indexed_mem_pool_test for now while the source of their breakage is being investigated. Reviewed By: yfeldblum Differential Revision: D5440415 fbshipit-source-id: 630c884ccd2db660bfc3e4529a2d35941d3bd0d3
Force string pooling to workaround a codegen bug Summary: There are bugs in MSVC's codegen that causes `StringPiece`'s evaluated in a `constexpr` context to have the start pointer point to one copy of the string and the end pointer point to another. Using the `StringPiece` at compile-time is perfectly fine, it just has the wrong values at runtime. We can work around this issue by enabling string pooling in all modes. Original bug report: https://developercommunity.visualstudio.com/content/problem/3216/c-incorrect-data-duplication-in-constexpr-context.html Reviewed By: yfeldblum Differential Revision: D5409753 fbshipit-source-id: 24e2b343209ba7c86d0dd39a1358d0abe9ee6d4d
Fix build with Ninja generator Summary: We were hitting a bug in CMake's Ninja generator that was causing it to incorrectly attempt to escape the closing quote on `_HAS_AUTO_PTR_ETC=1`, so remove the quotes, as they aren't actually needed. This also makes a few quality-of-life changes to make building Folly with Ninja slightly easier. Closes: https://github.com/facebook/folly/issues/604 Reviewed By: yfeldblum Differential Revision: D5134585 fbshipit-source-id: 3816e53774f7963b9b4fd8ddf68b83ff7afdefe1
Shift the job of defining NOMINMAX into source rather than the build system Summary: This makes it easier to consume Folly from a non-cmake project. Note that this also requires making libevent, which was previously categorized as a semi-portable header into a non-portable header, meaning it can't be referenced directly. (libevent includes `Windows.h` in one of its headers -_-....) Reviewed By: yfeldblum Differential Revision: D5106051 fbshipit-source-id: 5ce2d4188c9036d6ab206af3036c8fd4b09516a4
Fix the linking of various tests against GMock Summary: A define was needed to be able to link when built against a shared-library version of gmock and gtest. Reviewed By: yfeldblum Differential Revision: D5100409 fbshipit-source-id: 9a4c9df20f682a25edde642c451476b2d1e1ae22
Make a few adjustments to the compile config for the CMake build Summary: This includes adding options to toggle `/std:c++latest`, and `WIN32_LEAN_AND_MEAN`, along with giving a nice drop-down selector to `MSVC_FAVORED_ARCHITECTURE` when configured via the GUI, dropping `_WINSOCK_DEPRECATED_NO_WARNINGS` as it wasn't needed, and re-enabling warnings 4365 and 4775 within the scope of the standard library. Reviewed By: yfeldblum Differential Revision: D5100586 fbshipit-source-id: 87b20c6415391d4f0c75837cad5bc312910bf49f
Fix a couple of issues with the CMake script 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
Add CMake build system Summary: This is for use on Windows only, and does not support Linux or OSX in the slightest. There are probably still a few hacks laying around in it, but it works, and that's good enough for now. Reviewed By: yfeldblum Differential Revision: D4873498 fbshipit-source-id: 5952a927037dc1d56c51e71d51ba506d2cd17357