Ticket #50246: cmake-1.0.diff

File cmake-1.0.diff, 4.6 KB (added by RJVB (René Bertin), 8 years ago)
  • _resources/port1.0/group/cmake-1.0.tcl

    old new  
    6767
    6868configure.args      -DCMAKE_VERBOSE_MAKEFILE=ON \
    6969                    -DCMAKE_COLOR_MAKEFILE=ON \
    70                     -DCMAKE_BUILD_TYPE=Release \
     70                    -DCMAKE_BUILD_TYPE=MacPorts \
    7171                    -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
    7272                    -DCMAKE_INSTALL_RPATH=${prefix}/lib \
    7373                    -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib \
     
    113113    # from the concerned Release build type so that configure.optflags
    114114    # gets honored (Debug used by the +debug variant does not set
    115115    # optimization flags by default).
    116     if {${configure.optflags} ne ""} {
    117         configure.args-append -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
    118                               -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG"
     116    # NB: more recent CMake versions (>=3?) no longer take the env. variables into
     117    # account, and thus require explicit use of ${configure.c*flags} below:
     118#     if {${configure.optflags} ne ""} {
     119#         configure.args-append   -DCMAKE_C_FLAGS="-DNDEBUG ${configure.cflags}" \
     120#                                 -DCMAKE_CXX_FLAGS="-DNDEBUG ${configure.cxxflags}"
     121#     }
     122    # Using a custom BUILD_TYPE we can simply append to the env. variables,
     123    # but why do we set -DNDEBUG?
     124    configure.cflags-append     -DNDEBUG
     125    configure.cxxflags-append   -DNDEBUG
     126
     127    # process ${configure.cppflags} to extract include directives and other options
     128    if {${configure.cppflags} ne ""} {
     129        set cppflags [split ${configure.cppflags}]
     130        # reset configure.cppflags; we don't want options in double in CPPFLAGS and CFLAGS/CXXFLAGS
     131        configure.cppflags-delete   ${configure.cppflags}
     132        set next_is_path 0
     133        foreach flag ${cppflags} {
     134            if {${next_is_path}} {
     135                # previous option was a lone -I
     136                configure.cppflags-append       -I${flag}
     137                set next_is_path 0
     138            } else {
     139                if {[string match "-I" ${flag}]} {
     140                    # lone -I, store the next argument as a path
     141                    # (or ignore if this is the last argument)
     142                    set next_is_path 1
     143                } elseif {[string match "-I*" ${flag}]} {
     144                    # a -Ipath option
     145                    configure.cppflags-append   ${flag}
     146                } else {
     147                    # everything else must go into CFLAGS and CXXFLAGS
     148                    configure.cflags-append     ${flag}
     149                    configure.cxxflags-append   ${flag}
     150                    # append to the ObjC flags too, even if CMake ignores them:
     151                    configure.objcflags-append  ${flag}
     152                    configure.objcxxflags-append   ${flag}
     153                }
     154            }
     155        }
     156        ui_debug "-DINCLUDE_DIRECTORIES=${configure.cppflags}"
     157        ui_debug "CFLAGS=\"${configure.cflags}\" CXXFLAGS=\"${configure.cxxflags}\""
     158        configure.args-append   -DINCLUDE_DIRECTORIES:PATH="${configure.cppflags}"
    119159    }
    120160}
    121161
    122 platform darwin {
    123     set cmake._archflag_vars {cc_archflags cxx_archflags ld_archflags objc_archflags objcxx_archflags universal_cflags universal_cxxflags universal_ldflags universal_objcflags universal_objcxxflags}
     162post-configure {
     163    if {![catch {set fd [open "${workpath}/.macports.${subport}.configure.cmd" "w"]} err]} {
     164        foreach var [array names ::env] {
     165            puts ${fd} "${var}=$::env(${var})"
     166        }
     167        puts ${fd} "[join [lrange [split ${configure.env} " "] 0 end] "\n"]\n"
     168        puts ${fd} "cd ${worksrcpath}"
     169        puts ${fd} "${configure.cmd} ${configure.pre_args} ${configure.args} ${configure.post_args}"
     170        close ${fd}
     171        unset fd
     172    }
     173}
    124174
     175platform darwin {
     176    set cmake._archflag_vars {cc_archflags cxx_archflags ld_archflags objc_archflags objcxx_archflags \
     177        universal_cflags universal_cxxflags universal_ldflags universal_objcflags universal_objcxxflags}
    125178    pre-configure {
    126179        # cmake will add the correct -arch flag(s) based on the value of CMAKE_OSX_ARCHITECTURES.
    127180        if {[variant_exists universal] && [variant_isset universal]} {
     
    162215            configure.args-append -DCMAKE_OSX_SYSROOT="/"
    163216        }
    164217    }
    165 
    166218    post-configure {
    167219        # Although cmake wants us not to set -arch flags ourselves when we run cmake,
    168220        # ports might have need to access these variables at other times.