116 | | if {${configure.optflags} ne ""} { |
117 | | configure.args-append -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \ |
118 | | -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" |
| 117 | # NB: more recent CMake versions (>=3?) no longer take the env. variables into |
| 118 | # account, and thus require explicit use of ${configure.c*flags} below: |
| 119 | # if {${configure.optflags} ne ""} { |
| 120 | # configure.args-append -DCMAKE_C_FLAGS="-DNDEBUG ${configure.cflags}" \ |
| 121 | # -DCMAKE_CXX_FLAGS="-DNDEBUG ${configure.cxxflags}" |
| 122 | # } |
| 123 | # Using a custom BUILD_TYPE we can simply append to the env. variables, |
| 124 | # but why do we set -DNDEBUG? |
| 125 | configure.cflags-append -DNDEBUG |
| 126 | configure.cxxflags-append -DNDEBUG |
| 127 | |
| 128 | # process ${configure.cppflags} to extract include directives and other options |
| 129 | if {${configure.cppflags} ne ""} { |
| 130 | set cppflags [split ${configure.cppflags}] |
| 131 | # reset configure.cppflags; we don't want options in double in CPPFLAGS and CFLAGS/CXXFLAGS |
| 132 | configure.cppflags-delete ${configure.cppflags} |
| 133 | set next_is_path 0 |
| 134 | foreach flag ${cppflags} { |
| 135 | if {${next_is_path}} { |
| 136 | # previous option was a lone -I |
| 137 | configure.cppflags-append -I${flag} |
| 138 | set next_is_path 0 |
| 139 | } else { |
| 140 | if {[string match "-I" ${flag}]} { |
| 141 | # lone -I, store the next argument as a path |
| 142 | # (or ignore if this is the last argument) |
| 143 | set next_is_path 1 |
| 144 | } elseif {[string match "-I*" ${flag}]} { |
| 145 | # a -Ipath option |
| 146 | configure.cppflags-append ${flag} |
| 147 | } else { |
| 148 | # everything else must go into CFLAGS and CXXFLAGS |
| 149 | configure.cflags-append ${flag} |
| 150 | configure.cxxflags-append ${flag} |
| 151 | # append to the ObjC flags too, even if CMake ignores them: |
| 152 | configure.objcflags-append ${flag} |
| 153 | configure.objcxxflags-append ${flag} |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | ui_debug "-DINCLUDE_DIRECTORIES=${configure.cppflags}" |
| 158 | ui_debug "CFLAGS=\"${configure.cflags}\" CXXFLAGS=\"${configure.cxxflags}\"" |
| 159 | configure.args-append -DINCLUDE_DIRECTORIES:PATH="${configure.cppflags}" |
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} |
| 163 | post-configure { |
| 164 | # either compile_commands.json was created because of -DCMAKE_EXPORT_COMPILE_COMMANDS=ON |
| 165 | # in which case touch'ing it won't change anything. Or else it wasn't created, in which case |
| 166 | # we'll create a file that corresponds, i.e. containing an empty json array. |
| 167 | if {![file exists ${build.dir}/compile_commands.json]} { |
| 168 | if {![catch {set fd [open "${build.dir}/compile_commands.json" "w"]} err]} { |
| 169 | puts ${fd} "\[\n\]" |
| 170 | close ${fd} |
| 171 | } |
| 172 | } |
| 173 | if {![catch {set fd [open "${workpath}/.macports.${subport}.configure.cmd" "w"]} err]} { |
| 174 | foreach var [array names ::env] { |
| 175 | puts ${fd} "${var}=$::env(${var})" |
| 176 | } |
| 177 | puts ${fd} "[join [lrange [split ${configure.env} " "] 0 end] "\n"]\n" |
| 178 | puts ${fd} "cd ${worksrcpath}" |
| 179 | puts ${fd} "${configure.cmd} ${configure.pre_args} ${configure.args} ${configure.post_args}" |
| 180 | close ${fd} |
| 181 | unset fd |
| 182 | } |
| 183 | } |