0023741: Research and remove CSFDB support from OCCT if it is necessary
[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
9f33b387 14if (WIN32)
57c28b61 15 add_definitions (-wd4996)
9f33b387 16elseif (APPLE)
57c28b61 17 add_definitions (-fexceptions -fPIC -DOCC_CONVERT_SIGNALS)
9f33b387 18else()
57c28b61 19 add_definitions (-fexceptions -fPIC -DOCC_CONVERT_SIGNALS)
9f33b387 20endif()
21
22# enable structured exceptions for MSVC
23string (REGEX MATCH "EHsc" ISFLAG "${CMAKE_CXX_FLAGS}")
24if (ISFLAG)
25 string (REGEX REPLACE "EHsc" "EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
26elseif (WIN32)
27 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EHa")
28endif()
29
57c28b61 30# remove _WINDOWS flag if it exists
31string (REGEX MATCH "/D_WINDOWS" IS_WINDOWSFLAG "${CMAKE_CXX_FLAGS}")
32if (IS_WINDOWSFLAG)
33 message (STATUS "/D_WINDOWS has been removed from CMAKE_CXX_FLAGS")
34 string (REGEX REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
35endif()
36
37# remove WIN32 flag if it exists
38string (REGEX MATCH "/DWIN32" IS_WIN32FLAG "${CMAKE_CXX_FLAGS}")
39if (IS_WIN32FLAG)
40 message (STATUS "/DWIN32 has been removed from CMAKE_CXX_FLAGS")
41 string (REGEX REPLACE "/DWIN32" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
42endif()
43
44# remove _WINDOWS flag if it exists
45string (REGEX MATCH "/D_WINDOWS" IS_WINDOWSFLAG "${CMAKE_C_FLAGS}")
46if (IS_WINDOWSFLAG)
47 message (STATUS "/D_WINDOWS has been removed from CMAKE_C_FLAGS")
48 string (REGEX REPLACE "/D_WINDOWS" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
49endif()
50
51# remove WIN32 flag if it exists
52string (REGEX MATCH "/DWIN32" IS_WIN32FLAG "${CMAKE_C_FLAGS}")
53if (IS_WIN32FLAG)
54 message (STATUS "/DWIN32 has been removed from CMAKE_C_FLAGS")
55 string (REGEX REPLACE "/DWIN32" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
56endif()
57
9f33b387 58# remove DEBUG flag if it exists
59string (REGEX MATCH "-DDEBUG" IS_DEBUG_CXX "${CMAKE_CXX_FLAGS_DEBUG}")
60if (IS_DEBUG_CXX)
61 message (STATUS "-DDEBUG has been removed from CMAKE_CXX_FLAGS_DEBUG")
62 string (REGEX REPLACE "-DDEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
63endif()
64
65string (REGEX MATCH "-DDEBUG" IS_DEBUG_C "${CMAKE_C_FLAGS_DEBUG}")
66if (IS_DEBUG_C)
67 message (STATUS "-DDEBUG has been removed from CMAKE_C_FLAGS_DEBUG")
68 string (REGEX REPLACE "-DDEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
69endif()
9f33b387 70# enable parallel compilation on MSVC 9 and above
71if (MSVC AND NOT MSVC70 AND NOT MSVC80)
72 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP")
73endif()
74
75# generate a single response file which enlist all of the object files
76SET(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
77SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)
9f33b387 78# increase compiler warnings level (-W4 for MSVC, -Wall for GCC)
79if (MSVC)
80 if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
81 string (REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
82 else()
83 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
84 endif()
85elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
86 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
87endif()
88
19286d7c 89if (DEFINED CMAKE_COMPILER_IS_GNUCXX OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")
90 set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
91endif()
92
9f33b387 93set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
57c28b61 94set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")