1 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 ## Detect architecture
28 IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
29 SET(MACHINE_IS_64 TRUE)
31 SET(MACHINE_IS_64 FALSE)
34 ## Force CMAKE_BUILD_TYPE to Release if not set
35 IF(NOT CMAKE_BUILD_TYPE)
36 SET(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE})
37 ENDIF(NOT CMAKE_BUILD_TYPE)
38 IF(NOT CMAKE_BUILD_TYPE)
39 SET(CMAKE_BUILD_TYPE Release)
40 ENDIF(NOT CMAKE_BUILD_TYPE)
42 ## Define the log level according to the build type
43 IF(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "Debug")
46 SET(PYLOGLEVEL WARNING)
49 ## Make all warnings errors on non-windows platforms
51 IF(NOT (WIN32 OR APPLE))
53 SET(NAMES ACCEPT_SALOME_WARNINGS ACCEPT_${MODULE}_WARNINGS I_AM_A_TROLL_I_DO_NOT_FIX_${MODULE}_WARNINGS)
54 FOREACH(name ${NAMES})
55 SET(VAL $ENV{${name}})
56 IF("${VAL}" STREQUAL "0")
59 IF("${VAL}" STREQUAL "1")
65 # SET(CMAKE_C_FLAGS "-Werror")
66 # SET(CMAKE_CXX_FLAGS "-Werror")
70 ## TODO: remove this ?
72 # MARK_AS_ADVANCED(CLEAR CMAKE_CONFIGURATION_TYPES)
73 # SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "compilation types" FORCE)
75 # IF(CMAKE_BUILD_TYPE STREQUAL Debug)
76 # SET(CMAKE_C_FLAGS_DEBUG "-g")
77 # SET(CMAKE_CXX_FLAGS_DEBUG "-g")
78 # ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
79 # IF(CMAKE_BUILD_TYPE STREQUAL Release)
80 # SET(CMAKE_C_FLAGS_RELEASE "-O1 -DNDEBUG")
81 # SET(CMAKE_CXX_FLAGS_RELEASE "-O1 -DNDEBUG")
82 # ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
87 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) # To disable windows warnings for strcpy, fopen, ...
88 ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) # To disable windows warnings std::copy, std::transform, ...
89 ADD_DEFINITIONS(-DWNT -DWIN32)
90 ADD_DEFINITIONS(-D_WIN32_WINNT=0x0500) # Windows 2000 or later API is required
91 ADD_DEFINITIONS(-DPPRO_NT) # For medfile
92 #ADD_DEFINITIONS(-D_USE_MATH_DEFINES) # for MEDMEM
94 SET(PLATFORM_LIBS Ws2_32.lib)
95 LIST(APPEND PLATFORM_LIBS Userenv.lib) # At least for GEOM suit
98 ADD_DEFINITIONS(-D_SECURE_SCL=0 -D_SECURE_SCL_THROWS=0)
99 ADD_DEFINITIONS(-D_HAS_ITERATOR_DEBUGGING=0) # To avoid runtime error during checking iterators
100 SET(SIZE_OF_LONG 4) # set sizeof(long) to 4 byte
102 SET(SIZE_OF_LONG ${CMAKE_SIZEOF_VOID_P}) # set sizeof(long) the same as size of pointers
106 SET(PLATFORM_LIBS dl) # Dynamic loading (dlopen, dlsym)
108 ADD_DEFINITIONS(-DPCLINUX64)
112 ## define _DEBUG_ macro
113 IF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
114 ADD_DEFINITIONS(-D_DEBUG_)
119 SET(CMAKE_C_COMPILER gcc)
120 SET(CMAKE_CXX_COMPILER g++)
121 # because default is clang(llvm) with mountain lion at least
124 # Compiler flags for coverage testing
126 OPTION(SALOME_BUILD_FOR_GCOV "Add the compilation flags for GCov/LCov" OFF)
127 MARK_AS_ADVANCED(SALOME_BUILD_FOR_GCOV)
128 IF(SALOME_BUILD_FOR_GCOV)
129 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
130 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")