Ticket #49091: Portfile

File Portfile, 9.8 KB (added by ChristianFrisson (Christian Frisson), 9 years ago)
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 140730 2015-10-01 12:52:05Z michaelld@macports.org $
3
4PortSystem          1.0
5PortGroup           muniversal 1.0
6
7name                cmake
8
9categories          devel
10license             BSD
11installs_libs       no
12maintainers         michaelld css
13description         Cross-platform make
14set base_long_description \
15    "An extensible, open-source system that manages the build \
16    process in an operating system and compiler independent manner. \
17    Unlike many cross-platform systems, CMake is designed to be \
18    used in conjunction with the native build environment."
19homepage            http://www.cmake.org/
20platforms           darwin freebsd
21
22dist_subdir         cmake
23
24subport cmake-devel {}
25
26set branch          3.3
27
28if {${subport} eq ${name}} {
29
30    # release
31
32    version         ${branch}.2
33    revision        1
34    checksums       rmd160 c7d3b8895e2e143b7e1019477764370535917dca \
35                    sha256 e75a178d6ebf182b048ebfe6e0657c49f0dc109779170bad7ffcb17463f2fc22
36
37    long_description ${base_long_description} \
38        The ${subport} release port is updated roughly every few months.
39   
40    conflicts       cmake-devel
41
42    master_sites    http://www.cmake.org/files/v${branch}/
43
44    patchfiles-append patch-Modules-noArchCheck.release.diff
45    patchfiles-append patch-Modules-FindBoost.cmake.diff
46
47    livecheck.type  regex
48    livecheck.regex ${name}-(\[0-9.\]+)${extract.suffix}
49    livecheck.url   [lindex $master_sites 0]
50
51} else {
52
53    # devel
54    version         20150930
55    set dist_branch 3.3
56    set dist_date   20150929
57    set dist_hash   g847bd5
58    checksums       rmd160 05cbd5d910588ba53b0b55e8df9b8eeb8b8b5d8d \
59                    sha256 53a7ae91bcd85c5652c66ad1e16b3c1b9eef8d972af9d586aaca35d125dfc8b0
60
61    master_sites    http://www.cmake.org/files/dev/
62    distname        ${name}-${dist_branch}.${dist_date}-${dist_hash}
63    conflicts       cmake
64
65    long_description ${base_long_description} \
66        The ${subport} port is updated roughly every week.
67
68    patchfiles-append patch-Modules-noArchCheck.devel.diff
69
70    livecheck.type  regex
71    livecheck.regex (${name}-\[0-9a-g.-\]+)${extract.suffix}
72    livecheck.version ${distname}
73    livecheck.url   http://www.cmake.org/files/dev/
74
75}
76
77depends_lib-append  port:curl \
78                    port:expat \
79                    port:zlib \
80                    port:bzip2 \
81                    port:libarchive
82
83# CMake 3.2 changed dependency requirements to include jsoncpp.
84# jsoncpp 1.0+ requires CMake for building. catch 22. So, have CMake
85# use its internal jsoncpp until a better solution comes about.
86
87patchfiles-append   patch-CMakeFindFrameworks.cmake.diff \
88                    patch-Modules-FindFreetype.cmake.diff \
89                    patch-Modules-FindQt4.cmake.diff \
90                    patch-Modules-Platform-Darwin.cmake.diff \
91                    patch-Modules-Platform-Darwin-Initialize.cmake.diff
92
93configure.env-append \
94                    CMAKE_PREFIX_PATH=${prefix} \
95                    CMAKE_INCLUDE_PATH=${prefix}/include/ncurses \
96                    CMAKE_LIBRARY_PATH=${prefix}/lib
97
98platform darwin {
99    configure.env-append \
100                    CMAKE_OSX_DEPLOYMENT_TARGET="${macosx_deployment_target}"
101
102    if {${configure.sdkroot} != ""} {
103        configure.env-append CMAKE_OSX_SYSROOT="${configure.sdkroot}"
104    } else {
105        configure.env-append CMAKE_OSX_SYSROOT="/"
106    }
107}
108
109configure.args      --docdir=share/doc/cmake \
110                    --parallel=${build.jobs} \
111                    --init=${worksrcpath}/macports.cmake \
112                    --system-libs \
113                    --no-system-jsoncpp
114
115configure.universal_args
116configure.post_args
117
118# CMake's configure script doesn't recognize `--host`.
119array set merger_host {i386 {} x86_64 {} ppc {} ppc64 {}}
120
121# Leopard's Rosetta has some difficulties configuring the ppc slice
122platform darwin 9 {
123    global universal_archs_supported
124    if {${build_arch} eq "i386" || ${build_arch} eq "x86_64"} {
125        supported_archs i386 x86_64
126    } elseif {${build_arch} eq "ppc" || ${build_arch} eq "ppc64"} {
127        supported_archs ppc ppc64
128    }
129    set universal_archs_supported ${supported_archs}
130}
131
132platform darwin {
133    # TODO: Figure out why using libc++ fails on Lion and fix the bootstrap
134    #       script to honor CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET.
135    #       Since nothing links against cmake and cmake is just using the STL,
136    #       we're safe to force libstdc++
137    #
138    #       https://www.cmake.org/Bug/view.php?id=15039&nbn=16
139    if {${os.major} < 12} {
140        configure.cxx_stdlib libstdc++
141    }
142}
143
144build.post_args VERBOSE=ON
145
146post-patch {
147    # copy cmake init file, ready to be patched below
148    copy ${filespath}/macports.cmake ${worksrcpath}
149
150    # patch PREFIX
151    reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/macports.cmake
152    reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/Modules/CMakeFindFrameworks.cmake
153
154    # patch Python Version; doing this is OK even when +docs is not
155    # used, because the PYTHON_EXECUTABLE is used only when building
156    # docs -- so, when not building docs its setting makes no difference.
157
158    if {[variant_isset python27]} {
159        set PYTHON_VERSION_WITH_DOT "2.7"
160    } else {
161        set PYTHON_VERSION_WITH_DOT "3.4"
162    }
163    reinplace "s|__PYTHON_VERSION_WITH_DOT__|${PYTHON_VERSION_WITH_DOT}|g" ${worksrcpath}/macports.cmake
164}
165
166post-destroot {
167    xinstall -d -m 0755 ${destroot}${prefix}/share/emacs/site-lisp
168    xinstall -m 0644 ${worksrcpath}/Auxiliary/cmake-mode.el \
169        ${destroot}${prefix}/share/emacs/site-lisp
170    foreach type {syntax indent} {
171        xinstall -d -m 0755 ${destroot}${prefix}/share/vim/vimfiles/${type}
172        xinstall -m 0644 -W ${worksrcpath}/Auxiliary cmake-${type}.vim \
173            ${destroot}${prefix}/share/vim/vimfiles/${type}
174    }
175    if ([variant_isset gui]) {
176        set app CMake
177        xinstall -d ${destroot}${applications_dir}/${app}.app/Contents/MacOS \
178            ${destroot}${applications_dir}/${app}.app/Contents/Resources
179        xinstall -m 644 ${filespath}/Info.plist.in ${destroot}${applications_dir}/${app}.app/Contents/Info.plist
180        reinplace "s|@VERSION@|${version}|g" ${destroot}${applications_dir}/${app}.app/Contents/Info.plist
181        reinplace "s|@PREFIX@|${prefix}|g" ${destroot}${applications_dir}/${app}.app/Contents/Info.plist
182        ln -s ${prefix}/bin/cmake-gui ${destroot}${applications_dir}/${app}.app/Contents/MacOS/cmake-gui
183        xinstall -m 644 ${worksrcpath}/Source/QtDialog/CMakeSetup.icns ${destroot}${applications_dir}/${app}.app/Contents/Resources/CMakeSetup.icns
184    }
185}
186
187variant gui description {Build Qt-based cmake-gui} {
188    configure.args-append --qt-gui
189
190    # when building the GUI with Qt, CMake uses C++11. So, make sure
191    # the compiler used is c++11 compliant.
192   
193    if {${configure.cxx_stdlib} eq "libstdc++"} {
194
195        # *clang* when using libstdc++ do not seem to support C++11;
196        # C++11 support seems to need GCC 4.7+ when using libstdc++;
197        # could use C++0x support on GCC4.[56], but just ignore it since
198        # there are newer compilers already in place as defaults.
199
200        # Blacklist GCC compilers not supporting C++11 and all CLANG.
201        # This is probably not necessary, but it's good practice.
202
203        compiler.blacklist-append *clang* {*gcc-3*} {*gcc-4.[0-6]}
204
205        # and whitelist those we do want to use. wish there were a better way.
206        # these will be used in the order provided.
207
208        compiler.whitelist macports-gcc-4.9 macports-gcc-4.8 macports-gcc-4.7
209
210    } else {
211
212        # using libc++;
213        # Blacklist Clang not supporting C++11 in some form and all GCC.
214        # Just use the cxx11 PortGroup for this specific case.
215
216        PortGroup cxx11 1.0
217
218    }
219}
220
221variant qt4 conflicts qt5 requires gui description {Build Qt GUI using Qt4} {
222    PortGroup qt4 1.0
223    if {${subport} eq ${name}} {
224        patchfiles-append patch-qt4gui.release.diff
225    } else {
226        patchfiles-append patch-qt4gui.devel.diff
227    }
228    configure.args-append --qt-qmake=${qt_qmake_cmd}
229}
230
231variant qt5 conflicts qt4 requires gui description {Build Qt GUI using Qt5} {
232    PortGroup qt5 1.0
233    if {${subport} eq ${name}} {
234        patchfiles-append patch-qt5gui.release.diff
235    } else {
236        patchfiles-append patch-qt5gui.devel.diff
237    }
238    configure.args-append --qt-qmake=${qt_qmake_cmd}
239}
240
241if {[variant_isset gui]} {
242    if {![variant_isset qt4] && ![variant_isset qt5]} {
243        default_variants +qt4
244    }
245
246    if {![variant_isset qt4] && ![variant_isset qt5]} {
247        ui_error "\n\nYou must select either the +qt4 or +qt5 variant when using variant +gui.\n"
248        return -code error "Invalid variant selection"
249    }
250} else {
251    configure.args-append --no-qt-gui
252}
253
254variant docs description {Build documentation: HTML and manpages} {
255    configure.args-append \
256        --mandir=share/man \
257        --sphinx-man \
258        --sphinx-html
259}
260
261variant python27 conflicts python34 requires docs description {Build documentation using Sphinx from Python 2.7} {
262    depends_build-append port:py27-sphinx
263    configure.args-append \
264        --sphinx-build=${prefix}/bin/sphinx-build-2.7
265}
266
267variant python34 conflicts python27 requires docs description {Build documentation using Sphinx from Python 3.4} {
268    depends_build-append port:py34-sphinx
269    configure.args-append \
270        --sphinx-build=${prefix}/bin/sphinx-build-3.4
271}
272
273if {[variant_isset docs]} {
274    if {![variant_isset python27] && ![variant_isset python34]} {
275        default_variants +python27
276    }
277
278    if {![variant_isset python27] && ![variant_isset python34]} {
279        ui_error "\n\nYou must select either the +python27 or +python34 variant when using variant +docs.\n"
280        return -code error "Invalid variant selection"
281    }
282}