From 03957924ccf4e32d0fbc4dc3198da3249f57b890 Mon Sep 17 00:00:00 2001 From: Adam Simpkins Date: Fri, 12 Jan 2018 16:02:58 -0800 Subject: [PATCH] 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 --- ...Compiler.cmake => FollyCompilerMSVC.cmake} | 0 CMake/FollyCompilerUnix.cmake | 29 +++++++++++++++++++ CMakeLists.txt | 22 +++++++++++--- 3 files changed, 47 insertions(+), 4 deletions(-) rename CMake/{FollyCompiler.cmake => FollyCompilerMSVC.cmake} (100%) create mode 100644 CMake/FollyCompilerUnix.cmake diff --git a/CMake/FollyCompiler.cmake b/CMake/FollyCompilerMSVC.cmake similarity index 100% rename from CMake/FollyCompiler.cmake rename to CMake/FollyCompilerMSVC.cmake diff --git a/CMake/FollyCompilerUnix.cmake b/CMake/FollyCompilerUnix.cmake new file mode 100644 index 00000000..b9228150 --- /dev/null +++ b/CMake/FollyCompilerUnix.cmake @@ -0,0 +1,29 @@ +set(CMAKE_CXX_FLAGS_COMMON -g -Wall -Wextra) +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_COMMON}") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_COMMON} -O3") + +function(apply_folly_compile_options_to_target THETARGET) + target_compile_options(${THETARGET} + PUBLIC + -g + -std=gnu++14 + -fopenmp + -finput-charset=UTF-8 + -fsigned-char + -faligned-new + -Werror + -Wall + -Wno-deprecated + -Wdeprecated-declarations + -Wno-error=deprecated-declarations + -Wno-sign-compare + -Wno-unused + -Wunused-label + -Wunused-result + -Wnon-virtual-dtor + -Wno-noexcept-type + PRIVATE + -D_REENTRANT + -D_GNU_SOURCE + ) +endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index f1446753..fe6b4a58 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,11 @@ configure_file( ${CMAKE_CURRENT_BINARY_DIR}/folly/folly-config.h ) -include(FollyCompiler) +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") + include(FollyCompilerMSVC) +else() + include(FollyCompilerUnix) +endif() include(FollyFunctions) # Main folly library files @@ -196,11 +200,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} ) -- 2.34.1