]> SALOME platform Git repositories - modules/kernel.git/blob - salome_adm/cmake_files/SalomeSetupPlatform.cmake
Salome HOME
CMake: tweaks for Win32 platform: configuration is successful
[modules/kernel.git] / salome_adm / cmake_files / SalomeSetupPlatform.cmake
1 # Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 ## Detect architecture
21 IF(WIN32)
22   SET(MACHINE WINDOWS)
23 ELSE()
24   SET(MACHINE PCLINUX)
25 ENDIF()
26
27 ## Test for 64 bits
28 IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
29   SET(MACHINE_IS_64 TRUE)
30 ELSE()
31   SET(MACHINE_IS_64 FALSE)
32 ENDIF()
33
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)
41
42 ## Make all warnings errors on non-windows platforms
43 #  CURRENTLY DISABLED
44 IF(NOT (WIN32 OR APPLE))
45   SET(ADD_WERROR ON)
46   SET(NAMES ACCEPT_SALOME_WARNINGS ACCEPT_${MODULE}_WARNINGS I_AM_A_TROLL_I_DO_NOT_FIX_${MODULE}_WARNINGS)
47   FOREACH(name ${NAMES})
48     SET(VAL $ENV{${name}})
49     IF("${VAL}" STREQUAL "0")
50       SET(ADD_WERROR ON)
51     ENDIF()
52     IF("${VAL}" STREQUAL "1")
53       SET(ADD_WERROR OFF)
54     ENDIF()
55   ENDFOREACH()
56   
57   IF(ADD_WERROR)
58 #    SET(CMAKE_C_FLAGS "-Werror")
59 #    SET(CMAKE_CXX_FLAGS "-Werror")
60   ENDIF()
61 ENDIF()
62
63 ## TODO: remove this ?
64 #IF(WIN32)
65 #    MARK_AS_ADVANCED(CLEAR CMAKE_CONFIGURATION_TYPES)
66 #    SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "compilation types" FORCE)
67 #ELSE()
68 #    IF(CMAKE_BUILD_TYPE STREQUAL Debug)
69 #      SET(CMAKE_C_FLAGS_DEBUG "-g")
70 #      SET(CMAKE_CXX_FLAGS_DEBUG "-g")
71 #    ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
72 #    IF(CMAKE_BUILD_TYPE STREQUAL Release)
73 #      SET(CMAKE_C_FLAGS_RELEASE "-O1 -DNDEBUG")
74 #      SET(CMAKE_CXX_FLAGS_RELEASE "-O1 -DNDEBUG")
75 #    ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
76 #ENDIF()
77
78
79 IF(WIN32)
80   ## Windows specific:  
81   ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)  # To disable windows warnings for strcpy, fopen, ...
82   ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)  # To disable windows warnings std::copy, std::transform, ...
83   ADD_DEFINITIONS(-DWNT -DWIN32)
84   ADD_DEFINITIONS(-D_WIN32_WINNT=0x0500)      # Windows 2000 or later API is required
85   ADD_DEFINITIONS(-DPPRO_NT)                  # For medfile
86   #ADD_DEFINITIONS(-D_USE_MATH_DEFINES)        # for MEDMEM
87     
88   SET(PLATFORM_LIBS Ws2_32.lib)
89   LIST(APPEND PLATFORM_LIBS Userenv.lib)      # At least for GEOM suit
90   
91   IF(MACHINE_IS_64)      
92     ADD_DEFINITIONS(-D_SECURE_SCL=0 -D_SECURE_SCL_THROWS=0)
93     ADD_DEFINITIONS(-D_HAS_ITERATOR_DEBUGGING=0) # To avoid runtime error during checking iterators
94     SET(SIZE_OF_LONG "4")                        # set sizeof(long) to 4 byte 
95   ENDIF()
96 ELSE()
97   ## Linux specific:
98   SET(PLATFORM_LIBS dl)    # Dynamic loading (dlopen, dlsym)
99 ENDIF()
100
101 ## Apple specific:
102 IF(APPLE)
103   SET(CMAKE_C_COMPILER gcc)
104   SET(CMAKE_CXX_COMPILER g++)
105   # because default is clang(llvm) with mountain lion at least
106 ENDIF()
107