0025114: CMake-based build tools for OCCT 7.0
[occt.git] / adm / cmake / occt_defs_flags.cmake
CommitLineData
9f33b387 1
2if (MSVC)
3 add_definitions(/fp:precise)
4endif()
5
6# set compiler short name and choose SSE2 option for appropriate MSVC compilers
7# ONLY for 32-bit
8if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
9 if (MSVC80 OR MSVC90 OR MSVC10)
10 add_definitions(/arch:SSE2)
11 endif()
12endif()
13
14add_definitions (-DCSFDB)
15if (WIN32)
16 add_definitions (/DWNT -wd4996)
17elseif (APPLE)
18 add_definitions (-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H)
19else()
20 add_definitions (-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H -DLIN)
21endif()
22
23# enable structured exceptions for MSVC
24string (REGEX MATCH "EHsc" ISFLAG "${CMAKE_CXX_FLAGS}")
25if (ISFLAG)
26 string (REGEX REPLACE "EHsc" "EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
27elseif (WIN32)
28 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EHa")
29endif()
30
31# remove DEBUG flag if it exists
32string (REGEX MATCH "-DDEBUG" IS_DEBUG_CXX "${CMAKE_CXX_FLAGS_DEBUG}")
33if (IS_DEBUG_CXX)
34 message (STATUS "-DDEBUG has been removed from CMAKE_CXX_FLAGS_DEBUG")
35 string (REGEX REPLACE "-DDEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
36endif()
37
38string (REGEX MATCH "-DDEBUG" IS_DEBUG_C "${CMAKE_C_FLAGS_DEBUG}")
39if (IS_DEBUG_C)
40 message (STATUS "-DDEBUG has been removed from CMAKE_C_FLAGS_DEBUG")
41 string (REGEX REPLACE "-DDEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
42endif()
9f33b387 43# enable parallel compilation on MSVC 9 and above
44if (MSVC AND NOT MSVC70 AND NOT MSVC80)
45 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP")
46endif()
47
48# generate a single response file which enlist all of the object files
49SET(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
50SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)
9f33b387 51# increase compiler warnings level (-W4 for MSVC, -Wall for GCC)
52if (MSVC)
53 if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
54 string (REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
55 else()
56 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
57 endif()
58elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
59 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
60endif()
61
19286d7c 62if (DEFINED CMAKE_COMPILER_IS_GNUCXX OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")
63 set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
64endif()
65
9f33b387 66set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
67set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
68
69set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEB")
70set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEB")