| 82 | proc cmake.install_rpath {mode path} { |
| 83 | upvar #0 cmake_install_rpath rpath |
| 84 | if {${path} ne ""} { |
| 85 | switch -nocase ${mode} { |
| 86 | append {set newpath "${rpath}\;${path}"} |
| 87 | prepend {set newpath "${path}\;${rpath}"} |
| 88 | reset {set newpath "${path}"} |
| 89 | default { |
| 90 | ui_error "Usage: cmake.install_rpath <append|prepend|reset> <path>" |
| 91 | return -code error "Invalid invocation of cmake.install_rpath" |
| 92 | } |
| 93 | } |
| 94 | configure.args-replace \ |
| 95 | -DCMAKE_INSTALL_RPATH="${rpath}" \ |
| 96 | -DCMAKE_INSTALL_RPATH="${newpath}" |
| 97 | set rpath ${newpath} |
| 98 | } |
| 99 | } |
| 100 | |
116 | | if {${configure.optflags} ne ""} { |
117 | | configure.args-append -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \ |
118 | | -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" |
| 138 | # NB: more recent CMake versions (>=3?) no longer take the env. variables into |
| 139 | # account, and thus require explicit use of ${configure.c*flags} below: |
| 140 | # if {${configure.optflags} ne ""} { |
| 141 | # configure.args-append -DCMAKE_C_FLAGS="-DNDEBUG ${configure.cflags}" \ |
| 142 | # -DCMAKE_CXX_FLAGS="-DNDEBUG ${configure.cxxflags}" |
| 143 | # } |
| 144 | # Using a custom BUILD_TYPE we can simply append to the env. variables, |
| 145 | # but why do we set -DNDEBUG? |
| 146 | configure.cflags-append -DNDEBUG |
| 147 | configure.cxxflags-append -DNDEBUG |
| 148 | |
| 149 | # process ${configure.cppflags} to extract include directives and other options |
| 150 | if {${configure.cppflags} ne ""} { |
| 151 | set cppflags [split ${configure.cppflags}] |
| 152 | # reset configure.cppflags; we don't want options in double in CPPFLAGS and CFLAGS/CXXFLAGS |
| 153 | configure.cppflags-delete ${configure.cppflags} |
| 154 | set next_is_path 0 |
| 155 | foreach flag ${cppflags} { |
| 156 | if {${next_is_path}} { |
| 157 | # previous option was a lone -I |
| 158 | configure.cppflags-append -I${flag} |
| 159 | set next_is_path 0 |
| 160 | } else { |
| 161 | if {[string match "-I" ${flag}]} { |
| 162 | # lone -I, store the next argument as a path |
| 163 | # (or ignore if this is the last argument) |
| 164 | set next_is_path 1 |
| 165 | } elseif {[string match "-I*" ${flag}]} { |
| 166 | # a -Ipath option |
| 167 | configure.cppflags-append ${flag} |
| 168 | } else { |
| 169 | # everything else must go into CFLAGS and CXXFLAGS |
| 170 | configure.cflags-append ${flag} |
| 171 | configure.cxxflags-append ${flag} |
| 172 | # append to the ObjC flags too, even if CMake ignores them: |
| 173 | configure.objcflags-append ${flag} |
| 174 | configure.objcxxflags-append ${flag} |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | ui_debug "-DINCLUDE_DIRECTORIES=${configure.cppflags}" |
| 179 | ui_debug "CFLAGS=\"${configure.cflags}\" CXXFLAGS=\"${configure.cxxflags}\"" |
| 180 | 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} |
| 184 | post-configure { |
| 185 | # either compile_commands.json was created because of -DCMAKE_EXPORT_COMPILE_COMMANDS=ON |
| 186 | # in which case touch'ing it won't change anything. Or else it wasn't created, in which case |
| 187 | # we'll create a file that corresponds, i.e. containing an empty json array. |
| 188 | if {![file exists ${build.dir}/compile_commands.json]} { |
| 189 | if {![catch {set fd [open "${build.dir}/compile_commands.json" "w"]} err]} { |
| 190 | puts ${fd} "\[\n\]" |
| 191 | close ${fd} |
| 192 | } |
| 193 | } |
| 194 | if {![catch {set fd [open "${workpath}/.macports.${subport}.configure.cmd" "w"]} err]} { |
| 195 | foreach var [array names ::env] { |
| 196 | puts ${fd} "${var}=$::env(${var})" |
| 197 | } |
| 198 | puts ${fd} "[join [lrange [split ${configure.env} " "] 0 end] "\n"]\n" |
| 199 | puts ${fd} "cd ${worksrcpath}" |
| 200 | puts ${fd} "${configure.cmd} ${configure.pre_args} ${configure.args} ${configure.post_args}" |
| 201 | close ${fd} |
| 202 | unset fd |
| 203 | } |
| 204 | } |