TZIVI-254: IVI needs a newer version of cmake
[profile/ivi/cmake.git] / Modules / Platform / Darwin-GNU.cmake
1
2 #=============================================================================
3 # Copyright 2002-2009 Kitware, Inc.
4 #
5 # Distributed under the OSI-approved BSD License (the "License");
6 # see accompanying file Copyright.txt for details.
7 #
8 # This software is distributed WITHOUT ANY WARRANTY; without even the
9 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 # See the License for more information.
11 #=============================================================================
12 # (To distribute this file outside of CMake, substitute the full
13 #  License text for the above reference.)
14
15 # This module is shared by multiple languages; use include blocker.
16 if(__DARWIN_COMPILER_GNU)
17   return()
18 endif()
19 set(__DARWIN_COMPILER_GNU 1)
20
21 macro(__darwin_compiler_gnu lang)
22   # GNU does not have -shared on OS X
23   set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
24   set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
25 endmacro()
26
27 macro(cmake_gnu_has_isysroot lang)
28   if("x${CMAKE_${lang}_HAS_ISYSROOT}" STREQUAL "x")
29     set(_doc "${lang} compiler has -isysroot")
30     message(STATUS "Checking whether ${_doc}")
31     execute_process(
32       COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
33       OUTPUT_VARIABLE _gcc_help
34       ERROR_VARIABLE _gcc_help
35       )
36     if("${_gcc_help}" MATCHES "isysroot")
37       message(STATUS "Checking whether ${_doc} - yes")
38       set(CMAKE_${lang}_HAS_ISYSROOT 1)
39     else()
40       message(STATUS "Checking whether ${_doc} - no")
41       set(CMAKE_${lang}_HAS_ISYSROOT 0)
42     endif()
43   endif()
44 endmacro()
45
46 macro(cmake_gnu_set_osx_deployment_target_flag lang)
47   if(NOT DEFINED CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG)
48     set(_doc "${lang} compiler supports OSX deployment target flag")
49     message(STATUS "Checking whether ${_doc}")
50     execute_process(
51       COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
52       OUTPUT_VARIABLE _gcc_help
53       ERROR_VARIABLE _gcc_help
54       )
55     if("${_gcc_help}" MATCHES "macosx-version-min")
56       message(STATUS "Checking whether ${_doc} - yes")
57       set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
58     else()
59       message(STATUS "Checking whether ${_doc} - no")
60       set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "")
61     endif()
62     set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG_CODE "SET(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG \"${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}\")")
63   endif()
64 endmacro()