diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4711cad22f7d268a3c3fd191b90bd02a3895c015..5d2b49da461ede48ec56972b1cda766610f20e43 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,8 +4,9 @@ cmake_minimum_required(VERSION 2.6)
 # Project name
 project( OGS-6 )
 
-### CMake setup ###
+### CMake includes ###
 INCLUDE(scripts/cmake/CMakeSetup.cmake)
+INCLUDE(scripts/cmake/CompilerSetup.cmake)
 
 # Finds
 FIND_PACKAGE(OpenMP)
@@ -14,35 +15,6 @@ IF(OPENMP_FOUND)
 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
 ENDIF()
 
-### For GNU C/CXX
-IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
-		get_gcc_version(GCC_VERSION)
-        IF( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
-                MESSAGE(STATUS "Set GCC release flags")
-				IF(APPLE AND GCC_VERSION VERSION_LESS "4.3" AND NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode" )
-					# -march=native does not work here when on normal gcc compiler
-					# see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33144
-					SET(CMAKE_CXX_FLAGS "-O3 -mtune=native -msse4.2 -DNDEBUG")
-				ELSE()
-                	SET(CMAKE_CXX_FLAGS "-O3 -march=native -mtune=native -msse4.2 -DNDEBUG")
-				ENDIF()
-        ENDIF()
-        # -g
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wall -Wextra -fno-nonansi-builtins")
-        ADD_DEFINITIONS(
-                -DGCC
-        )
-ENDIF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
-
-IF (${CMAKE_C_COMPILER} MATCHES "icc.*$" OR ${CMAKE_CXX_COMPILER} MATCHES "icpc.*$") 
-        IF( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
-                MESSAGE(STATUS "Set Intel release flags")
-                SET(CMAKE_CXX_FLAGS "-O3 -DNDEBUG")
-        ENDIF()
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wall")
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -openmp")
-ENDIF(${CMAKE_C_COMPILER} MATCHES "icc.*$" OR ${CMAKE_CXX_COMPILER} MATCHES
-"icpc.*$")
 
 
 # Set build directories
diff --git a/scripts/cmake/CompilerSetup.cmake b/scripts/cmake/CompilerSetup.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..927dfcbde3d7385cca5d20247aa8c50ab3b5aa51
--- /dev/null
+++ b/scripts/cmake/CompilerSetup.cmake
@@ -0,0 +1,56 @@
+INCLUDE(ResetConfigurations)        # To Debug, Release, RelWithDbgInfo
+INCLUDE(SetDefaultBuildType)
+SET_DEFAULT_BUILD_TYPE(Debug)
+INCLUDE(MSVCMultipleProcessCompile) # /MP switch (multi processor) for VS
+
+### GNU C/CXX
+IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
+		get_gcc_version(GCC_VERSION)
+        IF( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
+                MESSAGE(STATUS "Set GCC release flags")
+				IF(APPLE AND GCC_VERSION VERSION_LESS "4.3" AND NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode" )
+					# -march=native does not work here when on normal gcc compiler
+					# see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33144
+					SET(CMAKE_CXX_FLAGS "-O3 -mtune=native -msse4.2 -DNDEBUG")
+				ELSE()
+                	SET(CMAKE_CXX_FLAGS "-O3 -march=native -mtune=native -msse4.2 -DNDEBUG")
+				ENDIF()
+        ENDIF()
+        # -g
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wall -Wextra -fno-nonansi-builtins")
+        ADD_DEFINITIONS( -DGCC )
+		IF (OGS_PROFILE)
+			IF( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
+				MESSAGE(Warning "When using profiling you should set CMAKE_BUILD_TYPE to Release.")
+			ENDIF()
+			SET(PROFILE_FLAGS "-pg -fno-omit-frame-pointer -O2 -DNDEBUG -fno-inline-functions-called-once -fno-optimize-sibling-calls")
+			SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROFILE_FLAGS}")
+		ENDIF (OGS_PROFILE)
+ENDIF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
+
+### Intel
+IF (${CMAKE_C_COMPILER} MATCHES "icc.*$" OR ${CMAKE_CXX_COMPILER} MATCHES "icpc.*$")
+        IF( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
+                MESSAGE(STATUS "Set Intel release flags")
+                SET(CMAKE_CXX_FLAGS "-O3 -DNDEBUG")
+        ENDIF()
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wall")
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -openmp")
+ENDIF(${CMAKE_C_COMPILER} MATCHES "icc.*$" OR ${CMAKE_CXX_COMPILER} MATCHES
+"icpc.*$")
+
+### Windows
+IF (WIN32)
+	## For Visual Studio compiler
+	IF (MSVC)
+		ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS
+			-D_CRT_XNONSTDC_NO_WARNINGS)
+		# Sets warning level 3 and ignores some warnings
+		SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4290 /wd4267")
+		SET(GCC OFF)
+	# cygwin
+	ELSE (MSVC)
+		MESSAGE (STATUS "Might be GCC under cygwin.")
+		SET(GCC ON)
+	ENDIF (MSVC)
+ENDIF (WIN32)