| 89 | proc cmake.install_rpath {mode path} { |
| 90 | upvar #0 cmake_install_rpath rpath |
| 91 | if {${path} ne ""} { |
| 92 | switch -nocase ${mode} { |
| 93 | append {set newpath "${rpath}\;${path}"} |
| 94 | prepend {set newpath "${path}\;${rpath}"} |
| 95 | reset {set newpath "${path}"} |
| 96 | default { |
| 97 | ui_error "Usage: cmake.install_rpath <append|prepend|reset> <path>" |
| 98 | return -code error "Invalid invocation of cmake.install_rpath" |
| 99 | } |
| 100 | } |
| 101 | configure.args-replace \ |
| 102 | -DCMAKE_INSTALL_RPATH="${rpath}" \ |
| 103 | -DCMAKE_INSTALL_RPATH="${newpath}" |
| 104 | set rpath ${newpath} |
| 105 | } |
| 106 | } |
| 107 | |
116 | | if {${configure.optflags} ne ""} { |
117 | | configure.args-append -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \ |
118 | | -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" |
| 145 | # NB: more recent CMake versions (>=3?) no longer take the env. variables into |
| 146 | # account, and thus require explicit use of ${configure.c*flags} below: |
| 147 | # if {${configure.optflags} ne ""} { |
| 148 | # configure.args-append -DCMAKE_C_FLAGS="-DNDEBUG ${configure.cflags}" \ |
| 149 | # -DCMAKE_CXX_FLAGS="-DNDEBUG ${configure.cxxflags}" |
| 150 | # } |
| 151 | # Using a custom BUILD_TYPE we can simply append to the env. variables, |
| 152 | # but why do we set -DNDEBUG? |
| 153 | configure.cflags-append -DNDEBUG |
| 154 | configure.cxxflags-append -DNDEBUG |
| 155 | # force newer CMake versions to take a change in compiler choice into account |
| 156 | # even if it is invoked in a build.dir that was configured before. |
| 157 | if {${configure.cc} ne ""} { |
| 158 | configure.args-append \ |
| 159 | -DCMAKE_C_COMPILER=${configure.cc} |
| 160 | } |
| 161 | if {${configure.cxx} ne ""} { |
| 162 | configure.args-append \ |
| 163 | -DCMAKE_CXX_COMPILER=${configure.cxx} |
| 164 | } |
| 165 | |
| 166 | |
| 167 | # process ${configure.cppflags} to extract include directives and other options |
| 168 | if {${configure.cppflags} ne ""} { |
| 169 | set cppflags [split ${configure.cppflags}] |
| 170 | # reset configure.cppflags; we don't want options in double in CPPFLAGS and CFLAGS/CXXFLAGS |
| 171 | set configure.cppflags "" |
| 172 | set next_is_path 0 |
| 173 | foreach flag ${cppflags} { |
| 174 | if {${next_is_path}} { |
| 175 | # previous option was a lone -I |
| 176 | configure.cppflags-append -I${flag} |
| 177 | set next_is_path 0 |
| 178 | } else { |
| 179 | if {[string match "-I" ${flag}]} { |
| 180 | # lone -I, store the next argument as a path |
| 181 | # (or ignore if this is the last argument) |
| 182 | set next_is_path 1 |
| 183 | } elseif {[string match "-I*" ${flag}]} { |
| 184 | # a -Ipath option |
| 185 | configure.cppflags-append ${flag} |
| 186 | } else { |
| 187 | # everything else must go into CFLAGS and CXXFLAGS |
| 188 | configure.cflags-append ${flag} |
| 189 | configure.cxxflags-append ${flag} |
| 190 | # append to the ObjC flags too, even if CMake ignores them: |
| 191 | configure.objcflags-append ${flag} |
| 192 | configure.objcxxflags-append ${flag} |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | if {${configure.cppflags} ne ""} { |
| 197 | ui_debug "-DINCLUDE_DIRECTORIES=${configure.cppflags}" |
| 198 | configure.args-append -DINCLUDE_DIRECTORIES:PATH="${configure.cppflags}" |
| 199 | } |
| 200 | ui_debug "CFLAGS=\"${configure.cflags}\" CXXFLAGS=\"${configure.cxxflags}\"" |
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} |
| 204 | post-configure { |
| 205 | # either compile_commands.json was created because of -DCMAKE_EXPORT_COMPILE_COMMANDS=ON |
| 206 | # in which case touch'ing it won't change anything. Or else it wasn't created, in which case |
| 207 | # we'll create a file that corresponds, i.e. containing an empty json array. |
| 208 | if {![file exists ${build.dir}/compile_commands.json]} { |
| 209 | if {![catch {set fd [open "${build.dir}/compile_commands.json" "w"]} err]} { |
| 210 | puts ${fd} "\[\n\]" |
| 211 | close ${fd} |
| 212 | } |
| 213 | } |
| 214 | if {![catch {set fd [open "${workpath}/.macports.${subport}.configure.cmd" "w"]} err]} { |
| 215 | foreach var [array names ::env] { |
| 216 | puts ${fd} "${var}=$::env(${var})" |
| 217 | } |
| 218 | puts ${fd} "[join [lrange [split ${configure.env} " "] 0 end] "\n"]" |
| 219 | # the following variables are no longer set in the environment at this point: |
| 220 | puts ${fd} "CPP=\"${configure.cpp}\"" |
| 221 | puts ${fd} "CC=\"${configure.cc}\"" |
| 222 | puts ${fd} "CXX=\"${configure.cxx}\"" |
| 223 | if {${configure.objcxx} ne ${configure.cxx}} { |
| 224 | puts ${fd} "OBJCXX=\"${configure.objcxx}\"" |
| 225 | } |
| 226 | puts ${fd} "CFLAGS=\"${configure.cflags}\"" |
| 227 | puts ${fd} "CXXFLAGS=\"${configure.cxxflags}\"" |
| 228 | if {${configure.objcflags} ne ${configure.cflags}} { |
| 229 | puts ${fd} "OBJCFLAGS=\"${configure.objcflags}\"" |
| 230 | } |
| 231 | if {${configure.objcxxflags} ne ${configure.cxxflags}} { |
| 232 | puts ${fd} "OBJCXXFLAGS=\"${configure.objcxxflags}\"" |
| 233 | } |
| 234 | puts ${fd} "LDFLAGS=\"${configure.ldflags}\"" |
| 235 | if {${configure.optflags} ne ""} { |
| 236 | puts ${fd} "configure.optflags=\"${configure.optflags}\"" |
| 237 | } |
| 238 | puts ${fd} "\ncd ${worksrcpath}" |
| 239 | puts ${fd} "${configure.cmd} ${configure.pre_args} ${configure.args} ${configure.post_args}" |
| 240 | close ${fd} |
| 241 | unset fd |
| 242 | } |
| 243 | } |