1 # Copyright (C) 2007-2019 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, or (at your option) any later version.
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 INCLUDE(CheckCXXCompilerFlag)
22 ## Detect architecture
30 IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
31 SET(MACHINE_IS_64 TRUE)
33 SET(MACHINE_IS_64 FALSE)
36 ## Force CMAKE_BUILD_TYPE to Release if not set
37 IF(NOT CMAKE_BUILD_TYPE)
38 SET(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE})
39 ENDIF(NOT CMAKE_BUILD_TYPE)
40 IF(NOT CMAKE_BUILD_TYPE)
41 SET(CMAKE_BUILD_TYPE Release)
42 ENDIF(NOT CMAKE_BUILD_TYPE)
44 ## Define the log level according to the build type
45 IF(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "Debug")
48 SET(PYLOGLEVEL WARNING)
51 ## Treat all warnings as errors
52 IF(NOT (WIN32 OR APPLE))
53 OPTION(SALOME_DEBUG_WARNINGS "Treat warnings as errors" OFF)
54 MARK_AS_ADVANCED(SALOME_DEBUG_WARNINGS)
55 IF(SALOME_DEBUG_WARNINGS)
56 SET(CMAKE_C_FLAGS "-Werror")
57 SET(CMAKE_CXX_FLAGS "-Werror")
63 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) # To disable windows warnings for strcpy, fopen, ...
64 ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) # To disable windows warnings generated by checked iterators(e.g. std::copy, std::transform, ...)
65 ADD_DEFINITIONS(-DWNT -DWIN32)
66 ADD_DEFINITIONS(-D_WIN32_WINNT=0x0500) # Windows 2000 or later API is required
67 ADD_DEFINITIONS(-DPPRO_NT) # For medfile
69 SET(PLATFORM_LIBS Ws2_32.lib)
70 LIST(APPEND PLATFORM_LIBS Userenv.lib) # At least for GEOM suit
73 SET(SIZE_OF_LONG 4) # Set sizeof(long) to 4 bytes
75 SET(SIZE_OF_LONG ${CMAKE_SIZEOF_VOID_P}) # Set sizeof(long) the same as size of pointers
77 ADD_DEFINITIONS(-DUNICODE) # Unicode
78 ADD_DEFINITIONS(-D_UNICODE)
81 SET(PLATFORM_LIBS dl) # Dynamic loading (dlopen, dlsym)
83 ADD_DEFINITIONS(-DPCLINUX64)
87 ## define _DEBUG_ macro
88 IF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
89 ADD_DEFINITIONS(-D_DEBUG_)
94 # Default is clang(llvm) with mountain lion at least
95 OPTION(SALOME_APPLE_USE_GCC "Use GCC compiler" OFF)
96 MARK_AS_ADVANCED(SALOME_APPLE_USE_GCC)
97 IF(SALOME_APPLE_USE_GCC)
98 SET(CMAKE_C_COMPILER gcc)
99 SET(CMAKE_CXX_COMPILER g++)
103 # Compiler flags for coverage testing
105 OPTION(SALOME_BUILD_FOR_GCOV "Add the compilation flags for GCov/LCov" OFF)
106 MARK_AS_ADVANCED(SALOME_BUILD_FOR_GCOV)
107 IF(SALOME_BUILD_FOR_GCOV)
108 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
109 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
113 # Compiler flag to disable treating alternative C++ tokens (compatibility with MSVS)
114 CHECK_CXX_COMPILER_FLAG("-fno-operator-names" COMPILER_SUPPORTS_NO_OPERATOR_NAMES)
115 IF(COMPILER_SUPPORTS_NO_OPERATOR_NAMES)
116 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names")
119 IF(NOT NO_CXX11_SUPPORT)
121 CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
122 CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
123 IF(COMPILER_SUPPORTS_CXX11)
124 MESSAGE(STATUS "Enable C++11 support")
125 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
126 ELSEIF(COMPILER_SUPPORTS_CXX0X)
127 MESSAGE(STATUS "Enable C++0x support")
128 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
130 MESSAGE(WARNING "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")