From 524fc3c0dca0167f3dbc2117b4a4d428322878d1 Mon Sep 17 00:00:00 2001 From: heister Date: Wed, 20 Feb 2013 01:06:46 +0000 Subject: [PATCH] add cmake scripts for MSVC 2012 (not working yet) git-svn-id: https://svn.dealii.org/branches/branch_cmake@28487 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/setup_compiler_flags.cmake | 6 +- deal.II/cmake/setup_compiler_flags_msvc.cmake | 85 +++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 deal.II/cmake/setup_compiler_flags_msvc.cmake diff --git a/deal.II/cmake/setup_compiler_flags.cmake b/deal.II/cmake/setup_compiler_flags.cmake index 7102e0105d..c2524fdecc 100644 --- a/deal.II/cmake/setup_compiler_flags.cmake +++ b/deal.II/cmake/setup_compiler_flags.cmake @@ -90,7 +90,11 @@ IF(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS) SET(DEAL_II_KNOWN_COMPILER TRUE) ENDIF() - + IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + INCLUDE(setup_compiler_flags_msvc) + SET(DEAL_II_KNOWN_COMPILER TRUE) + ENDIF() + IF(NOT DEAL_II_KNOWN_COMPILER) MESSAGE(FATAL_ERROR "\n" "Unknown compiler!\n" diff --git a/deal.II/cmake/setup_compiler_flags_msvc.cmake b/deal.II/cmake/setup_compiler_flags_msvc.cmake new file mode 100644 index 0000000000..3afea550b8 --- /dev/null +++ b/deal.II/cmake/setup_compiler_flags_msvc.cmake @@ -0,0 +1,85 @@ +##### +## +## Copyright (C) 2012 by the deal.II authors +## +## This file is part of the deal.II library. +## +## +## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later +## version of the LGPL license. +## +## Author: Timo Heister +## +##### + +# +# General setup for the Microsoft Visual Studio C++ Compiler (Windows) +# +# Please read the fat note in setup_compiler_flags.cmake prior to +# editing this file. +# + +#TODO: this check is not working, my version is 17.0.51106.1 (2012) +#IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "17.0.0.0" ) +## MESSAGE(WARNING "\n" +# "You're using an old version of the MSVC C++ Compiler!\n" +# "It is strongly recommended to use at least version 2012.\n" +# ) +#ENDIF() + + +######################## +# # +# General setup: # +# # +######################## + +# enable exception handling: +ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "/EHsc") + +#enable warnings: +ADD_FLAGS(CMAKE_CXX_FLAGS "/W3") + +############################# +# # +# For Release target: # +# # +############################# + +IF (CMAKE_BUILD_TYPE MATCHES "Release") + # + # General optimization flags: (very basic for now) + # + ADD_FLAGS(DEAL_II_CXX_FLAGS_RELEASE "/O2") +ENDIF() + + +########################### +# # +# For Debug target: # +# # +########################### + +IF (CMAKE_BUILD_TYPE MATCHES "Debug") + LIST(APPEND DEAL_II_DEFINITIONS_DEBUG "DEBUG") + LIST(APPEND DEAL_II_USER_DEFINITIONS_DEBUG "DEBUG") + + # generate some debug info: + ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_DEBUG "/Zi") +ENDIF() + + +######################### +# # +# Set up C FLAGS: # +# # +######################### + +# +# For the moment we assume that CC and CXX are the same compiler and that +# we can set (almost) the same default flags for both: +# +SET(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS}) +SET(DEAL_II_C_FLAGS_RELEASE ${DEAL_II_CXX_FLAGS_RELEASE}) +SET(DEAL_II_C_FLAGS_DEBUG ${DEAL_II_CXX_FLAGS_DEBUG}) + -- 2.39.5