diff options
author | David Neto <dneto@google.com> | 2018-11-19 22:02:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-19 22:02:07 -0500 |
commit | e390591a28e042872376b9db4de5433b15702c02 (patch) | |
tree | 51fdfcf68fc853d3118cb9a3573b2f1b64190b30 /CMakeLists.txt | |
parent | 6296cc53f4608ee06fff0d57a6b266c541f0ca7a (diff) | |
download | amber-e390591a28e042872376b9db4de5433b15702c02.tar.gz |
Windows build support (#71)
Windows build support
* MSVC: Ensure CRT is statically linked into executables
* Use fopen_s on Windows to avoid security warning
* Use std::strtoull and include its header
* Use #if defined(_MSC_VER)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c7c2bd9..296194b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,12 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1) +if (POLICY CMP0048) + cmake_policy(SET CMP0048 NEW) +endif() +if (POLICY CMP0054) + # Avoid dereferencing variables or interpret keywords that have been + # quoted or bracketed. + # https://cmake.org/cmake/help/v3.1/policy/CMP0054.html + cmake_policy(SET CMP0054 NEW) +endif() project(amber) enable_testing() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_CXX_STANDARD 11) include(CheckIncludeFile) include(GNUInstallDirs) @@ -38,12 +49,6 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE "Debug") endif() -set(CUSTOM_CXX_FLAGS - -std=c++11 - -Wall - -Werror - -Wextra) - if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))) @@ -53,7 +58,11 @@ endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CUSTOM_CXX_FLAGS ${CUSTOM_CXX_FLAGS} + -std=c++11 + -Wall + -Werror -Weverything + -Wextra -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded @@ -64,13 +73,39 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CUSTOM_CXX_FLAGS ${CUSTOM_CXX_FLAGS} + -Wall + -std=c++11 + -Werror + -Wextra -Wno-unknown-pragmas -Wpedantic -pedantic-errors) elseif(MSVC) + # We don't want to have to copy the C Runtime DLL everywhere the executable + # goes. So compile code to assume the CRT is statically linked, i.e. use + # /MT* options. For debug builds use /MTd, and for release builds use /MT. + if(CMAKE_BUILD_TYPE MATCHES "Debug") + set(CUSTOM_CXX_FLAGS ${CUSTOM_CXX_FLAGS} /MTd) + else() + set(CUSTOM_CXX_FLAGS ${CUSTOM_CXX_FLAGS} /MT) + endif() set(CUSTOM_CXX_FLAGS ${CUSTOM_CXX_FLAGS} - /WX) + /bigobj + /EHsc + /W3 + /WX + /wd4068 + /wd4514 + /wd4571 + /wd4625 + /wd4626 + /wd4710 + /wd4774 + /wd4820 + /wd5026 + /wd5027 + ) endif() SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "${CUSTOM_CXX_FLAGS}") |