0024023: Revamp the OCCT Handle - non-cost reference cast
[occt.git] / adm / templates / 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()
43
44# enable parallel compilation on MSVC 9 and above
45if (MSVC AND NOT MSVC70 AND NOT MSVC80)
46 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP")
47endif()
48
49# generate a single response file which enlist all of the object files
50SET(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
51SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)
52
53# increase compiler warnings level (-W4 for MSVC, -Wall for GCC)
54if (MSVC)
55 if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
56 string (REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
57 else()
58 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
59 endif()
60elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
61 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
62endif()
63
64set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
65set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
66
67set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEB")
68set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEB")