Skip to content

Commit 4790747

Browse files
committed
Tune osgeo4w scripts (followup cab6a4b)
1 parent fb3ff6d commit 4790747

File tree

7 files changed

+279
-268
lines changed

7 files changed

+279
-268
lines changed

CMakeLists.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ MESSAGE(STATUS "QGIS version: ${COMPLETE_VERSION} ${RELEASE_NAME} (${QGIS_VERSIO
2929

3030
#############################################################
3131
# Configure CCache if available
32-
option(USE_CCACHE "Use ccache" ON)
33-
if (USE_CCACHE)
32+
IF(NOT MSVC)
33+
option(USE_CCACHE "Use ccache" ON)
34+
if (USE_CCACHE)
3435
find_program(CCACHE_FOUND ccache)
3536
if(CCACHE_FOUND)
3637
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
3738
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
3839
endif(CCACHE_FOUND)
39-
endif()
40+
endif(USE_CCACHE)
41+
endif(NOT MSVC)
4042

4143
# in generated makefiles use relative paths so the project dir is moveable
4244
# Note commented out since it cause problems but it would be nice to resolve these and enable

INSTALL

+70-65
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
QGIS
22
Building QGIS from source - step by step
3-
Friday May 11, 2018
3+
Wednesday June 20, 2018
44

55

6-
Last Updated: Friday May 11, 2018
7-
Last Change : Friday May 11, 2018
6+
Last Updated: Wednesday June 20, 2018
7+
Last Change : Wednesday June 20, 2018
88

99

1010
1. Introduction
@@ -430,12 +430,11 @@ To enable debug prints for the current user, execute:
430430
4.1. Building with Microsoft Visual Studio
431431
==========================================
432432

433-
This section describes how to build QGIS using Visual Studio on Windows. This
434-
is currently also how the binary QGIS packages are made (earlier versions used
435-
MinGW).
433+
This section describes how to build QGIS using Visual Studio (MSVC) 2015 on Windows.
434+
This is currently also how the binary QGIS packages are made (earlier versions used MinGW).
436435

437436
This section describes the setup required to allow Visual Studio to be used to
438-
build QGIS.
437+
build QGIS.
439438

440439

441440
4.1.1. Visual C++ Community Edition
@@ -457,10 +456,6 @@ Download and install following packages:
457456
| OSGeo4W | http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe (32bit) or http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe (64bit) |
458457
| ninja | https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-win.zip |
459458

460-
OSGeo4W does not only provide ready packages for the current QGIS release and
461-
nightly builds of master, but also offers most of the dependencies needs to
462-
build it.
463-
464459
For the QGIS build you need to install following packages from cygwin:
465460

466461
- bison
@@ -469,19 +464,22 @@ For the QGIS build you need to install following packages from cygwin:
469464

470465
and from OSGeo4W (select Advanced Installation):
471466

472-
- qgis-rel-deps
467+
- qgis-dev-deps
473468

474469
This will also select packages the above packages depend on.
475470

476-
If you install other packages, this might cause issues. Particularly, make sure
477-
not to install the msinttypes package. It installs a stdint.h file in
478-
OSGeo4W[64]\include, that conflicts with Visual Studio own stdint.h, which for
479-
example breaks the build of the virtuallayer provider.
471+
If you install other packages, this might cause issues. Particularly, make sure
472+
not to install the msinttypes package. It installs a stdint.h file in
473+
OSGeo4W[64]\include, that conflicts with Visual Studio own stdint.h, which for
474+
example breaks the build of the virtual layer provider.
480475

481476
Earlier versions of this document also covered how to build all above
482477
dependencies. If you're interested in that, check the history of this page in the Wiki
483478
or the SVN repository.
484479

480+
ninja:
481+
copy ninja.exe to d:\OSGeo4W64\bin\
482+
485483

486484
4.1.3. Setting up the Visual Studio project with CMake
487485
======================================================
@@ -496,71 +494,78 @@ variables create the following batch file (assuming the above packages were
496494
installed in the default locations):
497495

498496
@echo off
499-
set OSGEO4W_ROOT=C:\OSGeo4W
500-
call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
501-
call "%OSGEO4W_ROOT%\bin\py3_env.bat"
502-
call "%OSGEO4W_ROOT%\bin\qt5_env.bat"
503-
504-
set O4W_ROOT=%OSGEO4W_ROOT:\=/%
505-
set LIB_DIR=%O4W_ROOT%
506-
507-
call "C:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
508-
path %path%;C:\Program Files\Microsoft Visual Studio 14.0\VC\bin
509-
510-
path %PATH%;C:\Program Files\CMake\bin;c:\cygwin\bin
511-
512-
@set GRASS_PREFIX=c:/OSGeo4W/apps/grass/grass-7.2.1
513-
@set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\include
514-
@set LIB=%LIB%;%OSGEO4W_ROOT%\lib;%OSGEO4W_ROOT%\lib
515-
516-
set LIB=%LIB%;%OSGEO4W_ROOT%\apps\Qt5\lib;%OSGEO4W_ROOT%\lib
517-
set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\apps\Qt5\include;%OSGEO4W_ROOT%\include
518-
497+
call X:\src\qgis\ms-windows\osgeo4w\msvc-env.bat x86_64
519498
@cmd
520499

521-
Start the batch file and on the command prompt checkout the QGIS source from
500+
Save the batch file as d:\OSGeo4W64\OSGeo4W-dev.bat and run it.
501+
On the command prompt checkout the QGIS source from
522502
git to the source directory QGIS:
523503

524504
git clone git://github.com/qgis/QGIS.git
525505

526-
Create a 'build' directory somewhere. This will be where all the build output
527-
will be generated.
506+
Using configonly.cmd to create the MSVC solution file:
507+
We will be using the file ms-windows/osgeo4w/configonly.cmd to create an MSVC solution file.
508+
There are a few options for a solution file, following are the options: ninja, native MSVC.
509+
The advantage of using native MSVC solution is that you can find the root of build problems much easily.
510+
configonly.cmd is meant to create a configured build directory with a MSVC solution file:
511+
512+
```
513+
configonly.cmd
514+
```
515+
516+
Compiling QGIS with MSVC:
517+
We will need to run MSVC with all the environment variables set, thus we will run it as follows:
518+
Run the batch file OSGeo4W-dev.bat you created before. On the command prompt run: devenv
519+
From MSVC, open the solution file
520+
d:\OSGeo4W64\QGIS\ms-windows\osgeo4w\build-qgis-test-x86_64\qgis2.99.0.sln
521+
Try to build the solution go grab a cup of tea, it may take a (while).
522+
If it fails, run it again and again until there are [hopefully] no errors.
523+
524+
Running QGIS from within MSVC:
525+
Edit the properties of the project ALL_BUILD:
526+
Debugging -> Command -> D:\OSGeo4W64\QGIS\ms-windows\osgeo4w\build-qgis-test-x86_64\output\bin\RelWithDebInfo\qgis.exe
527+
Run.
528+
Ignore the "These projects are out of date" message, it appeares even if no files were was changed.
529+
530+
Old alternative method that might still work using cmake-gui:
531+
Create a 'build' directory somewhere. This will be where all the build output
532+
will be generated.
528533

529-
Now run cmake-gui (still from cmd) and in the Where is the source code:
530-
box, browse to the top level QGIS directory.
534+
Now run cmake-gui (still from cmd) and in the Where is the source code:
535+
box, browse to the top level QGIS directory.
531536

532-
In the Where to build the binaries: box, browse to the 'build' directory you
533-
created.
537+
In the Where to build the binaries: box, browse to the 'build' directory you
538+
created.
534539

535-
If the path to bison and flex contains blanks, you need to use the short name
536-
for the directory (i.e. C:\Program Files should be rewritten to
537-
C:\Progra~n, where n is the number as shown in `dir /x C:\``).
540+
If the path to bison and flex contains blanks, you need to use the short name
541+
for the directory (i.e. C:\Program Files should be rewritten to
542+
C:\Progra~n, where n is the number as shown in `dir /x C:\``).
538543

539-
Verify that the 'BINDINGS_GLOBAL_INSTALL' option is not checked, so that python
540-
bindings are placed into the output directory when you run the INSTALL target.
544+
Verify that the 'BINDINGS_GLOBAL_INSTALL' option is not checked, so that python
545+
bindings are placed into the output directory when you run the INSTALL target.
541546

542-
Hit Configure to start the configuration and select Visual Studio 9 2008
543-
and keep native compilers and click Finish.
547+
Hit Configure to start the configuration and select Visual Studio 9 2008
548+
and keep native compilers and click Finish.
544549

545-
The configuration should complete without any further questions and allow you to
546-
click Generate.
550+
The configuration should complete without any further questions and allow you to
551+
click Generate.
547552

548-
Now close cmake-gui and continue on the command prompt by starting
549-
vcexpress. Use File / Open / Project/Solutions and open the
550-
qgis-x.y.z.sln File in your project directory.
553+
Now close cmake-gui and continue on the command prompt by starting
554+
vcexpress. Use File / Open / Project/Solutions and open the
555+
qgis-x.y.z.sln File in your project directory.
551556

552-
Change Solution Configuration from Debug to RelWithDebInfo (Release
553-
with Debug Info) or Release before you build QGIS using the ALL_BUILD
554-
target (otherwise you need debug libraries that are not included).
557+
Change Solution Configuration from Debug to RelWithDebInfo (Release
558+
with Debug Info) or Release before you build QGIS using the ALL_BUILD
559+
target (otherwise you need debug libraries that are not included).
555560

556-
After the build completed you should install QGIS using the INSTALL target.
561+
After the build completed you should install QGIS using the INSTALL target.
557562

558-
Install QGIS by building the INSTALL project. By default this will install to
559-
c:\Program Files\qgis<version> (this can be changed by changing the
560-
CMAKE_INSTALL_PREFIX variable in cmake-gui).
563+
Install QGIS by building the INSTALL project. By default this will install to
564+
c:\Program Files\qgis<version> (this can be changed by changing the
565+
CMAKE_INSTALL_PREFIX variable in cmake-gui).
561566

562-
You will also either need to add all the dependency DLLs to the QGIS install
563-
directory or add their respective directories to your PATH.
567+
You will also either need to add all the dependency DLLs to the QGIS install
568+
directory or add their respective directories to your PATH.
564569

565570

566571
4.1.4. Packaging
@@ -600,7 +605,7 @@ Now create a package.
600605

601606
./quickpackage.sh
602607

603-
After this you should now have a nsis installer containing your own build
608+
After this you should now have a nsis installer containing your own build
604609
of QGIS and all dependencies needed to run it on a windows machine.
605610

606611

0 commit comments

Comments
 (0)