Ticket #40648: patch-cmake-portgroup.diff

File patch-cmake-portgroup.diff, 6.0 KB (added by maehne (Torsten Maehne), 11 years ago)
  • ports/_resources/port1.0/group/cmake-1.0.tcl

    diff --git a/ports/_resources/port1.0/group/cmake-1.0.tcl b/ports/_resources/port1.0/group/cmake-1.0.tcl
    index 085a820..6571141 100644
    a b configure.args -DCMAKE_VERBOSE_MAKEFILE=ON \ 
    5656                    -DCMAKE_FIND_FRAMEWORK=LAST \
    5757                    -Wno-dev
    5858
    59 # Handle configure.cppflags, configure.optflags, configure.cflags,
    60 # configure.cxxflags, configure.ldflags by setting the equivalent CMAKE_*_FLAGS.
    61 #
    62 # Be aware that a CMake script can always override these flags when it runs, as
    63 # they are frequently set internally in function of other CMake build variables!
     59# CMake honors set environment variables CFLAGS, CXXFLAGS, and LDFLAGS when it
     60# is first run in a build directory to initialize CMAKE_C_FLAGS,
     61# CMAKE_CXX_FLAGS, CMAKE_[EXE|SHARED|MODULE]_LINKER_FLAGS. However, be aware
     62# that a CMake script can always override these flags when it runs, as they
     63# are frequently set internally in function of other CMake build variables!
    6464#
    6565# Attention: If you want to be sure that no compiler flags are passed via
    66 # configure.args, you have to set manually configure.optflags to "", as it is by
    67 # default "-O2" and added to all language-specific flags. If you want to turn off
    68 # optimization, explicitly set configue.optflags to "-O0".
    69 if {${configure.cppflags} != ""} {
    70     # Add the preprocessor flags to the C/C++ compiler flags as CMake does not
    71     # honor separately CPPFLAGS (it uses usually add_definitions() for that).
    72     # We use the compiler flags for all build types, as they are usually empty.
    73     # Cf. also to CMake upstream ticket #12928 "CMake silently ignores CPPFLAGS"
    74     # <http://www.cmake.org/Bug/view.php?id=12928>.
    75     configure.args-append -DCMAKE_C_FLAGS="${configure.cppflags}"
    76     configure.args-append -DCMAKE_CXX_FLAGS="${configure.cppflags}"
    77 }
    78 if {${configure.cflags} != ""} {
    79     # The configure.cflags contain configure.optflags by default. Therefore, we
    80     # set the Release flags, which would otherwise overrule the optimization
    81     # flags, as they are set by default to "-O3 -NDEBUG". Therefore, be sure
    82     # to add "-NDEBUG" to the configure.cflags if you want to turn off
    83     # assertions in release builds!
    84     configure.args-append -DCMAKE_C_FLAGS_RELEASE="${configure.cflags}"
    85 }
    86 set cxx_stdlibflags {}
    87 if {[info exists configure.cxx_stdlib] &&
    88     ${configure.cxx_stdlib} ne {} &&
    89     [string match *clang* ${configure.cxx}]} {
    90     set cxx_stdlibflags -stdlib=${configure.cxx_stdlib}
    91 }
    92 if {${configure.cxxflags} != "" || ${cxx_stdlibflags} != ""} {
    93     # The configure.cxxflags contain configure.optflags by default. Therefore,
    94     # we set the Release flags, which would otherwise overrule the optimization
    95     # flags, as they are set by default to "-O3 -NDEBUG". Therefore, be sure
    96     # to add "-NDEBUG" to the configure.cflags if you want to turn off
    97     # assertions in release builds!
    98     configure.args-append -DCMAKE_CXX_FLAGS_RELEASE="${configure.cxxflags} ${cxx_stdlibflags}"
    99 }
    100 if {${configure.ldflags} != ""} {
    101     # CMake supports individual linker flags for executables, modules, and dlls.
    102     # By default, they are empty.
    103     configure.args-append -DCMAKE_EXE_LINKER_FLAGS="${configure.ldflags}"
    104     configure.args-append -DCMAKE_SHARED_LINKER_FLAGS="${configure.ldflags}"
    105     configure.args-append -DCMAKE_MODULE_LINKER_FLAGS="${configure.ldflags}"
    106 }
     66# configure.args, you have to set manually configure.optflags to "", as it is
     67# by default "-O2" and added to all language-specific flags. If you want to
     68# turn off optimization, explicitly set configue.optflags to "-O0".
    10769
    10870# TODO: Handle configure.objcflags (cf. to CMake upstream ticket #4756
    10971#       "CMake needs an Objective-C equivalent of CMAKE_CXX_FLAGS"
    if {${configure.ldflags} != ""} { 
    11476
    11577# TODO: Handle the Java-specific configure.classpath variable.
    11678
    117 platform darwin {
    118     pre-configure {
     79pre-configure {
     80    # The environment variable CPPFLAGS is not considered by CMake.
     81    # (CMake upstream ticket #12928 "CMake silently ignores CPPFLAGS"
     82    # <http://www.cmake.org/Bug/view.php?id=12928>).
     83    # Thus, we have to add them manually to the CFLAGS and CXXFLAGS in the
     84    # pre-configure phase.
     85    if {${configure.cppflags} != ""} {
     86        configure.cflags-append ${configure.cppflags}
     87        configure.cxxflags-append ${configure.cppflags}
     88    }
     89
     90    # In addition, CMake provides build-type-specific flags for
     91    # Release (-O3 -DNDEBUG), Debug (-g), MinSizeRel (-Os -DNDEBUG), and
     92    # RelWithDebInfo (-O2 -g -DNDEBUG). If the configure.optflags have been
     93    # set (-O2 by default), we have to remove the optimization flags from the
     94    # from the concerned Release build type so that configure.optflags
     95    # gets honored (Debug used by the +debug variant does not set
     96    # optimization flags by default).
     97    if {${configure.optflags} != ""} {
     98        configure.args-append -DCMAKE_C_FLAGS_RELEASE="-NDEBUG" \
     99                              -DCMAKE_CXX_FLAGS_RELEASE="-NDEBUG"
     100    }
     101
     102    platform darwin {
    119103        if {[variant_exists universal] && [variant_isset universal]} {
    120104            if {[info exists universal_archs_supported]} {
    121105                global merger_configure_args
    configure.universal_args-delete --disable-dependency-tracking 
    144128variant debug description "Enable debug binaries" {
    145129    configure.args-delete   -DCMAKE_BUILD_TYPE=Release
    146130    configure.args-append   -DCMAKE_BUILD_TYPE=Debug
    147     # Consider the configure.cflags and configure.cxxflags for Debug builds.
    148     # Attention, they contain configure.optflags by default!
    149     if {${configure.cflags} != ""} {
    150         configure.args-append -DCMAKE_C_FLAGS_DEBUG="-g ${configure.cflags}"
    151     }
    152     if {${configure.cxxflags} != "" || ${cxx_stdlibflags} != ""} {
    153         configure.args-append -DCMAKE_CXX_FLAGS_DEBUG="-g ${configure.cxxflags} ${cxx_stdlibflags}"
    154     }
    155131}
    156132
    157133# cmake doesn't like --enable-debug, so in case a portfile sets