Salome HOME
fixed a typo
[modules/shaper.git] / CMakeCommon / Common.cmake
1 # Copyright (C) 2014-2023  CEA, EDF
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, or (at your option) any later version.
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 cmake_minimum_required (VERSION 2.6)
21 cmake_policy(SET CMP0011 NEW)
22
23 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
24 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
25 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
26
27 set(CMAKE_INCLUDE_CURRENT_DIR ON)
28
29 IF(WIN32)
30   ## Specific definitions: EHsc to avoid exceptions-linkage unresolved symbols
31   ADD_DEFINITIONS(-DWIN32 -D_WINDOWS /EHsc)
32 ENDIF(WIN32)
33
34 IF(UNIX)
35   IF(CMAKE_COMPILER_IS_GNUCC)
36     #C++11 is not supported on some platforms, disable it
37     #MESSAGE(STATUS "Setting -std=c++0x flag for the gcc...")
38     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
39
40     #Supporting test coverage checks (gcov) in the DEBUG mode
41     IF(USE_TEST_COVERAGE)
42       INCLUDE(CodeCoverage)
43       MESSAGE(STATUS "Setting flags for gcov support the gcc...")
44       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
45       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
46       SET(CMAKE_SHARED_LINKER_FLAGS "-lgcov")
47
48       SETUP_TARGET_FOR_COVERAGE(test_coverage  # Name for custom target.
49                                 ctest          # Name of the test driver executable that runs the tests.
50                                 coverage)      # Name of output directory.
51
52       SET(USE_TEST_COVERAGE False)
53     ENDIF(USE_TEST_COVERAGE)
54
55     #SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -E")
56     #MESSAGE(STATUS "gcc flags are: " ${CMAKE_CXX_FLAGS})
57     #MESSAGE(STATUS "linker flags are: " ${CMAKE_SHARED_LINKER_FLAGS})
58   ENDIF(CMAKE_COMPILER_IS_GNUCC)
59 ENDIF(UNIX)
60
61 # Set highest warnings level
62 IF(MSVC)
63   IF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
64     string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
65   else()
66     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
67   endif()
68 ELSE()
69   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
70 ENDIF()