source: trunk/dports/_resources/port1.0/group/cmake-1.0.tcl @ 121112

Last change on this file since 121112 was 121112, checked in by mojca@…, 6 years ago

cmake-1.0.tcl: remove -I${prefix}/include from C(XX)FLAGS (#42872)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.6 KB
Line 
1# -*- coding: utf-8; mode: tcl; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; truncate-lines: t -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
2# $Id: cmake-1.0.tcl 121112 2014-06-17 20:16:44Z mojca@macports.org $
3#
4# Copyright (c) 2009 Orville Bennett <illogical1 at gmail.com>
5# Copyright (c) 2010-2013 The MacPorts Project
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions are
10# met:
11#
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17# 3. Neither the name of Apple Computer, Inc. nor the names of its
18#    contributors may be used to endorse or promote products derived from
19#    this software without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#
33#
34# Usage:
35# PortGroup     cmake 1.0
36
37# standard place to install extra CMake modules
38set cmake_share_module_dir ${prefix}/share/cmake/modules
39
40depends_build-append port:cmake
41
42#FIXME: ccache works with cmake on linux
43configure.ccache    no
44
45configure.cmd       ${prefix}/bin/cmake
46
47configure.pre_args  -DCMAKE_INSTALL_PREFIX=${prefix}
48
49configure.args      -DCMAKE_VERBOSE_MAKEFILE=ON \
50                    -DCMAKE_COLOR_MAKEFILE=ON \
51                    -DCMAKE_BUILD_TYPE=Release \
52                    -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
53                    -DCMAKE_INSTALL_RPATH=${prefix}/lib \
54                    -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib \
55                    -DCMAKE_SYSTEM_PREFIX_PATH="${prefix}\;/usr" \
56                    -DCMAKE_MODULE_PATH=${cmake_share_module_dir} \
57                    -DCMAKE_FIND_FRAMEWORK=LAST \
58                    -Wno-dev
59
60# CMake honors set environment variables CFLAGS, CXXFLAGS, and LDFLAGS when it
61# is first run in a build directory to initialize CMAKE_C_FLAGS,
62# CMAKE_CXX_FLAGS, CMAKE_[EXE|SHARED|MODULE]_LINKER_FLAGS. However, be aware
63# that a CMake script can always override these flags when it runs, as they
64# are frequently set internally in functions of other CMake build variables!
65#
66# Attention: If you want to be sure that no compiler flags are passed via
67# configure.args, you have to manually clear configure.optflags, as it is set
68# to "-Os" by default and added to all language-specific flags. If you want to
69# turn off optimization, explicitly set configure.optflags to "-O0".
70
71# TODO: Handle configure.objcflags (cf. to CMake upstream ticket #4756
72#       "CMake needs an Objective-C equivalent of CMAKE_CXX_FLAGS"
73#       <http://public.kitware.com/Bug/view.php?id=4756>)
74
75# TODO: Handle the Fortran-specific configure.* variables:
76#       configure.fflags, configure.fcflags, configure.f90flags
77
78# TODO: Handle the Java-specific configure.classpath variable.
79
80pre-configure {
81    # The environment variable CPPFLAGS is not considered by CMake.
82    # (CMake upstream ticket #12928 "CMake silently ignores CPPFLAGS"
83    # <http://www.cmake.org/Bug/view.php?id=12928>).
84    #
85    # But adding -I${prefix}/include to CFLAGS/CXXFLAGS is a bad idea.
86    # If any other flags are needed, we need to add them.
87
88    # In addition, CMake provides build-type-specific flags for
89    # Release (-O3 -DNDEBUG), Debug (-g), MinSizeRel (-Os -DNDEBUG), and
90    # RelWithDebInfo (-O2 -g -DNDEBUG). If the configure.optflags have been
91    # set (-Os by default), we have to remove the optimization flags from the
92    # from the concerned Release build type so that configure.optflags
93    # gets honored (Debug used by the +debug variant does not set
94    # optimization flags by default).
95    if {${configure.optflags} ne ""} {
96        configure.args-append -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
97                              -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG"
98    }
99
100    platform darwin {
101        if {[variant_exists universal] && [variant_isset universal]} {
102            if {[info exists universal_archs_supported]} {
103                global merger_configure_args
104                foreach arch ${universal_archs_to_use} {
105                    lappend merger_configure_args(${arch}) -DCMAKE_OSX_ARCHITECTURES=${arch}
106                }
107            } else {
108                configure.universal_args-append \
109                    -DCMAKE_OSX_ARCHITECTURES="[join ${configure.universal_archs} \;]"
110            }
111        } else {
112            configure.args-append \
113                -DCMAKE_OSX_ARCHITECTURES="${configure.build_arch}"
114        }
115        if {${configure.sdkroot} != ""} {
116            configure.args-append -DCMAKE_OSX_SYSROOT="${configure.sdkroot}" -DCMAKE_OSX_DEPLOYMENT_TARGET="${macosx_deployment_target}" 
117        } else {
118            # Without this, cmake will choose an SDK and deployment target on its own.
119            if {[vercmp $xcodeversion 4.3] < 0} {
120                set sdks_dir ${developer_dir}/SDKs
121            } else {
122                set sdks_dir ${developer_dir}/Platforms/MacOSX.platform/Developer/SDKs
123            }
124            if {$macosx_deployment_target eq "10.4"} {
125                set sdk ${sdks_dir}/MacOSX10.4u.sdk
126            } else {
127                set sdk ${sdks_dir}/MacOSX${macosx_deployment_target}.sdk
128            }
129            configure.args-append \
130                -DCMAKE_OSX_SYSROOT="${sdk}" \
131                -DCMAKE_OSX_DEPLOYMENT_TARGET="${macosx_deployment_target}" 
132        }
133    }
134}
135
136configure.universal_args-delete --disable-dependency-tracking
137
138variant debug description "Enable debug binaries" {
139    configure.args-delete   -DCMAKE_BUILD_TYPE=Release
140    configure.args-append   -DCMAKE_BUILD_TYPE=Debug
141}
142
143# cmake doesn't like --enable-debug, so in case a portfile sets
144# --enable-debug (regardless of variant) we remove it
145if {[string first "--enable-debug" ${configure.args}] > -1} {
146    configure.args-delete     --enable-debug
147}
Note: See TracBrowser for help on using the repository browser.