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

Last change on this file since 134168 was 134168, checked in by michaelld@…, 4 years ago

cmake 1.0 PortGroup: by default be verbose when building, for debugging purposes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.4 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 134168 2015-03-19 16:28:00Z michaelld@macports.org $
3#
4# Copyright (c) 2009 Orville Bennett <illogical1 at gmail.com>
5# Copyright (c) 2010-2014 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
37options cmake.out_of_source cmake.build_dir
38
39default cmake.out_of_source no
40default cmake.build_dir {${workpath}/build}
41
42# standard place to install extra CMake modules
43set cmake_share_module_dir ${prefix}/share/cmake/Modules
44
45depends_build-append port:cmake
46
47proc _cmake_get_build_dir {} {
48    if {[option cmake.out_of_source]} {
49        return [option cmake.build_dir]
50    }
51    return [option worksrcpath]
52}
53
54default configure.dir {[_cmake_get_build_dir]}
55
56pre-configure {
57    file mkdir ${configure.dir}
58}
59
60#FIXME: ccache works with cmake on linux
61configure.ccache    no
62
63configure.cmd       ${prefix}/bin/cmake
64
65configure.pre_args  -DCMAKE_INSTALL_PREFIX=${prefix}
66
67configure.args      -DCMAKE_VERBOSE_MAKEFILE=ON \
68                    -DCMAKE_COLOR_MAKEFILE=ON \
69                    -DCMAKE_BUILD_TYPE=Release \
70                    -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
71                    -DCMAKE_INSTALL_RPATH=${prefix}/lib \
72                    -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib \
73                    -DCMAKE_SYSTEM_PREFIX_PATH="${prefix}\;/usr" \
74                    -DCMAKE_MODULE_PATH=${cmake_share_module_dir} \
75                    -DCMAKE_FIND_FRAMEWORK=LAST \
76                    -Wno-dev
77
78default configure.post_args {${worksrcpath}}
79
80# CMake honors set environment variables CFLAGS, CXXFLAGS, and LDFLAGS when it
81# is first run in a build directory to initialize CMAKE_C_FLAGS,
82# CMAKE_CXX_FLAGS, CMAKE_[EXE|SHARED|MODULE]_LINKER_FLAGS. However, be aware
83# that a CMake script can always override these flags when it runs, as they
84# are frequently set internally in functions of other CMake build variables!
85#
86# Attention: If you want to be sure that no compiler flags are passed via
87# configure.args, you have to manually clear configure.optflags, as it is set
88# to "-Os" by default and added to all language-specific flags. If you want to
89# turn off optimization, explicitly set configure.optflags to "-O0".
90
91# TODO: Handle configure.objcflags (cf. to CMake upstream ticket #4756
92#       "CMake needs an Objective-C equivalent of CMAKE_CXX_FLAGS"
93#       <http://public.kitware.com/Bug/view.php?id=4756>)
94
95# TODO: Handle the Fortran-specific configure.* variables:
96#       configure.fflags, configure.fcflags, configure.f90flags
97
98# TODO: Handle the Java-specific configure.classpath variable.
99
100pre-configure {
101    # The environment variable CPPFLAGS is not considered by CMake.
102    # (CMake upstream ticket #12928 "CMake silently ignores CPPFLAGS"
103    # <http://www.cmake.org/Bug/view.php?id=12928>).
104    #
105    # But adding -I${prefix}/include to CFLAGS/CXXFLAGS is a bad idea.
106    # If any other flags are needed, we need to add them.
107
108    # In addition, CMake provides build-type-specific flags for
109    # Release (-O3 -DNDEBUG), Debug (-g), MinSizeRel (-Os -DNDEBUG), and
110    # RelWithDebInfo (-O2 -g -DNDEBUG). If the configure.optflags have been
111    # set (-Os by default), we have to remove the optimization flags from the
112    # from the concerned Release build type so that configure.optflags
113    # gets honored (Debug used by the +debug variant does not set
114    # optimization flags by default).
115    if {${configure.optflags} ne ""} {
116        configure.args-append -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
117                              -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG"
118    }
119
120    platform darwin {
121        if {[variant_exists universal] && [variant_isset universal]} {
122            if {[info exists universal_archs_supported]} {
123                global merger_configure_args
124                foreach arch ${universal_archs_to_use} {
125                    lappend merger_configure_args(${arch}) -DCMAKE_OSX_ARCHITECTURES=${arch}
126                }
127            } else {
128                configure.universal_args-append \
129                    -DCMAKE_OSX_ARCHITECTURES="[join ${configure.universal_archs} \;]"
130            }
131        } else {
132            configure.args-append \
133                -DCMAKE_OSX_ARCHITECTURES="${configure.build_arch}"
134        }
135
136        configure.args-append -DCMAKE_OSX_DEPLOYMENT_TARGET="${macosx_deployment_target}"
137
138        if {${configure.sdkroot} != ""} {
139            configure.args-append -DCMAKE_OSX_SYSROOT="${configure.sdkroot}"
140        } else {
141            configure.args-append -DCMAKE_OSX_SYSROOT="/"
142        }
143    }
144}
145
146configure.universal_args-delete --disable-dependency-tracking
147
148variant debug description "Enable debug binaries" {
149    configure.args-replace  -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Debug
150}
151
152# cmake doesn't like --enable-debug, so in case a portfile sets
153# --enable-debug (regardless of variant) we remove it
154if {[string first "--enable-debug" ${configure.args}] > -1} {
155    configure.args-delete     --enable-debug
156}
157
158default build.dir {${configure.dir}}
159
160default build.post_args {VERBOSE=ON}
Note: See TracBrowser for help on using the repository browser.