├── .gitignore ├── .travis.yml ├── Formula └── qgis3-dev.rb ├── README.md ├── development └── README.md ├── scripts ├── qgis-cmake-setup.sh ├── qgis-dev-build.sh ├── qgis-dev-ctest.sh ├── qgis-dev-install.sh ├── qgis-dev.env └── qgis-set-app-env.py └── travis ├── after_script.sh ├── before_install.sh ├── before_script.sh ├── install.sh └── script.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | os: osx 3 | env: OSX=10.12 4 | osx_image: xcode8.1 5 | rvm: system 6 | sudo: required 7 | 8 | before_install: 9 | - export TRAVIS_COMMIT="$(git rev-parse --verify -q HEAD)" 10 | - export CHANGED_FORMULAE="$(git diff --name-status $TRAVIS_COMMIT^ $TRAVIS_COMMIT | sed -n -E 's#^(A|M)[[:space:]]+Formula/(.+)\.rb$#\2#p' )" 11 | - if [ "${CHANGED_FORMULAE}" == "" ]; then 12 | echo "Skipping CI; no changed formulae found in $TRAVIS_BUILD_DIR"; 13 | travis_terminate 0; 14 | else 15 | echo "Changed formulae are ${CHANGED_FORMULAE}"; 16 | fi 17 | - export HOMEBREW_REPOSITORY="$(brew --repo)" 18 | - sudo chown -R "$USER" "$HOMEBREW_REPOSITORY" 19 | - git -C "$HOMEBREW_REPOSITORY" reset --hard origin/master 20 | - mkdir -p "$HOMEBREW_REPOSITORY/Library/Taps/qgis" 21 | - ln -s "$TRAVIS_BUILD_DIR" "$HOMEBREW_REPOSITORY/Library/Taps/qgis/homebrew-qgisdev" 22 | - cd "$HOMEBREW_REPOSITORY/Library/Taps/qgis/homebrew-qgisdev" 23 | - chmod -f 0644 $HOMEBREW_REPOSITORY/Library/Taps/qgis/homebrew-qgisdev/Formula/*.rb 24 | - export TRAVIS_BUILD_DIR="$HOMEBREW_REPOSITORY/Library/Taps/qgis/homebrew-qgisdev" 25 | - export HOMEBREW_DEVELOPER="1" 26 | - export HOMEBREW_PREFIX=$(brew --prefix) 27 | - ulimit -n 1024 28 | - ./travis/before_install.sh 29 | 30 | install: ./travis/install.sh 31 | 32 | #before_script: ./travis/before_script.sh 33 | 34 | script: ./travis/script.sh 35 | 36 | #after_script: ./travis/after_script.sh 37 | -------------------------------------------------------------------------------- /Formula/qgis3-dev.rb: -------------------------------------------------------------------------------- 1 | class Qgis3DevUnlinkedFormulae < Requirement 2 | fatal true 3 | satisfy(:build_env => false) { !qt4_linked && !pyqt4_linked && !txt2tags_linked } 4 | 5 | def qt4_linked 6 | (Formula["qt"].linked_keg/"lib/QtCore.framework/Versions/4").exist? 7 | rescue 8 | return false 9 | end 10 | 11 | def pyqt4_linked 12 | (Formula["pyqt"].linked_keg/"lib/python2.7/site-packages/PyQt").exist? 13 | rescue 14 | return false 15 | end 16 | 17 | def txt2tags_linked 18 | Formula["txt2tags"].linked_keg.exist? 19 | rescue 20 | return false 21 | end 22 | 23 | def message 24 | s = "Compilation can fail if these formulae are installed and linked:\n\n" 25 | 26 | s += "Unlink with `brew unlink qt` or remove with `brew uninstall qt`\n" if qt4_linked 27 | s += "Unlink with `brew unlink pyqt` or remove with `brew uninstall pyqt`\n" if pyqt4_linked 28 | s += "Unlink with `brew unlink txt2tags` or remove with `brew uninstall txt2tags`\n" if txt2tags_linked 29 | s 30 | end 31 | end 32 | 33 | class Qgis3Dev < Formula 34 | desc "User friendly open source Geographic Information System" 35 | homepage "https://www.qgis.org" 36 | 37 | url "https://github.com/qgis/QGIS.git", :branch => "master" 38 | version "2.99" 39 | 40 | option "without-ninja", "Disable use of ninja CMake generator" 41 | option "without-debug", "Disable debug build, which outputs info to system.log or console" 42 | option "without-qt5-webkit", "Build without webkit based functionality" 43 | option "without-pyqt5-webkit", "Build without webkit python bindings" 44 | option "without-server", "Build without QGIS Server (qgis_mapserv.fcgi)" 45 | option "without-postgresql", "Build without current PostgreSQL client" 46 | option "with-globe", "Build with Globe plugin, based upon osgEarth" 47 | option "with-grass", "Build with GRASS 7 integration plugin and Processing plugin support (or install grass-7x first)" 48 | option "with-oracle", "Build extra Oracle geospatial database and raster support" 49 | option "with-orfeo5", "Build extra Orfeo Toolbox for Processing plugin" 50 | option "with-r", "Build extra R for Processing plugin" 51 | option "with-saga-gis-lts", "Build extra Saga GIS for Processing plugin" 52 | # option "with-qt-mysql", "Build extra Qt MySQL plugin for eVis plugin" 53 | option "with-qspatialite", "Build QSpatialite Qt database driver" 54 | option "with-api-docs", "Build the API documentation with Doxygen and Graphviz" 55 | option "with-3d", "Build with 3D Map View panel" 56 | 57 | depends_on Qgis3DevUnlinkedFormulae 58 | 59 | # core qgis 60 | depends_on "cmake" => :build 61 | depends_on "ninja" => [:build, :recommended] 62 | depends_on "bison" => :build 63 | depends_on "flex" => :build 64 | if build.with? "api-docs" 65 | depends_on "graphviz" 66 | depends_on "doxygen" 67 | end 68 | 69 | depends_on :python3 70 | 71 | depends_on "qt" # keg_only 72 | depends_on "osgeo/osgeo4mac/qt5-webkit" => :recommended # keg_only 73 | depends_on "sip" 74 | depends_on "pyqt" 75 | depends_on "osgeo/osgeo4mac/pyqt5-webkit" => :recommended 76 | depends_on "qca" 77 | depends_on "qtkeychain" 78 | depends_on "qscintilla2" 79 | depends_on "qwt" 80 | depends_on "qwtpolar" 81 | depends_on "gsl" 82 | depends_on "sqlite" # keg_only 83 | depends_on "expat" # keg_only 84 | depends_on "proj" 85 | depends_on "spatialindex" 86 | depends_on "homebrew/science/matplotlib" 87 | depends_on "fcgi" if build.with? "server" 88 | # use newer postgresql client than Apple's, also needed by `psycopg2` 89 | depends_on "postgresql" => :recommended 90 | depends_on "libzip" 91 | 92 | # needed for PKI authentication methods that require PKCS#8->PKCS#1 conversion 93 | depends_on "libtasn1" 94 | 95 | # core providers 96 | depends_on "osgeo/osgeo4mac/gdal2" # keg_only 97 | depends_on "osgeo/osgeo4mac/gdal2-python" # keg_only 98 | depends_on "osgeo/osgeo4mac/oracle-client-sdk" if build.with? "oracle" 99 | # TODO: add MSSQL third-party support formula?, :optional 100 | 101 | # core plugins (c++ and python) 102 | if build.with?("grass") || (HOMEBREW_PREFIX/"opt/grass7").exist? 103 | depends_on "osgeo/osgeo4mac/grass7" 104 | depends_on "gettext" # keg_only 105 | end 106 | 107 | # Not until osgearth is Qt5-ready 108 | # if build.with? "globe" 109 | # # this is pretty borked with OS X >= 10.10+ 110 | # depends on "open-scene-graph" 111 | # depends on "homebrew/science/osgearth" 112 | # end 113 | 114 | depends_on "gpsbabel" => :optional 115 | # TODO: remove "pyspatialite" when PyPi package supports spatialite 4.x 116 | # or DB Manager supports libspatialite >= 4.2.0 (with mod_spatialite) 117 | 118 | # TODO: what to do for Py3 and pyspatialite? 119 | # depends on "pyspatialite" # for DB Manager 120 | # depends on "qt-mysql" => :optional # for eVis plugin (non-functional in 2.x?) 121 | 122 | # core processing plugin extras 123 | # see `grass` above 124 | depends_on "osgeo/osgeo4mac/orfeo5" => :optional 125 | depends_on "r" => :optional 126 | depends_on "osgeo/osgeo4mac/saga-gis-lts" => :optional 127 | # TODO: LASTools straight build (2 reporting tools), or via `wine` (10 tools) 128 | # TODO: Fusion from USFS (via `wine`?) 129 | 130 | # TODO: add one for Py3 131 | # (only necessary when macOS ships a Python3 or 3rd-party isolation is needed) 132 | # resource "pyqgis-startup" do 133 | # url "https://gist.githubusercontent.com/dakcarto/11385561/raw/e49f75ecec96ed7d6d3950f45ad3f30fe94d4fb2/pyqgis_startup.py" 134 | # sha256 "385dce925fc2d29f05afd6508bc1f46ec84c0bc607cc0c8dfce78a4bb93b9c4e" 135 | # version "2.14.0" 136 | # end 137 | 138 | needs :cxx11 139 | 140 | def install 141 | ENV.cxx11 142 | 143 | # when gdal2-python.rb loaded, PYTHONPATH gets set to 2.7 site-packages... 144 | # clear it before calling any local python3 functions 145 | ENV["PYTHONPATH"] = nil 146 | if ARGV.debug? 147 | puts "python_exec: #{python_exec}" 148 | puts "py_ver: #{py_ver}" 149 | puts "brewed_python?: #{brewed_python?}" 150 | puts "python_site_packages: #{python_site_packages}" 151 | puts "python_prefix: #{python_prefix}" 152 | puts "qgis_python_packages: #{qgis_python_packages}" 153 | puts "gdal_python_packages: #{gdal_python_packages}" 154 | puts "gdal_python_opt_bin: #{gdal_python_opt_bin}" 155 | puts "gdal_opt_bin: #{gdal_opt_bin}" 156 | end 157 | 158 | # Vendor required python3 pkgs if they are missing 159 | # TODO: this should really be a requirements.txt in src tree 160 | py_req = %w[ 161 | future 162 | psycopg2 163 | python-dateutil 164 | httplib2 165 | pytz 166 | six 167 | nose2 168 | pygments 169 | jinja2 170 | pyyaml 171 | requests 172 | owslib 173 | ].freeze 174 | 175 | orig_user_base = ENV["PYTHONUSERBASE"] 176 | ENV["PYTHONUSERBASE"] = libexec/"python" 177 | system HOMEBREW_PREFIX/"bin/pip3", "install", "--user", *py_req 178 | ENV["PYTHONUSERBASE"] = orig_user_base 179 | 180 | # Set bundling level back to 0 (the default in all versions prior to 1.8.0) 181 | # so that no time and energy is wasted copying the Qt frameworks into QGIS. 182 | 183 | # Install custom widgets Designer plugin to local qt plugins prefix 184 | mkdir lib/"qt/plugins/designer" 185 | inreplace "src/customwidgets/CMakeLists.txt", 186 | "${QT_PLUGINS_DIR}/designer", lib/"qt/plugins/designer".to_s 187 | 188 | # Fix custom widgets Designer module install path 189 | mkdir lib/"python#{py_ver}/site-packages/PyQt5" 190 | inreplace "CMakeLists.txt", 191 | "${PYQT5_MOD_DIR}", lib/"python#{py_ver}/site-packages/PyQt5".to_s 192 | 193 | # Install db plugins to local qt plugins prefix 194 | if build.with? "qspatialite" 195 | mkdir lib/"qt/plugins/sqldrivers" 196 | inreplace "src/providers/spatialite/qspatialite/CMakeLists.txt", 197 | "${QT_PLUGINS_DIR}/sqldrivers", lib/"qt/plugins/sqldrivers".to_s 198 | end 199 | if build.with? "oracle" 200 | inreplace "src/providers/oracle/ocispatial/CMakeLists.txt", 201 | "${QT_PLUGINS_DIR}/sqldrivers", lib/"qt/plugins/sqldrivers".to_s 202 | end 203 | 204 | args = std_cmake_args 205 | args << "-DCMAKE_BUILD_TYPE=RelWithDebInfo" if build.with? "debug" # override 206 | 207 | cmake_prefixes = %w[ 208 | qt5 209 | qt5-webkit 210 | qscintilla2 211 | qwt 212 | qwtpolar 213 | qca 214 | gdal2 215 | gsl 216 | geos 217 | proj 218 | libspatialite 219 | spatialindex 220 | expat 221 | sqlite 222 | libzip 223 | flex 224 | bison 225 | fcgi 226 | ].freeze 227 | # Force CMake to search HB/opt paths first, so headers in HB/include are not found instead; 228 | # specifically, ensure any gdal v1 includes are not used 229 | args << "-DCMAKE_PREFIX_PATH=#{cmake_prefixes.map { |f| Formula[f.to_s].opt_prefix }.join(";")}" 230 | 231 | args += %w[ 232 | -DENABLE_TESTS=FALSE 233 | -DENABLE_MODELTEST=FALSE 234 | -DQGIS_MACAPP_BUNDLE=0 235 | -DQGIS_MACAPP_INSTALL_DEV=FALSE 236 | -DWITH_QWTPOLAR=TRUE 237 | -DWITH_INTERNAL_QWTPOLAR=FALSE 238 | -DWITH_ASTYLE=FALSE 239 | -DWITH_QSCIAPI=TRUE 240 | -DWITH_STAGED_PLUGINS=TRUE 241 | -DWITH_GRASS=FALSE 242 | -DWITH_CUSTOM_WIDGETS=TRUE 243 | ] 244 | 245 | args << "-DWITH_QTWEBKIT=#{build.with?("qt5-webkit") ? "TRUE" : "FALSE"}" 246 | 247 | # Prefer opt_prefix for CMake modules that find versioned prefix by default 248 | # This keeps non-critical dependency upgrades from breaking QGIS linking 249 | args << "-DGDAL_LIBRARY=#{Formula["gdal2"].opt_lib}/libgdal.dylib" 250 | args << "-DGEOS_LIBRARY=#{Formula["geos"].opt_lib}/libgeos_c.dylib" 251 | args << "-DGSL_CONFIG=#{Formula["gsl"].opt_bin}/gsl-config" 252 | args << "-DGSL_INCLUDE_DIR=#{Formula["gsl"].opt_include}" 253 | args << "-DGSL_LIBRARIES='-L#{Formula["gsl"].opt_lib} -lgsl -lgslcblas'" 254 | 255 | args << "-DWITH_SERVER=#{build.with?("server") ? "TRUE" : "FALSE"}" 256 | 257 | args << "-DPOSTGRES_CONFIG=#{Formula["postgresql"].opt_bin}/pg_config" if build.with? "postgresql" 258 | 259 | args << "-DWITH_GRASS7=#{(build.with?("grass") || brewed_grass7?) ? "TRUE" : "FALSE"}" 260 | if build.with?("grass") || brewed_grass7? 261 | # this is to build the GRASS Plugin, not for Processing plugin support 262 | grass7 = Formula["grass7"] 263 | args << "-DGRASS_PREFIX7='#{grass7.opt_prefix}/grass-base'" 264 | # Keep superenv from stripping (use Cellar prefix) 265 | ENV.append "CXXFLAGS", "-isystem #{grass7.prefix.resolved_path}/grass-base/include" 266 | # So that `libintl.h` can be found (use Cellar prefix; should not be needed anymore with QGIS 2.99+) 267 | # ENV.append "CXXFLAGS", "-isystem #{Formula["gettext"].include.resolved_path}" 268 | end 269 | 270 | args << "-DWITH_GLOBE=#{build.with?("globe") ? "TRUE" : "FALSE"}" 271 | if build.with? "globe" 272 | osg = Formula["open-scene-graph"] 273 | opoo "`open-scene-graph` formula's keg not linked." unless osg.linked_keg.exist? 274 | # must be HOMEBREW_PREFIX/lib/osgPlugins-#.#.#, since all osg plugins are symlinked there 275 | args << "-DOSG_PLUGINS_PATH=#{HOMEBREW_PREFIX}/lib/osgPlugins-#{osg.version}" 276 | end 277 | 278 | args << "-DWITH_ORACLE=#{build.with?("oracle") ? "TRUE" : "FALSE"}" 279 | if build.with? "oracle" 280 | oracle_opt = Formula["oracle-client-sdk"].opt_prefix 281 | args << "-DOCI_INCLUDE_DIR=#{oracle_opt}/include/oci" 282 | args << "-DOCI_LIBRARY=#{oracle_opt}/lib/libclntsh.dylib" 283 | end 284 | 285 | args << "-DWITH_QSPATIALITE=#{build.with?("qspatialite") ? "TRUE" : "FALSE"}" 286 | 287 | args << "-DWITH_APIDOC=#{build.with?("api-docs") ? "TRUE" : "FALSE"}" 288 | 289 | args << "-DWITH_3D=#{build.with?("3d") ? "TRUE" : "FALSE"}" 290 | 291 | # nix clang tidy runs 292 | args << "-DCLANG_TIDY_EXE=" 293 | 294 | # if using Homebrew's Python, make sure its components are always found first 295 | # see: https://github.com/Homebrew/homebrew/pull/28597 296 | ENV["PYTHONHOME"] = python_prefix 297 | 298 | # handle custom site-packages for keg-only modules and packages 299 | ENV.append_path "PYTHONPATH", python_site_packages 300 | ENV.append_path "PYTHONPATH", libexec/"python/lib/python/site-packages" 301 | 302 | # handle some compiler warnings 303 | # ENV["CXX_EXTRA_FLAGS"] = "-Wno-unused-private-field -Wno-deprecated-register" 304 | # if ENV.compiler == :clang && (MacOS::Xcode.version >= "7.0" || MacOS::CLT.version >= "7.0") 305 | # ENV.append "CXX_EXTRA_FLAGS", "-Wno-inconsistent-missing-override" 306 | # end 307 | 308 | ENV.prepend_path "PATH", libexec/"python/bin" 309 | 310 | mkdir "build" do 311 | # editor = "/usr/local/bin/bbedit" 312 | # cmake_config = Pathname("#{Dir.pwd}/#{name}_cmake-config.txt") 313 | # cmake_config.write ["cmake ..", *args].join(" \\\n") 314 | # system editor, cmake_config.to_s 315 | # raise 316 | system "cmake", "-G", build.with?("ninja") ? "Ninja" : "Unix Makefiles", *args, ".." 317 | # system editor, "CMakeCache.txt" 318 | # raise 319 | system "cmake", "--build", ".", "--target", "all", "--", "-j", Hardware::CPU.cores 320 | system "cmake", "--build", ".", "--target", "install", "--", "-j", Hardware::CPU.cores 321 | end 322 | 323 | # Fixup some errant lib linking 324 | # TODO: fix upstream in CMake 325 | dy_libs = [lib/"qt/plugins/designer/libqgis_customwidgets.dylib"] 326 | dy_libs << lib/"qt/plugins/sqldrivers/libqsqlspatialite.dylib" if build.with? "qspatialite" 327 | dy_libs.each do |dy_lib| 328 | MachO::Tools.dylibs(dy_lib.to_s).each do |i_n| 329 | %w[core gui native].each do |f_n| 330 | sufx = i_n[/(qgis_#{f_n}\.framework.*)/, 1] 331 | next if sufx.nil? 332 | i_n_to = "#{opt_prefix}/QGIS.app/Contents/Frameworks/#{sufx}" 333 | puts "Changing install name #{i_n} to #{i_n_to} in #{dy_lib}" if ARGV.debug? 334 | dy_lib.ensure_writable do 335 | MachO::Tools.change_install_name(dy_lib.to_s, i_n.to_s, i_n_to, :strict => false) 336 | end 337 | end 338 | end 339 | end 340 | 341 | # Update .app's bundle identifier, so other installers doesn't get confused 342 | inreplace prefix/"QGIS.app/Contents/Info.plist", 343 | "org.qgis.qgis3", "org.qgis.qgis3-hb-dev" 344 | 345 | py_lib = lib/"python#{py_ver}/site-packages" 346 | py_lib.mkpath 347 | ln_s "../../../QGIS.app/Contents/Resources/python/qgis", py_lib/"qgis" 348 | 349 | ln_s "QGIS.app/Contents/MacOS/fcgi-bin", prefix/"fcgi-bin" if build.with? "server" 350 | 351 | doc.mkpath 352 | mv prefix/"QGIS.app/Contents/Resources/doc/api", doc/"api" if build.with? "api-docs" 353 | ln_s "../../../QGIS.app/Contents/Resources/doc", doc/"doc" 354 | 355 | # copy PYQGIS_STARTUP file pyqgis_startup.py, even if not isolating (so tap can be untapped) 356 | # only works with QGIS > 2.0.1 357 | # doesn't need executable bit set, loaded by Python runner in QGIS 358 | # TODO: for Py3 359 | # (libexec/"python").install resource("pyqgis-startup") 360 | 361 | bin.mkdir 362 | qgis_bin = bin/name.to_s 363 | touch qgis_bin.to_s # so it will be linked into HOMEBREW_PREFIX 364 | qgis_bin.chmod 0755 365 | post_install 366 | end 367 | 368 | def post_install 369 | # configure environment variables for .app and launching binary directly. 370 | # having this in `post_intsall` allows it to be individually run *after* installation with: 371 | # `brew postinstall -v ` 372 | 373 | app = prefix/"QGIS.app" 374 | tab = Tab.for_formula(self) 375 | opts = tab.used_options 376 | 377 | # define default isolation env vars 378 | pthsep = File::PATH_SEPARATOR 379 | pypth = python_site_packages.to_s 380 | pths = %w[ 381 | /usr/bin 382 | /bin 383 | /usr/sbin 384 | /sbin 385 | /opt/X11/bin 386 | /usr/X11/bin 387 | #{opt_libexec}/python/bin 388 | ] 389 | 390 | # unless opts.include?("with-isolation") 391 | # pths = ORIGINAL_PATHS.dup 392 | # pyenv = ENV["PYTHONPATH"] 393 | # if pyenv 394 | # pypth = pyenv.include?(pypth) ? pyenv : pypth + pthsep + pyenv 395 | # end 396 | # end 397 | 398 | unless pths.include?(HOMEBREW_PREFIX/"bin") 399 | pths = pths.insert(0, HOMEBREW_PREFIX/"bin") 400 | end 401 | 402 | # set install's lib/python#{py_ver}/site-packages first, so app will work if unlinked 403 | pypths = %W[ 404 | #{opt_lib}/python#{py_ver}/site-packages 405 | #{opt_libexec}/python/lib/python/site-packages 406 | #{pypth} 407 | ] 408 | 409 | pths.insert(0, gdal_opt_bin) 410 | pths.insert(0, gdal_python_opt_bin) 411 | pypths.insert(0, gdal_python_packages) 412 | 413 | if opts.include?("with-gpsbabel") 414 | pths.insert(0, Formula["gpsbabel"].opt_bin.to_s) 415 | end 416 | 417 | envars = { 418 | :PATH => pths.join(pthsep), 419 | :PYTHONPATH => pypths.join(pthsep), 420 | :GDAL_DRIVER_PATH => "#{HOMEBREW_PREFIX}/lib/gdalplugins", 421 | :GDAL_DATA => "#{Formula["gdal2"].opt_share}/gdal", 422 | } 423 | 424 | # handle multiple Qt plugins directories 425 | qtplgpths = %W[ 426 | #{Formula["qt"].opt_prefix}/plugins 427 | #{HOMEBREW_PREFIX}/lib/qt/plugins 428 | ] 429 | envars[:QT_PLUGIN_PATH] = qtplgpths.join(pthsep) 430 | 431 | proc_algs = "Contents/Resources/python/plugins/processing/algs" 432 | if opts.include?("with-grass") || brewed_grass7? 433 | grass7 = Formula["grass7"] 434 | # for core integration plugin support 435 | envars[:GRASS_PREFIX] = "#{grass7.opt_prefix}/grass-base" 436 | begin 437 | inreplace app/"#{proc_algs}/grass7/Grass7Utils.py", 438 | "'/Applications/GRASS-7.{}.app/Contents/MacOS'.format(version)", 439 | "'#{grass7.opt_prefix}/grass-base'" 440 | puts "GRASS 7 GrassUtils.py has been updated" 441 | rescue Utils::InreplaceError 442 | puts "GRASS 7 GrassUtils.py already updated" 443 | end 444 | end 445 | 446 | unless opts.include?("without-globe") 447 | osg = Formula["open-scene-graph"] 448 | envars[:OSG_LIBRARY_PATH] = "#{HOMEBREW_PREFIX}/lib/osgPlugins-#{osg.version}" 449 | end 450 | 451 | # TODO: add for Py3 452 | # if opts.include?("with-isolation") || File.exist?("/Library/Frameworks/GDAL.framework") 453 | # envars[:PYQGIS_STARTUP] = opt_libexec/"python/pyqgis_startup.py" 454 | # end 455 | 456 | # envars.each { |key, value| puts "#{key.to_s}=#{value}" } 457 | # exit 458 | 459 | # add env vars to QGIS.app's Info.plist, in LSEnvironment section 460 | plst = app/"Contents/Info.plist" 461 | # first delete any LSEnvironment setting, ignoring errors 462 | # CAUTION!: may not be what you want, if .app already has LSEnvironment settings 463 | dflt = `defaults read-type \"#{plst}\" LSEnvironment 2> /dev/null` 464 | `defaults delete \"#{plst}\" LSEnvironment` if dflt 465 | kv = "{ " 466 | envars.each { |key, value| kv += "'#{key}' = '#{value}'; " } 467 | kv += "}" 468 | `defaults write \"#{plst}\" LSEnvironment \"#{kv}\"` 469 | # add ability to toggle high resolution in Get Info dialog for app 470 | hrc = `defaults read-type \"#{plst}\" NSHighResolutionCapable 2> /dev/null` 471 | `defaults delete \"#{plst}\" NSHighResolutionCapable` if hrc 472 | `defaults write \"#{plst}\" NSHighResolutionCapable \"True\"` 473 | # leave the plist readable; convert from binary to XML format 474 | `plutil -convert xml1 -- \"#{plst}\"` 475 | # make sure plist is readble by all users 476 | plst.chmod 0644 477 | # update modification date on app bundle, or changes won't take effect 478 | touch app.to_s 479 | 480 | # add env vars to launch script for QGIS app's binary 481 | qgis_bin = bin/name.to_s 482 | rm_f qgis_bin if File.exist?(qgis_bin) # install generates empty file 483 | bin_cmds = %W[#!/bin/sh\n] 484 | # setup shell-prepended env vars (may result in duplication of paths) 485 | unless pths.include? HOMEBREW_PREFIX/"bin" 486 | pths.insert(0, HOMEBREW_PREFIX/"bin") 487 | end 488 | # even though this should be affected by with-isolation, allow local env override 489 | pths << "$PATH" 490 | pypths << "$PYTHONPATH" 491 | envars[:PATH] = pths.join(pthsep) 492 | envars[:PYTHONPATH] = pypths.join(pthsep) 493 | envars.each { |key, value| bin_cmds << "export #{key}=#{value}" } 494 | bin_cmds << opt_prefix/"QGIS.app/Contents/MacOS/QGIS \"$@\"" 495 | qgis_bin.write(bin_cmds.join("\n")) 496 | qgis_bin.chmod 0755 497 | end 498 | 499 | def caveats 500 | s = <<-EOS.undent 501 | Bottles support only Homebrew's Python3 502 | 503 | QGIS is built as an application bundle. Environment variables for the 504 | Homebrew prefix are embedded in QGIS.app: 505 | #{opt_prefix}/QGIS.app 506 | 507 | You may also symlink QGIS.app into /Applications or ~/Applications: 508 | brew linkapps [--local] 509 | 510 | To directly run the `QGIS.app/Contents/MacOS/QGIS` binary use the wrapper 511 | script pre-defined with Homebrew prefix environment variables: 512 | #{opt_bin}/#{name} 513 | 514 | NOTE: Your current PATH and PYTHONPATH environment variables are honored 515 | when launching via the wrapper script, while launching QGIS.app 516 | bundle they are not. 517 | 518 | For standalone Python3 development, set the following environment variable: 519 | export PYTHONPATH=#{qgis_python_packages}:#{gdal_python_packages}:#{python_site_packages}:$PYTHONPATH 520 | 521 | EOS 522 | 523 | s += <<-EOS.undent 524 | If you have built GRASS 7 for the Processing plugin set the following in QGIS: 525 | Processing->Options: Providers->GRASS GIS 7 commands->GRASS 7 folder to: 526 | #{HOMEBREW_PREFIX}/opt/grass7/grass-base 527 | 528 | EOS 529 | 530 | s 531 | end 532 | 533 | test do 534 | output = `#{bin}/#{name.to_s} --help 2>&1` # why does help go to stderr? 535 | assert_match /^QGIS is a user friendly/, output 536 | end 537 | 538 | private 539 | 540 | def brewed_grass7? 541 | Formula["grass7"].opt_prefix.exist? 542 | end 543 | 544 | def python_exec 545 | if brewed_python? 546 | Formula["python3"].opt_bin/"python3" 547 | else 548 | py_exec = `which python3`.strip 549 | raise if py_exec == "" 550 | py_exec 551 | end 552 | end 553 | 554 | def py_ver 555 | `#{python_exec} -c 'import sys;print("{0}.{1}".format(sys.version_info[0],sys.version_info[1]))'`.strip 556 | end 557 | 558 | def brewed_python? 559 | Formula["python3"].linked_keg.exist? 560 | end 561 | 562 | def python_site_packages 563 | HOMEBREW_PREFIX/"lib/python#{py_ver}/site-packages" 564 | end 565 | 566 | def python_prefix 567 | `#{python_exec} -c 'import sys;print(sys.prefix)'`.strip 568 | end 569 | 570 | def qgis_python_packages 571 | opt_lib/"python#{py_ver}/site-packages".to_s 572 | end 573 | 574 | def gdal_python_packages 575 | Formula["gdal2-python"].opt_lib/"python#{py_ver}/site-packages".to_s 576 | end 577 | 578 | def gdal_python_opt_bin 579 | Formula["gdal2-python"].opt_bin.to_s 580 | end 581 | 582 | def gdal_opt_bin 583 | Formula["gdal2"].opt_bin.to_s 584 | end 585 | 586 | def module_importable?(mod) 587 | `#{python_exec} -c 'import sys;sys.path.insert(1, "#{gdal_python_packages}"); import #{mod}'`.strip 588 | end 589 | end 590 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # THIS REPO IS ARCHIVED 2 | 3 | “The code and processes described in this repository have been superseded by the [OSGEO4MAC](https://github.com/OSGeo/homebrew-osgeo4mac) project. 4 | 5 | Detailed instructions for setting up a development environment on your macOS machine are now provided in the [QGIS Install Documentation](https://github.com/qgis/QGIS/blob/master/doc/osx.t2t) (which is currently in need of updating). 6 | 7 | Please contribute your macOS build process improvements there.” 8 | 9 | # Homebrew-qgisdev 10 | 11 | [![Build Status](https://travis-ci.org/qgis/homebrew-qgisdev.svg?branch=master)](https://travis-ci.org/qgis/homebrew-qgisdev) 12 | 13 | Formulae for macOS Homebrew package manager to aid in building the development branch of QGIS. 14 | 15 | ## How do I install these formulae? 16 | `brew install qgis/qgisdev/` 17 | 18 | Or `brew tap qgis/qgisdev` and then `brew install `. 19 | 20 | Or install via URL (which will not receive updates): 21 | 22 | ``` 23 | brew install https://raw.githubusercontent.com/qgis/homebrew-qgisdev/master/Formula/.rb 24 | ``` 25 | 26 | There may be formulae in this tap that conflict with (meant to override) formulae of the same name available in other or core `Homebrew/Homebrew-*` taps. You can *prioritize* the formulae in this tap over all others with: 27 | ``` 28 | brew tap-pin qgis/qgisdev 29 | ``` 30 | 31 | ## Homebrew documentation 32 | `brew help`, `man brew` or check [Homebrew's documentation](https://github.com/Homebrew/brew/tree/master/docs#readme). 33 | 34 | ## Formulae naming convention 35 | 36 | Formulae have specific suffix naming: 37 | 38 | * `*-dev` formulae are meant for developers/testers doing local builds 39 | * `*-travis` formulae are meant for QGIS project automated Travis CI testing 40 | * `no suffix` dependency formulae, for QGIS dev builds, not found in other taps 41 | 42 | ## Developing QGIS using Homebrew dependencies 43 | 44 | See: tutorial in [development/README.md](development/README.md) 45 | -------------------------------------------------------------------------------- /development/README.md: -------------------------------------------------------------------------------- 1 | # Developing QGIS using Homebrew dependencies 2 | 3 | In addition to using this tap to install [QGIS development formulae](../Formula), you can also use it to fully set up a development environment for an externally built QGIS from a clone of the current [development (master) branch](https://github.com/qgis/QGIS) of the source code tree. 4 | 5 | > Note: This setup, though heavily tested, is currently _experimental_ and may change. 6 | 7 | For the terminally lazy, who are already comfortable with Homebrew, [jump to sample Terminal session](#terminal). 8 | 9 | ## Development Tools 10 | 11 | This tutorial is based upon the following software: 12 | * [Qt Creator](http://qt-project.org/downloads) for CMake/C++ development of ([core source](https://github.com/qgis/QGIS/tree/master/src) and [plugins](https://github.com/qgis/QGIS/tree/master/src/plugins)) 13 | * [PyCharm Community Edition](http://www.jetbrains.com/pycharm/download/) for Python development of ([PyQGIS plugins/apps](http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/), [Python unit tests](https://github.com/qgis/QGIS/tree/master/tests/src/python), [reStructuredText for documentation](https://github.com/qgis/QGIS-Documentation)). 14 | * macOS XCode (download via Mac App Store and _launch at least once_) and Xcode Command Line Tools (run `xcode-select --install` after installing Xcode), for Homebrew and building QGIS source. QGIS's [CMake](http://www.cmake.org) build process uses generated build files for building QGIS source directly with the `clang` compiler, _not via Xcode project files_. 15 | 16 | ## Homebrew 17 | 18 | See http://brew.sh and [Homebrew docs](https://github.com/Homebrew/brew/tree/master/docs) for info on installing Homebrew. 19 | 20 | After Homebrew is installed run the following and fix everything that it mentions, if you can: 21 | ```sh 22 | brew doctor 23 | ``` 24 | 25 | ### Homebrew configuration 26 | 27 | Homebrew now defaults to _auto-updating_ itself (runs `brew update`) upon *every* `brew install` invocation. While this can be handy for keeping up with the latest changes, it can also quickly break an existing build's linked-to libraries. Consider setting the `HOMEBREW_NO_AUTO_UPDATE` environment variable to turn this off, thereby forcing manual running of `brew update`: 28 | 29 | ```sh 30 | export HOMEBREW_NO_AUTO_UPDATE=1 31 | ``` 32 | 33 | See end of `man brew` for other environment variables. 34 | 35 | ### Homebrew prefix 36 | 37 | While all of the formulae and scripts support building QGIS using Homebrew installed to a non-standard prefix, e.g. `/opt/homebrew`, **do yourself a favor** (especially if you are new to Homebrew) and [install in the default directory of `/usr/local`](https://github.com/Homebrew/brew/blob/master/docs/Installation.md). QGIS has many dependencies which are available as ["bottles"](https://github.com/Homebrew/brew/blob/master/docs/Bottles.md) (pre-built binary installs) from the Homebrew project. Installing Homebrew to a non-standard prefix will force many of the bottled formulae to be built from source, since many of the available bottles are built specific to `/usr/local`. Such unnecessary building from source can comparatively take hours and hours more, depending upon your available CPU cores. 38 | 39 | If desired, this setup supports QGIS builds where the dependencies are in a non-standard Homebrew location, e.g. `/opt/homebrew`, instead of `/usr/local`. This allows for multiple build scenarios, though often requires a more meticulous CMake configuration of QGIS. 40 | 41 | You can programmatically find the prefix with `brew --prefix`. In formulae code, it is denoted with the HOMEBREW_PREFIX environment variable. 42 | 43 | ### Homebrew formula install prefixes 44 | 45 | By default, Homebrew installs to a versioned prefix in the 'Cellar', e.g. `/usr/local/Cellar/gdal2/2.1.2/`. Using the versioned path for dependencies _might_ lead to it being hardcoded into the linking phase of your builds. This is an issue because the version can change often with formula changes that are unrelated to the actual dependency's version, e.g. `2.1.2_1`. When defining paths for CMake, always try the formula's 'opt prefix' first, e.g. `/usr/local/opt/gdal2`, which is a symbolic link that _always_ points to the latest versioned install prefix of the formula. This often avoids the issue, though some CMake find modules _may_ resolve the symbolic link back to the versioned install prefix. 46 | 47 | ### Install some basic formulae 48 | 49 | Always read the 'Caveats' section output at the end of `brew info ` or `brew install `. 50 | 51 | ```sh 52 | brew install bash-completion 53 | brew install git 54 | ``` 55 | 56 | ## Python Dependencies 57 | 58 | ### Select an interpreter 59 | 60 | The first important decision to make is regarding whether to use Homebrew's or another Python 3.x. Currently macOS does not ship with Python 3, and QGIS 3 should be built against Python 3.x. 61 | 62 | > Note: The more Homebrew formulae you install from bottles, the higher likelihood you will end up running into a formulae that requires installing Homebrew's Python 3, since bottles are always built against that Python. 63 | 64 | If using Homebrew Python 3.x, install with: 65 | 66 | ```sh 67 | # review options 68 | brew info python3 69 | brew install python3 [--with-option ...] 70 | ``` 71 | 72 | Regardless of which Python interpreter you use, always ensure it is the first found `python3` on PATH in your Terminal session where you run `brew` commands, i.e. `which python3` points to the correct Python 3 you wish to use when building formulae. 73 | 74 | ### Install required Python packages 75 | 76 | Use [pip3](https://pypi.python.org/pypi/pip/) that was installed against the same Python 3 you are using when installing formulae. You can also tap [homebrew/python](https://github.com/Homebrew/homebrew-python) for some more complex package installs. 77 | 78 | Reference `pip3 --help` for info on usage (usually just `pip install `). 79 | 80 | * [future](https://pypi.python.org/pypi/future) 81 | * [numpy](https://pypi.python.org/pypi/numpy) 82 | * [psycopg2](https://pypi.python.org/pypi/psycopg2) 83 | * [matplotlib](https://pypi.python.org/pypi/matplotlib) 84 | * [pyparsing](https://pypi.python.org/pypi/pyparsing) 85 | * [requests](https://pypi.python.org/pypi/requests) 86 | * [mock](https://pypi.python.org/pypi/mock) 87 | * [pyyaml](https://pypi.python.org/pypi/PyYAML) 88 | * [nose2](https://pypi.python.org/pypi/nose2) 89 | 90 | Other Python packages **automatically installed** by Homebrew from QGIS dependencies: 91 | 92 | * [sip](https://github.com/Homebrew/homebrew-core/blob/master/Formula/sip.rb) 93 | * [PyQt5](https://github.com/Homebrew/homebrew-core/blob/master/Formula/pyqt5.rb) 94 | * [QScintilla2](https://github.com/Homebrew/homebrew-core/blob/master/Formula/qscintilla2.rb) 95 | * [pyspatialite](https://github.com/OSGeo/homebrew-osgeo4mac/blob/master/Formula/pyspatialite.rb) (deprecated) 96 | * [`osgeo.gdal` and `osgeo.ogr`, etc.](https://github.com/OSGeo/homebrew-osgeo4mac/blob/master/Formula/gdal2-python.rb) 97 | 98 | ## Install Build and Linked Library Dependencies 99 | 100 | ### Install dependencies from QGIS formulae 101 | 102 | > Note: substitute **`qgis3-xx`** for whatever QGIS formula you are using for dependencies, e.g. `qgis3-dev`. 103 | 104 | ```sh 105 | # add this tap 106 | brew tap qgis/qgisdev 107 | # review options 108 | brew info qgis3-xx 109 | # see what dependencies will be included 110 | brew deps --tree qgis3-xx [--with[out]-some-option ...] 111 | # install dependencies, but not QGIS 112 | brew install qgis3-xx --only-dependencies [--with[out]-some-option ...] 113 | ``` 114 | 115 | You do not have to actually do `brew install qgis3-xx` unless you also want that version installed. If you do have QGIS 3 formulae installed, and are planning on _installing_ your development build (not just running from the build directory), you should unlink the formulae installs, e.g.: 116 | 117 | ```sh 118 | brew unlink qgis3-xx 119 | ``` 120 | 121 | This will ensure the `qgis.core`, etc. Python modules of the formula(e) installs are not overwritten by the development build upon `make install`. All `qgis-xx` formulae QGIS applications will run just fine from their Cellar keg install directory. _Careful_, though, as multiple QGIS installs will probably all share the same application preference files; so, don't run them concurrently. 122 | 123 | ### Optional External Dependencies 124 | 125 | The [Processing framework](http://docs.qgis.org/testing/en/docs/user_manual/processing/index.html) of QGIS can leverage many external geospatial applications and utilities, which _do not_ need to be built as dependencies prior to building QGIS: 126 | 127 | * [`grass7`](https://github.com/OSGeo/homebrew-osgeo4mac/blob/master/Formula/grass7.rb) (`--with-grass` option) - [GRASS 7](http://grass.osgeo.org), which is also used by the GRASS core plugin in QGIS 128 | * [`orfeo5`](https://github.com/OSGeo/homebrew-osgeo4mac/blob/master/Formula/orfeo5.rb) (`--with-orfeo5` option) - [Orfeo Toolbox](http://orfeo-toolbox.org/otb/) 129 | * [`r`](http://www.r-project.org/) (`--with-r` option) - [R Project](http://www.r-project.org/) 130 | * [`saga-gis`](https://github.com/OSGeo/homebrew-osgeo4mac/blob/master/Formula/saga-gis.rb) (`--with-saga-gis` option) - [System for Automated Geoscientific Analyses](http://www.saga-gis.org) 131 | * [`taudem`](https://github.com/OSGeo/homebrew-osgeo4mac/blob/master/Formula/taudem.rb) - [Terrain Analysis Using Digital Elevation Models](http://hydrology.usu.edu/taudem/taudem5/index.html). 132 | 133 | The `gpsbabel` formula can be installed as a dependency, though you may have to define the path to its binary when using QGIS's [GPS Tools](http://docs.qgis.org/testing/en/docs/user_manual/working_with_gps/plugins_gps.html). 134 | 135 | > Note: if you install Processing external utilities _after_ installing a QGIS formula or building your own QGIS, you may need to configure the individual utility's paths in Processing's options dialog. 136 | 137 | ## Clone QGIS Source 138 | 139 | See the QGIS [INSTALL](https://github.com/qgis/QGIS/blob/master/INSTALL) document for information on using git to clone the source tree. 140 | 141 | QGIS's build setup uses CMake, which supports 'out-of-source' build directories. It is recommended to create a separate build directory, either within the source tree, or outside of it. Since the (re)build process can generate _many_ files, consider creating a separate partition on which to place the build directory. Such a setup can significantly reduce fragmentation on your main startup drive. Use of Solid State Disks is recommended. 142 | 143 | ## Customize Build Scripts 144 | 145 | This tap offers several convenience scripts for use in Qt Creator, or wrapper build scripts, to aid in building/installing QGIS, located at: 146 | 147 | ```sh 148 | $(brew --repository qgis/qgisdev)/scripts 149 | ``` 150 | 151 | > Note: **Copy the directory elsewhere** and use it from there. It's important to not edit the scripts where they are located, in the tap, because it is a git repository. You should keep that working tree clean so that `brew update` always works. 152 | 153 | The scripts will be used when configuring/building/installing the QGIS project in Qt Creator, or can be used independent of Qt Creator. 154 | 155 | ### Open and review scripts 156 | 157 | **Note:** scripts expect the HOMEBREW_PREFIX environment variable to be set, e.g. in your `.bash_profile`: 158 | 159 | ```sh 160 | # after prepending `brew --prefix` to PATH (not needed for default /usr/local Homebrew) 161 | export HOMEBREW_PREFIX=$(brew --prefix) 162 | ``` 163 | 164 | * [qgis-cmake-setup.sh](../scripts/qgis-cmake-setup.sh) - For generating CMake option string for use in Qt Creator (or build scripts) when built off dependencies from this and other taps. Edit CMake options to suit your build needs. Note, the current script usually has CMake options for building QGIS with *most* core options that the current `qgis3-xx` Homebrew formula supports, which may not include things like Oracle support, etc. You will probably want to edit it and (un)comment out such lines for an initial build. 165 | 166 | * [qgis-set-app-env.py](../scripts/qgis-set-app-env.py) - For setting env vars in dev build and installed QGIS.app, to ensure they are available on double-click run. _Needs to stay in the same directory as the next scripts._ Generally, you will not need to edit this script. 167 | 168 | * [qgis-dev-build.sh](../scripts/qgis-dev-build.sh) - Sets up the build environ and ensures the QGIS.app in the build directory can find resources, so it can run from there. 169 | 170 | * [qgis-dev-install.sh](../scripts/qgis-dev-install.sh) - Installs the app and ensures QGIS.app has proper environment variables, so it can be moved around on the filesystem. Currently, QGIS.app bundling beyond [QGIS_MACAPP_BUNDLE=0](https://github.com/qgis/QGIS/tree/master/mac) is not supported. Since all dependencies are in your `HOMEBREW_PREFIX`, _no complex bundling is necessary_, unless you intend to relocate the built app to another Mac (which is a planned feature). 171 | 172 | ## Configure/build/install QGIS in a Terminal.app session 173 | 174 | **Example** Terminal.app session for cloning and building QGIS from scratch, based off of `qgis-3-dev` formula dependencies and assuming Xcode.app, Xcode Command Line Tools, and Homebrew are _already installed_. BASH used here. 175 | 176 | ```sh 177 | # Setup environment variables 178 | export HOMEBREW_PREFIX=$(brew --prefix) 179 | export HOMEBREW_NO_AUTO_UPDATE=1 180 | 181 | # Optionally update Homebrew (recommended) 182 | brew update 183 | 184 | # Install some handy base formulae 185 | brew install bash-completion 186 | brew install git 187 | brew install cmake 188 | 189 | # Decide to use recommended Homebrew's Python3 190 | # (could use Anaconda's Python 3, etc. instead, though bottles may not work) 191 | brew install python3 192 | 193 | # Install some Python dependencies 194 | # NOTE: may require `sudo` if Python 3 is installed in a root-owned location 195 | pip3 install future numpy psycopg2 matplotlib pyparsing requests pyyaml mock nose2 196 | 197 | # Add some useful Homebrew taps 198 | # NOTE: try to avoid tapping homebrew/boneyard 199 | brew tap homebrew/science 200 | brew tap homebrew/python 201 | brew tap qgis/qgisdev 202 | brew tap osgeo/osgeo4mac 203 | 204 | # Make sure deprecated Qt4 formulae are not linked 205 | brew unlink qt 206 | brew unlink pyqt 207 | 208 | # Older txt2tags generator for INSTALL doc breakes build and chokes on Python 3 209 | brew unlink txt2tags 210 | 211 | # Install and verify GDAL/OGR with decent driver support 212 | # Do NOT install `gdal` (1.11.x) formula, unless you truely need it otherwise 213 | # NOTE: keg-only, e.g. only available from HOMEBREW_PREFIX/opt/gdal2 prefix 214 | brew install osgeo/osgeo4mac/gdal2 --with-complete --with-libkml 215 | brew test osgeo/osgeo4mac/gdal2 216 | 217 | # If failure, review any .dylib errors when loading drivers (scroll to top of output) 218 | $HOMEBREW_PREFIX/opt/gdal2/bin/gdalinfo --formats 219 | $HOMEBREW_PREFIX/opt/gdal2/bin/ogrinfo --formats 220 | 221 | # Add the Python 3 bindings for GDAL/OGR 222 | brew install osgeo/osgeo4mac/gdal2-python --with-python3 223 | brew test osgeo/osgeo4mac/gdal2-python 224 | 225 | # Optionally add and verify Processing framework extra utilities 226 | brew install osgeo/osgeo4mac/grass7 227 | brew install osgeo/osgeo4mac/gdal2-grass7 228 | brew test osgeo/osgeo4mac/grass7 229 | brew test osgeo/osgeo4mac/gdal2-grass7 230 | 231 | brew install osgeo/osgeo4mac/saga-gis --with-app 232 | brew test osgeo/osgeo4mac/saga-gis 233 | 234 | # This one's huge, bringing in large dependencies 235 | brew install orfeo5 236 | brew test orfeo5 237 | 238 | # Install remaining dependencies for qgis3-dev formula, but not QGIS 239 | # This may take a loooong time if there are missing bottles, which need built 240 | brew install qgis3-dev --only-dependencies [--with-other-options] 241 | 242 | # Base directory path of src, install and build directories 243 | BASE_DIR=$HOME/src 244 | mkdir -p $BASE_DIR 245 | cd $BASE_DIR 246 | 247 | # Create and save a directory to install a final QGIS.app 248 | QGIS_INSTALL=$BASE_DIR/QGIS_install 249 | mkdir -p $QGIS_INSTALL 250 | 251 | # Clone QGIS source tree 252 | QGIS_SRC=$BASE_DIR/QGIS 253 | # This may take a looong time, depending upon connection speed 254 | git clone https://github.com/qgis/QGIS.git $QGIS_SRC 255 | cd $QGIS_SRC 256 | 257 | # Setup out-of-source build directory, inside of QGIS tree 258 | BUILD_DIR=$BASE_DIR/QGIS/build 259 | mkdir -p $BUILD_DIR 260 | cd $BUILD_DIR 261 | 262 | # Where you have copied the build scripts (here using the defaults, as is) 263 | BUILD_SCRIPTS=$(brew --repository qgis/qgisdev)/scripts 264 | 265 | # Configure CMake and generate build files 266 | # usage: qgis-cmake-setup.sh 'source directory' 'build directory' 'install directory' 267 | # (directories need to absolute paths) 268 | $BUILD_SCRIPTS/qgis-cmake-setup.sh $QGIS_SRC $BUILD_DIR $QGIS_INSTALL 269 | 270 | # Review or edit what was configured (almost all dependencies should be from Homebrew) 271 | ccmake $BUILD_DIR 272 | 273 | # Build QGIS 274 | # usage: qgis-dev-build.sh 'absolute path to build directory' 275 | $BUILD_SCRIPTS/qgis-dev-build.sh $BUILD_DIR 276 | 277 | # Run QGIS test suite from build directory 278 | # source environment and run tests inside of a bash subshell, 279 | # so your shell environment is not polluted 280 | ( source $BUILD_SCRIPTS/qgis-dev.env $BUILD_DIR && ctest ) 281 | 282 | # Install QGIS.app 283 | # note: app bundle is moveable about the filesystem, but not to another Mac 284 | $BUILD_SCRIPTS/qgis-dev-install.sh $BUILD_DIR 285 | ``` 286 | 287 | ## Configure/build/install QGIS in Qt Creator.app 288 | 289 | These steps assume you are starting from a QGIS source tree clone, having done none of the above in Terminal.app. However, using an existing Terminal-based build is possible, if you assign the existing build directory upon loading your QGIS project. 290 | 291 | **Important:** This configuration uses ``/usr/local`` as the HOMEBREW_PREFIX, which is the default. Substitute if yours is different. 292 | 293 | ### Install QtCreator 4.2 or better 294 | 295 | It is recommended to use Qt Creator >= 4.2.0, as the CMake support much better than previous versions. Newer versions are slated to offer even more CMake integration, so update often. 296 | 297 | * Grab _just_ the Qt Creator installer from https://www.qt.io/download-open-source/ 298 | * Click **View All Downloads** scroll down to Qt Creator section 299 | * Open the DMG and drag **Qt Creator.app** wherever you like 300 | * Open **Qt Creator.app** 301 | 302 | ### Make a "Build & Run" kit for Homebrew 303 | 304 | Go to ``Preferences -> Build & Run``. All further settings for building a kit are contained in tabs of that Preferences section. 305 | 306 | **Note:** You can click ``Apply`` button, at any time, to apply your settings without closing the dialog. 307 | 308 | #### Define a CMake executable 309 | 310 | Under ``CMake`` tab, click ``Add`` 311 | 312 | * **Name:** Brew CMake 313 | * **Path:** /usr/local/bin/cmake 314 | 315 | #### Optionally define a compiler cache 316 | 317 | Generally, the default macOS `clang` compiler is very quick, but subsequent compilations can be accelerated with a compiler cache. QGIS developers often use and have heavily tested ``ccache`` for this purpose: 318 | 319 | ```sh 320 | brew install ccache 321 | ``` 322 | 323 | Compiler symlinks are **not available** in ``/usr/local/bin``, but can be found in: 324 | 325 | ```sh 326 | /usr/local/opt/ccache/libexec 327 | ``` 328 | 329 | Under ``Compilers`` tab... 330 | 331 | * Click ``Add -> Clang -> C`` and configure: 332 | 333 | * **Name:** Clang (x86 64bit) - Brew ccache 334 | * **Compiler path:** _Paste_ in ``/usr/local/opt/ccache/libexec/clang`` 335 | * **ABI:** x86, darwin, generic, mach_o, 64bit 336 | 337 | * Click ``Add -> Clang -> C++`` and configure: 338 | 339 | * **Name:** Clang (x86 64bit) - Brew ccache 340 | * **Compiler path:** _Paste_ in ``/usr/local/opt/ccache/libexec/clang++`` 341 | * **ABI:** x86, darwin, generic, mach_o, 64bit 342 | 343 | **Note:** If you browse to one of the symlinked compiler paths, you will end up with an unwanted "Cellar"-based path. 344 | 345 | #### Define a Qt Version 346 | Under ``Qt Versions``, click ``Add``. 347 | 348 | * **Version name:** Brew Qt5 349 | * **qmake location:** Browse to the executable ``/usr/local/opt/qt5/bin/qmake`` 350 | 351 | **Note:** Homebrew's Qt5 `qmake` is not currently linked into `HOMEBREW_PREFIX/bin`, though this may change. To check, see if `/usr/local/bin/qmake` exists and is from Homebrew's Qt5. If so, use that path instead; otherwise, continue with next step. 352 | 353 | The **qmake** location for `/usr/local/opt/qt5/bin/qmake` will be saved as a versioned "Cellar" path. We need to adjust this to its "opt prefix" alternate path, the one we originally browsed. This keeps incremental Homebrew upgrades of Qt5 packages from breaking our kit in the future. 354 | 355 | ##### Fix qmake location 356 | 357 | * Click ``OK`` for Preferences dialog and **quit** Qt Creator 358 | * Open this file in a text editor: 359 | 360 | ``~/.config/QtProject/qtcreator/qtversion.xml`` 361 | 362 | * Find the same versioned "Cellar" ``qmake`` path (associated with the element whose attribute is ``key="QMakePath"``) and change it to: 363 | 364 | ``/usr/local/opt/qt5/bin/qmake`` 365 | 366 | * Save file and relaunch Qt Creator, then go to: 367 | 368 | ``Preferences -> Build & Run -> Qt Versions`` 369 | 370 | When you select the ``Brew Qt5`` version, it should now show the "opt prefix" path. 371 | 372 | #### Define a kit 373 | 374 | Under ``Kits`` tab, click ``Add``, then configure with: 375 | 376 | * **Name:** QGIS Build Kit - Qt5 377 | * **File system name:** _blank_ 378 | * **Device type:** Desktop 379 | * **Device:** Local PC (default for Desktop) 380 | * **Sysroot:** _blank_ 381 | * **Compiler:** (if using ccache, substitute the compilers you defined) 382 | * **C:** Clang (x86_64bin in /usr/bin) 383 | * **C++:** Clang (x86_64bin in /usr/bin) 384 | * **Environment:** click ``Change...`` and add the following variables: 385 | 386 | ``` 387 | HOMEBREW_PREFIX=/usr/local 388 | PATH=/usr/local/opt/ccache/libexec:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin 389 | ``` 390 | 391 | **Notes:** 392 | * The kit's Qt5 `bin` dir is always prepended to PATH: `/usr/local/opt/qt5/bin`, but it will be resolved to it's "Cellar" path, e.g. `/usr/local/Cellar/qt5/5.7.1_1/bin`, which is not an issue since it is dynamically prepended. 393 | * `HOMEBREW_PREFIX` is used by the custom build and install scripts. 394 | 395 | * **Debugger:** System LLDB at `/Applications/Xcode.app/Contents/Developer/usr/bin/lldb` (or `/usr/bin/lldb`, if using the Command Line Tools) 396 | * **Qt Version:** Brew Qt5 (which you previously created) 397 | * **Qt mkspec:** leave blank 398 | * **CMake Tool:** Brew CMake (which you previously created) 399 | * **CMake Generator:** CodeBlocks - Unix Makefiles 400 | * **CMake Configuration:** Press the `Change...` button and paste this into the box provided: 401 | 402 | ``` 403 | CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable} 404 | CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} 405 | QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} 406 | CMAKE_BUILD_TYPE:STRING=RelWithDebInfo 407 | CMAKE_FIND_FRAMEWORK:STRING=LAST 408 | CMAKE_PREFIX_PATH:STRING='/usr/local/opt/qt5;/usr/local/opt/qt5-webkit;/usr/local/opt/qscintilla2;/usr/local/opt/qwt;/usr/local/opt/qwtpolar;/usr/local/opt/qca;/usr/local/opt/gdal2;/usr/local/opt/gsl;/usr/local/opt/geos;/usr/local/opt/proj;/usr/local/opt/libspatialite;/usr/local/opt/spatialindex;/usr/local/opt/fcgi;/usr/local/opt/expat;/usr/local/opt/sqlite;/usr/local/opt/flex;/usr/local/opt/bison' 409 | ``` 410 | 411 | **Notes:** 412 | * If using `ccache`, you must also define `CMAKE_C_COMPILER` (as above), or Apple's default C compiler will be used. 413 | * `CMAKE_PREFIX_PATH` is **critical** as it tells CMake to search _first_ in Homebrew install prefixes that are not linked into the HOMEBREW_PREFIX, e.g. `/usr/local`. Otherwise, CMake can not find them. Often, these packages are important to building QGIS or are newer versions overriding packages already installed on the base macOS. 414 | * The `CMAKE_PREFIX_PATH` value can be taken from `$(brew --repository qgis/qgisdev)/scripts/qgis-cmake-setup.sh`. You can comment out the last `eval` line of the aforementioned script to get the equivalent value above. 415 | * Do not place QGIS-specific CMake options here. Those should be defined in the CMake section of a specific QGIS source tree when loaded into Qt Creator as a project. 416 | 417 | Optionally, once you have your kit defined, you can make it the default by selecting it and clicking the `Make Default` button. 418 | 419 | ### Load QGIS project 420 | 421 | **Note:** This describes loading a CMake project in Qt Creator 4.2 (recommended minimum version). Other versions may vary. 422 | 423 | When opening a project, the build directory needs defined. You can set a default build directory templated path in the `General` tab's `Default build directory:` option. If you wish to have the build directory default to _inside_ your project source tree directory, you can use the following template path: 424 | 425 | ``` 426 | %{CurrentProject:Path}/build_%{CurrentBuild:Type} 427 | ``` 428 | 429 | The generated build paths based upon this template can still be overridden in the next step. 430 | 431 | Load QGIS project and configure/generate its build files: 432 | 433 | * Select `File -> Open File or Project...` menu action 434 | * Open the `CMakeLists.txt` in the root of your cloned QGIS source tree directory 435 | * In the resulting `Configure Project` panel: 436 | 437 | * Check only the `QGIS Build Kit - Qt5` you previously created, and uncheck **all** other kits 438 | * Click `Details` of your kit to reveal build directory options 439 | * Uncheck all options except "Release with Debug Information" (recommended - you can always add other types later as additional build configurations) 440 | * If you wish to use the templated directory path, and want to create it now, the easiest way is to copy the path and run `mkdir ` in Terminal.app. 441 | * If you wish to override the templated build directory path, click `Choose...` (create an empty build folder and select it) 442 | * Click `Configure Project` 443 | 444 | **Note:** If you did not create the build directory, CMake will _configure_ the project, but not _create_ the build directory or _generate_ the build files until you choose to build the project. 445 | 446 | ### Configuring QGIS CMake options 447 | 448 | **Tip:** You can choose the `Build -> Run CMake` menu action to reconfigure and generate build files for your project at any time. This is helpful for when Qt Creator does not update its GUI and give you the option to do so. 449 | 450 | You can configure CMake options for your project in the `Projects` section of the main window, under `Active Project -> Your project` then under `Build & Run -> Your kit -> Build`. 451 | 452 | * **Note:** When you `Add` or `Edit` options here, they are stored in `CMakeLists.txt.user` in the root of your QGIS source tree, under the this XML element: 453 | 454 | ``` 455 | 456 | ``` 457 | If you have problems with Qt Creator picking up automatic configuration changes, check the child elements of that `valuelist` to see if there are stored option elements that need deleted (if so, quit Creator first). This is necessary until Qt adds a `Delete` action for CMake options to Creator. Optionally, you can also delete `CMakeLists.txt.user`, though you lose considerably more project configurations. 458 | 459 | #### Configure for running from build directory 460 | 461 | This will stage the core Python plugins so they are available at runtime from the build directory: 462 | 463 | ``` 464 | WITH_STAGED_PLUGINS=TRUE (Add as Boolean) 465 | ``` 466 | 467 | #### Configure QwtPolar 468 | 469 | To avoid building the internal QwtPolar, and use Homebrew's: 470 | 471 | ``` 472 | WITH_QWTPOLAR=TRUE (Add as Boolean) 473 | WITH_INTERNAL_QWTPOLAR=FALSE (Add as Boolean) 474 | ``` 475 | 476 | #### Configure for code styling 477 | 478 | To ensure the `astyle` binary is built for checking your code with `prepare-commit.sh` script before committing to PR, etc. 479 | 480 | ``` 481 | WITH_ASTYLE=TRUE (Add as Boolean) 482 | ``` 483 | 484 | #### Configure for install 485 | 486 | If you intend to install QGIS.app, and not just run it from the build directory: 487 | 488 | ``` 489 | CMAKE_INSTALL_PREFIX= 490 | ``` 491 | 492 | This defaults to `/usr/local`, which is probably not what you want. Suggested: 493 | 494 | ``` 495 | CMAKE_INSTALL_PREFIX=$HOME/Applications/QGIS (Add as Directory) 496 | ``` 497 | 498 | Unless you intend to install a fully bundled, standalone `QGIS.app` (not yet supported), then you will want to set: 499 | 500 | ``` 501 | QGIS_MACAPP_BUNDLE=0 (Add as String) 502 | ``` 503 | 504 | #### Configure GRASS 505 | 506 | If using `osgeo/osgeo4mac/grass7`: 507 | 508 | ``` 509 | WITH_GRASS7=TRUE (Add as Boolean) 510 | GRASS_PREFIX7=/usr/local/opt/grass7/grass-base" (Add as Directory) 511 | ``` 512 | 513 | #### Fix some CMake module search results 514 | 515 | To ensure your build is isolated as much as possible from incidental Homebrew updates, prefer package "opt prefix" paths for CMake modules that find versioned prefix by default: 516 | 517 | ``` 518 | GDAL_LIBRARY=/usr/local/opt/gdal2/lib/libgdal.dylib (Add as File) 519 | GEOS_LIBRARY=/usr/local/opt/geos/lib/libgeos_c.dylib (Add as File) 520 | GSL_CONFIG=/usr/local/opt/gsl/bin/gsl-config (Add as File) 521 | GSL_INCLUDE_DIR=/usr/local/opt/gsl/include (Add as Directory) 522 | GSL_LIBRARIES='-L/usr/local/opt/gsl/lib -lgsl -lgslcblas' (Add as String) 523 | ``` 524 | 525 | # TODO: WIP from here to end 526 | 527 | ### Building QGIS 528 | 529 | TODO: notes on `qgis-set-app-env.py` and `qgis-dev-build.sh` 530 | 531 | ### Cleaning the build 532 | 533 | If you want to start with a clean setup in Qt Creator you should: 534 | 535 | * Quit Qt Creator 536 | * Remove the `CMakeLists.txt.user` file at the root of the QGIS source tree 537 | * Optionally, remove the _contents_ of any existing build directory or just its `CMakeCache.txt` file 538 | * Restart Qt Creator 539 | * Load project as noted above 540 | 541 | ### Running/debugging QGIS.app from build directory 542 | 543 | You may need to do this: 544 | 545 | • add /usr/local/opt/gdal2/bin/ to the raster/gdal tool settings in qgis 546 | • add gdal to your path : export PATH=/usr/local/opt/gdal2/bin/:$PATH 547 | 548 | When debugging / running from Qt-Creator, ensure that GDAL python packages are in your path by adding this to your run environment: 549 | 550 | ``` 551 | PYTHONPATH set to $PYTHONPATH:/usr/local/opt/gdal2-python/lib/python3.5/site-packages 552 | ``` 553 | 554 | Alternatively, add the gdal2 packages to your environment directly in QGIS like this: 555 | 556 | ![screen shot 2017-03-19 at 8 37 54 pm](https://cloud.githubusercontent.com/assets/178003/24084521/6d5345ec-0cf4-11e7-9d86-e8af713a5b76.png) 557 | 558 | 559 | 560 | ### Installing QGIS.app 561 | 562 | ### Qt Creator tweaks 563 | 564 | * Import QGIS code style rules 565 | * Under `Preferences -> C++`, click `Import` 566 | * Import `qtcreator_code_style.xml` from `QGIS/doc` folder in QGIS source tree 567 | * A "QGIS" code style is imported, which you can assign as the code style for your loaded project (or import just for your project, under `Project Settings` for your project in the `Projects` section of the main window) 568 | 569 | ### Useful Qt Creator shortcuts 570 | 571 | * **Ctrl-K** - pops up quick search for a class 572 | * **:spacebar** in the search popup will search for symbols 573 | * **Ctrl-K** - then type 'git blame' and it will give git blame for currently open file 574 | * **F2** - jump to symbol / definition under cursor 575 | * **Alt-Enter** - refactoring you can automatically implement stubs for a method in a header 576 | * **Alt-Enter** - refactoring you can generate getter and setter for a private member in a header 577 | * **Alt-Enter** - general refactoring 578 | * **Cmd-shift R** - refactor symbol name under the cursor 579 | * **Cmd-B** - Build 580 | * **Cmd-R** - Run w/o debugger 581 | * **F5** - debug 582 | 583 | ### Troubleshooting 584 | 585 | **Problem:** 586 | /usr/local/Cellar/cmake/3.5.2/share/cmake/Modules/CMakeTestCCompiler.cmake:61: error: The C compiler "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc" is not able to compile a simple test program. It fails with the following output: Change Dir: /Users/timlinux/dev/cpp/QGIS/build/CMakeFiles/CMakeTmp 587 | 588 | **Resolution:** 589 | 590 | Close Qt Creator, remove CMakeLists.txt.user from your source tree and start again, see if that helps. 591 | 592 | **Problem:** 593 | 594 | CMAKE CODEBLOCKS GENERATOR not found 595 | 596 | **Resolution:** 597 | 598 | Manually set this to 'make' (or try ninja) 599 | 600 | ## Configure/build/install QGIS in CLion 601 | 602 | [CLion](https://www.jetbrains.com/clion/) is a cross platform C++ IDE developed by JetBrains. Usage generally requires purchasing a commercial license, though they do provide free licenses for Open Source projects (subject to some criteria). 603 | 604 | ![screen shot 2017-03-19 at 10 39 28 pm](https://cloud.githubusercontent.com/assets/178003/24084554/f67a9b40-0cf4-11e7-8351-49324dc154ab.png) 605 | Image above: An example session running CLion. 606 | 607 | CLion is much simpler to set up as a build environment for QGIS compared to QtCreator and my be a good alternative for those used to developing with PyCharm for their Python Work (see PyCharm section below), since both PyCharm and CLion are build on the same 'engine' and have constencies in features, key bindings etc. 608 | 609 | * Open project 610 | * Open the CMakeLists.txt in QGIS Source tree 611 | * Open CLion preferences 612 | * Go to Build, execution, deployment 613 | * Go to Toolchain 614 | * CMake Executable: Custom: /usr/local/Cellar/cmake/3.6.1/bin/cmake 615 | * CMake: 616 | * Generation group box 617 | * Configuration: RelWithDebInfo 618 | * CMake options: 619 | 620 | ``` 621 | -DWITH_BINDINGS=ON 622 | -G 623 | "Ninja" 624 | -DCMAKE_CODEBLOCKS_EXECUTABLE:PATH='/usr/local/bin/ninja' 625 | -DCMAKE_INSTALL_PREFIX:PATH='/Users/timlinux/Applications/' 626 | -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo 627 | -DCMAKE_FIND_FRAMEWORK:STRING=LAST 628 | -DCMAKE_PREFIX_PATH:STRING='/usr/local/opt/qt5;/usr/local/opt/qt5-webkit-qt@5.7;/usr/local/opt/qscintilla2;/usr/local/opt/qwt;/usr/local/opt/qwtpolar;/usr/local/opt/qca-qt@5.7;/usr/local/opt/gdal2;/usr/local/opt/gsl;/usr/local/opt/geos;/usr/local/opt/proj;/usr/local/opt/libspatialite;/usr/local/opt/spatialindex;/usr/local/opt/fcgi;/usr/local/opt/expat;/usr/local/opt/sqlite;/usr/local/opt/flex;/usr/local/opt/bison;' 629 | -DENABLE_MODELTEST:BOOL=FALSE 630 | -DENABLE_TESTS:BOOL=TRUE 631 | -DGDAL_LIBRARY:FILEPATH=/usr/local/opt/gdal2/lib/libgdal.dylib 632 | -DGEOS_LIBRARY:FILEPATH=/usr/local/opt/geos/lib/libgeos_c.dylib 633 | -DGSL_CONFIG:FILEPATH=/usr/local/opt/gsl/bin/gsl-config 634 | -DGSL_INCLUDE_DIR:PATH=/usr/local/opt/gsl/include 635 | -DGSL_LIBRARIES="-L/usr/local/opt/gsl/lib -lgsl -lgslcblas" 636 | -DWITH_QWTPOLAR:BOOL=TRUE 637 | -DWITH_INTERNAL_QWTPOLAR:BOOL=FALSE 638 | -DWITH_GRASS:BOOL=FALSE 639 | -DWITH_GRASS7:BOOL=TRUE 640 | -DGRASS_PREFIX7:PATH=/usr/local/opt/grass7/grass-base 641 | -DWITH_APIDOC:BOOL=FALSE 642 | -DWITH_ASTYLE:BOOL=TRUE 643 | -DWITH_CUSTOM_WIDGETS:BOOL=TRUE 644 | -DWITH_GLOBE:BOOL=FALSE 645 | -DWITH_ORACLE:BOOL=FALSE 646 | -DWITH_QSCIAPI:BOOL=FALSE 647 | -DWITH_QSPATIALITE:BOOL=FALSE 648 | -DWITH_QTWEBKIT:BOOL=TRUE 649 | -DWITH_SERVER:BOOL=TRUE 650 | -DWITH_STAGED_PLUGINS:BOOL=TRUE 651 | -DQGIS_MACAPP_DEV_PREFIX:PATH=/Users/timlinux/Applications/qgis-dev 652 | -DQGIS_MACAPP_INSTALL_DEV:BOOL=TRUE 653 | -DQGIS_MACAPP_BUNDLE:STRING=0 654 | '/Users/timlinux/dev/cpp/QGIS' 655 | -DCMAKE_CXX_COMPILER=/usr/local/opt/ccache/libexec/clang++ 656 | -DCMAKE_C_COMPILER=/usr/local/opt/ccache/libexec/clang 657 | ``` 658 | 659 | In our testing we found that with the above options, QGIS will compile but crash at runtime just after the splash screen. Adding the options below will resolve this issue - we will update this list to remove redundant entries in the near future. 660 | 661 | ``` 662 | -DCMAKE_AR:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar 663 | -DCMAKE_CXX_COMPILER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ 664 | -DCMAKE_C_COMPILER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc 665 | -DCMAKE_LINKER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld 666 | -DCMAKE_PREFIX_PATH:STRING=/usr/local/opt/qt5;/usr/local/opt/qt5-webkit-qt@5.7;/usr/local/opt/qscintilla2;/usr/local/opt/qwt;/usr/local/opt/qwtpolar;/usr/local/opt/qca-qt@5.7;/usr/local/opt/gdal2;/usr/local/opt/gsl;/usr/local/opt/geos;/usr/local/opt/proj;/usr/local/opt/libspatialite;/usr/local/opt/spatialindex;/usr/local/opt/fcgi;/usr/local/opt/expat;/usr/local/opt/sqlite;/usr/local/opt/flex;/usr/local/opt/bison; 667 | -DCMAKE_RANLIB:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib 668 | -DCMAKE_STRIP:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip 669 | -DQCA_INCLUDE_DIR:PATH=/usr/local/opt/qca/lib/qca-qt5.framework/Headers 670 | -DQCA_LIBRARY:FILEPATH=/usr/local/opt/qca/lib/qca-qt5.framework 671 | -DQGIS_MACAPP_INSTALL_DEV:BOOL=FALSE 672 | -DQt5WebKitWidgets_DIR:PATH=/usr/local/opt/qt5-webkit/lib/cmake/Qt5WebKitWidgets 673 | -DQt5WebKit_DIR:PATH=/usr/local/opt/qt5-webkit/lib/cmake/Qt5WebKit 674 | -DCMAKE_EXTRA_GENERATOR:INTERNAL= 675 | ``` 676 | 677 | Make sure to review the options - espectially paths near the bottom of the list to ensure 678 | they are correct for your home directory. 679 | 680 | For the most part these options were generated by calling the 681 | 682 | ``` 683 | $(brew --repository qgis/qgisdev)/scripts/qgis-cmake-setup.sh 684 | ``` 685 | 686 | utility script provided with homebrew. 687 | 688 | 689 | Generation path: Set to your home applications dir e.g.: 690 | ``` 691 | /Users/timlinux/dev/cpp/QGIS-CLion-Build 692 | ``` 693 | 694 | When debugging / running from CLion, ensure that GDAL python packages are in your path by adding this to your run environment: 695 | 696 | ``` 697 | PYTHONPATH set to $PYTHONPATH:/usr/local/opt/gdal2-python/lib/python3.5/site-packages 698 | ``` 699 | 700 | Alternatively, add the gdal2 packages to your environment directly in QGIS like this: 701 | 702 | ![screen shot 2017-03-19 at 8 37 54 pm](https://cloud.githubusercontent.com/assets/178003/24084521/6d5345ec-0cf4-11e7-9d86-e8af713a5b76.png) 703 | 704 | 705 | 706 | ## PyCharm 707 | 708 | * Using paths in PyCharm and PyCharm test defaults: 709 | * Using hand built QGIS: 710 | 711 | Set your interpreter so add these python paths: 712 | 713 | ``` 714 | /usr/local/lib/python3.5/site-packages/ 715 | /Users/timlinux/Applications/QGIS.app/Contents/Resources/python/ 716 | /Users/timlinux/Applications/QGIS.app/Contents/Resources/python/plugins 717 | ``` 718 |  719 | 720 | (Adjust these paths if you used a different install dir) 721 | 722 | ``` 723 | QGIS_PREFIX_PATH=/Users/timlinux/dev/cpp/QGIS/build/output/bin/QGIS.app/contents/MacOS; 724 | 725 | PYTHONPATH=$PYTHONPATH:/Users/timlinux/Applications/QGIS.app/contents/Resources/python:/Users/timlinux/Applications/QGIS.app/contents/Resources/python/plugins/:/usr/local/lib/python3.5/site-packages/ 726 | ``` 727 | 728 | ### For tests in PyCharm: 729 | 730 | ``` 731 | $PYTHONPATH:/Users/timlinux/Applications/QGIS.app/contents/Resources/python:/Users/timlinux//Applications/QGIS.app/Contents/Resources/python/plugins/ 732 | ``` 733 | 734 | ### Commit some changes to QGIS 735 | 736 | Before committing your changes to QGIS, you need to run `scripts/prepare-commit.sh`. You need to install some tools first: 737 | ``` 738 | brew install gnu-sed 739 | pip3 install autopep8 740 | ``` 741 | -------------------------------------------------------------------------------- /scripts/qgis-cmake-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #*************************************************************************** 4 | # Script for CMake configure and generation setup prior to use in Qt 5 | # Creator with dev builds and installs of QGIS when built off dependencies 6 | # from Homebrew project 7 | # ------------------- 8 | # begin : November 2016 9 | # copyright: (C) 2016 Larry Shaffer 10 | # email : larrys at dakotacarto dot com 11 | # ***************************************************************************/ 12 | # 13 | #/*************************************************************************** 14 | # * * 15 | # * This program is free software; you can redistribute it and/or modify * 16 | # * it under the terms of the GNU General Public License as published by * 17 | # * the Free Software Foundation; either version 2 of the License, or * 18 | # * (at your option) any later version. * 19 | # * * 20 | # ***************************************************************************/ 21 | 22 | # exit on errors 23 | set -e 24 | 25 | usage(){ 26 | echo "usage: