Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] CMake build with Visual Studio support #289

Closed
wants to merge 265 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
265 commits
Select commit Hold shift + click to select a range
acccffc
install sqlfiles to etc/sql
rkanavath Jan 28, 2018
7db4499
install lock, clean_temp, echo to ./etc/
rkanavath Jan 28, 2018
491fe75
Revert "Revert "test parsetab""
rkanavath Jan 28, 2018
22f947a
fix on py2.7
rkanavath Jan 28, 2018
d24d665
install libs
rkanavath Jan 28, 2018
70dc76c
link with dl lib
rkanavath Jan 28, 2018
5719c60
cleanup cmake code
rkanavath Jan 28, 2018
47ffe48
fix python script & lib install dirs
rkanavath Jan 28, 2018
4b38260
fixed gisbase for grass startup script
rkanavath Jan 28, 2018
39753a3
call correct python interp with version
rkanavath Jan 28, 2018
6634794
install modules to bin
rkanavath Jan 28, 2018
44ecfa6
add PNG as dependency to r.out.png
rkanavath Jan 28, 2018
f4db409
install __init__.py
rkanavath Jan 28, 2018
017d3f6
wrong install dir for python api
rkanavath Jan 28, 2018
5fc8388
install with rpath to avoid LD_LIBRARY_PATH
rkanavath Jan 28, 2018
f31945f
whitespace fixes
rkanavath Jan 28, 2018
cc72f15
Merge remote-tracking branch 'upstream/master' into cmake_build
rkanavath Dec 26, 2019
baefee5
MSVC: check for _WIN32 to use msvc and mingw32
rkanavath Dec 26, 2019
2a45734
MSVC: disable some programs temporarily
rkanavath Dec 26, 2019
c5ffdf0
update cmake scripts to manage thirdparty libs
rkanavath Dec 26, 2019
c4c9312
disable X11 on windows
rkanavath Dec 26, 2019
6a394ec
update generation of config.h
rkanavath Dec 26, 2019
a4e0423
fix list of cmake depends
rkanavath Dec 26, 2019
93a9ef1
msvc compile fixes
rkanavath Dec 26, 2019
6b77a19
use INIFINITY rather than gcc only division by zero
rkanavath Dec 26, 2019
5bb6fc3
ignore visual studio, cmake files
rkanavath Dec 26, 2019
cfa7d62
use INFINITY rather than divide by zero
rkanavath Dec 26, 2019
098f3a3
use _WIN32 for mingw32 and msvc
rkanavath Dec 26, 2019
295a509
add ssize_t for msvc
rkanavath Dec 26, 2019
227cb15
msvc add _USE_MATH_DEFINES an d export dll
rkanavath Dec 26, 2019
90891e8
keep check for long long int in cache
rkanavath Dec 26, 2019
93ce04d
include driver/init.c when building display drivers
rkanavath Dec 26, 2019
3f36aff
use _WIN32 to build msvc and mingw32
rkanavath Dec 26, 2019
c486ecd
update cmake for lib/db
rkanavath Dec 26, 2019
a028530
link with libm only on unix
rkanavath Dec 26, 2019
9be5cef
msvc: skip chmod on windows msvc
rkanavath Dec 26, 2019
704f33d
use INFINITY rather than diivide by zero
rkanavath Dec 26, 2019
cb2fef8
add msvc specific headers: unistd.h, dirent.h
rkanavath Dec 30, 2019
b1af94a
include grass/gis.h on msvc for __atribute fix
rkanavath Dec 30, 2019
170c125
use _WIN32 rather than__MINGW32__
rkanavath Dec 30, 2019
f996ffa
grass moved to git... So follow that in cmake.
rkanavath Dec 30, 2019
e64d0b0
fix check for HAVE_LONG_LONG
rkanavath Dec 30, 2019
f115c44
include math.h only on msvc. To be discussed
rkanavath Dec 30, 2019
54116bb
void* arithmetic (GCC extension) is not allowed in msvc
rkanavath Dec 30, 2019
d5bfd08
disable d.mon, d.font on msvc. TBD
rkanavath Dec 30, 2019
e730ba2
missing O_ACCMODE on msvc
rkanavath Dec 30, 2019
bf6329e
Add unistd.h on windows
rkanavath Dec 30, 2019
2956f18
dbmi_base: add dirent.h and dirent.c for msvc
rkanavath Dec 30, 2019
3322223
use macro INFINITY rather than GCC divide by zero
rkanavath Dec 30, 2019
51a740b
Revert "include math.h only on msvc. To be discussed"
rkanavath Dec 30, 2019
d21a7e3
MSVC: fix missing strings.h
rkanavath Dec 30, 2019
a5081a9
use math defines on msvc
rkanavath Dec 30, 2019
4d276ea
update find package of fftw
rkanavath Dec 30, 2019
f6ef68c
update setting of HAVE_* defines. 1/n
rkanavath Dec 30, 2019
ff7cd12
add odbc target on windows
rkanavath Dec 30, 2019
f53bfb0
update values in generated config.h
rkanavath Dec 30, 2019
898c134
reorganize cmake option defaults, cmake flags, macros
rkanavath Dec 30, 2019
ab2b961
simlib: min, max are already available
rkanavath Dec 30, 2019
59d3a0d
CMake: reorganize cmake functions, macros, find_scripts (Like a Pro)
rkanavath Dec 30, 2019
b507d3a
fix define used in lib/rst/interp_float
rkanavath Dec 30, 2019
2eafaea
fix tools/timer build
rkanavath Dec 30, 2019
eae5f0b
CMake: reorganize cmake functions (2)
rkanavath Dec 30, 2019
ee35d8d
MSVC: copy UINT64CONST(x) from postgresql
rkanavath Dec 30, 2019
653de5d
WIP: disable pyc generation with g.parser on msvc
rkanavath Dec 30, 2019
1eec8b1
fix ccmath complex struct for msvc
rkanavath Dec 30, 2019
7597fbe
fix use of ifdef loop for msvc
rkanavath Dec 30, 2019
0818322
take out GCC'sim and stick to C standard
rkanavath Dec 31, 2019
f520af0
copy external/ccmath/ccmath.h to include/grass/ccmath_grass.h
rkanavath Dec 31, 2019
90c2406
CMake: enable cmake export all symbols on for shared libs
rkanavath Dec 31, 2019
31c4d49
CMake: build lib/python on MSVC
rkanavath Dec 31, 2019
f84631c
fix yaac.py to work with py3
rkanavath Dec 31, 2019
01eb0ba
MSVC: include sys/time.h if available or time.h
rkanavath Dec 31, 2019
6ba4b4f
CMake: remove debug trace
rkanavath Dec 31, 2019
2550dcb
CMake: minor cleanup
rkanavath Dec 31, 2019
5a185de
CMake: make gui/images
rkanavath Dec 31, 2019
2da0825
CMake: fix run_grass of locale_strings and ctypesgen
rkanavath Dec 31, 2019
d91ec1d
CMake: link with postgres is optional
rkanavath Dec 31, 2019
e4da936
gid_t, uid_t, pid_t exists on *nix
rkanavath Dec 31, 2019
52469e2
use find_library_suffix to switch between debug and rest
rkanavath Dec 31, 2019
cd8d72f
avoid touch .stamp files and depend on generated pyc file
rkanavath Dec 31, 2019
f1a5765
CMake: update definiition of HAVE_PROJ_H
rkanavath Dec 31, 2019
ca1a9e0
include winsock.h only on msvc
rkanavath Dec 31, 2019
e5ec2bc
CMake: remove annoying logs
rkanavath Dec 31, 2019
d496f89
for fix TODO for g.version
rkanavath Dec 31, 2019
df452d3
CMake: depend on pyc file not on a new .stamp file
rkanavath Dec 31, 2019
10c4e8b
CMake: fix syntax error
rkanavath Dec 31, 2019
f03a58d
CMake: fix sqlite include dir variable
rkanavath Dec 31, 2019
0f9f384
CMake: detect version of proj4 before activating defines
rkanavath Dec 31, 2019
b82cee5
MSVC: avoid pulling min max on windows
rkanavath Dec 31, 2019
7d81a38
CMake: update list of enabled modules
rkanavath Dec 31, 2019
7f94310
TODO r.watershed, fix cmake proj4 library varname
rkanavath Dec 31, 2019
9e4ff95
Revert "simlib: min, max are already available"
rkanavath Dec 31, 2019
39cffc5
CMake: update proj library variables (remove suffix 4)
rkanavath Dec 31, 2019
72b35ca
undef min max on msvc
rkanavath Dec 31, 2019
d7da905
use macro INFINITY
rkanavath Dec 31, 2019
87c67cc
MSVC: fix gisinit initialized flag
rkanavath Jan 1, 2020
f83bdb1
MSVC: fix min, max macro stuff
rkanavath Jan 1, 2020
712d138
update TODO, list of modules not built by cmake
rkanavath Jan 1, 2020
c22d567
CMake: update find scripts to find debug then release
rkanavath Jan 1, 2020
4c1455e
CMake: zlib is check with cmake target
rkanavath Jan 1, 2020
6c1d9c4
demolocation is configured in lib/init/CMakeLists.txt
rkanavath Jan 1, 2020
cf7af72
CMake: generate grass.py and grass.sh scripts (build tree)
rkanavath Jan 1, 2020
5b50a95
CMake: fix startup script generation (install tree)
rkanavath Jan 1, 2020
e854b84
fix generation of startup scripts
rkanavath Jan 2, 2020
955aa1a
fix g.list building 1/2
rkanavath Jan 2, 2020
1fc01ce
MSVC: missing regex, use PCRE (wip)
rkanavath Jan 2, 2020
f76a3e0
lib/init: fix startup script on linux
rkanavath Jan 2, 2020
daf6199
fix input configure_file
rkanavath Jan 2, 2020
101ed9c
activate building g.remove on msvc
rkanavath Jan 2, 2020
5536d63
support shell ash (alpine)
rkanavath Jan 2, 2020
2fc77e7
add cmake messages for lib/init/
rkanavath Jan 2, 2020
64da2ae
include sys/time.h if not on msvc.
rkanavath Jan 2, 2020
7c4d721
install proj data files
rkanavath Jan 2, 2020
ee16556
geotiff_csv only required in windows
rkanavath Jan 2, 2020
647999d
wip: add compile defs via interface library
rkanavath Jan 2, 2020
b77832e
fix g.version, grass_gproj with proj6
rkanavath Jan 2, 2020
d339872
Revert "support shell ash (alpine)"
rkanavath Jan 2, 2020
5a0197c
create startup shell scripts in bin
rkanavath Jan 2, 2020
b45f646
fix startup script
rkanavath Jan 4, 2020
0ff53cd
MSVC: configure run_grass.bat, run_python.bat
rkanavath Jan 4, 2020
bb3d796
generate html docs
rkanavath Jan 4, 2020
5acb308
fix copy_python_file (used in gui/wxpython, lib/python)
rkanavath Jan 4, 2020
7b0d5d3
build all gui/wxpython modules
rkanavath Jan 4, 2020
b1236ea
wrapper scripts to build html docs
rkanavath Jan 4, 2020
22e320a
skip html-description for g.parser
rkanavath Jan 4, 2020
fb68e47
update mkhtml.py to with cmake and autoconf
rkanavath Jan 4, 2020
b0123ad
update msvc target properties
rkanavath Jan 4, 2020
51226e8
fix install directory for running from binary tree
rkanavath Jan 4, 2020
66ee1e5
install tools for buildtree and installtree
rkanavath Jan 4, 2020
5119729
fix build docs using cmake POST_BUILD
rkanavath Jan 4, 2020
22611e2
update mkhtml.py for cmake
rkanavath Jan 4, 2020
062bc86
copy header to binary directory using add_custom_command
rkanavath Jan 4, 2020
3bf55ef
install extra files in lib/gis using post_build
rkanavath Jan 4, 2020
35b5d74
add copy_header as depdendency to grass_datetime
rkanavath Jan 4, 2020
773996d
first install tools directory
rkanavath Jan 4, 2020
7b9811b
find cairo debug and then release libs
rkanavath Jan 4, 2020
9918ce3
add POST_BUILD target for documentation only if WITH_DOCS
rkanavath Jan 4, 2020
3511784
build gui/wxpython, fix html description generation
rkanavath Jan 5, 2020
1016dc6
MSVC: uninitialized variable
rkanavath Jan 5, 2020
5ea9140
CMake: update to work with autoconf and cmake
rkanavath Jan 5, 2020
c45ccb5
CMake: install et copy gui/images gui/icons
rkanavath Jan 5, 2020
a176456
CMake: fix grass version date
rkanavath Jan 5, 2020
b33c471
CMake: fix building gui (python files, docs, html)
rkanavath Jan 6, 2020
7d14e35
fix dist include dir name
rkanavath Jan 6, 2020
5101a2c
build docs only if requested
rkanavath Jan 6, 2020
a6d3fd3
fix typo
rkanavath Jan 6, 2020
8eb4482
fix cmake syntax errors
rkanavath Jan 6, 2020
9be152f
cmake linux fixes
rkanavath Jan 6, 2020
c07f406
check for _WIN32 define to work with msvc
rkanavath Jan 6, 2020
40d676d
fix newline at end of file
rkanavath Jan 6, 2020
72ad9a9
WIP: update helper cmake scripts
rkanavath Jan 6, 2020
c317c1a
update copy_header target
rkanavath Jan 6, 2020
94d2968
use gisbase as dist directory for build tree
rkanavath Jan 6, 2020
60efded
cmake: fix build for db/drivers
rkanavath Jan 6, 2020
2126a6d
ignore __pycache__ directory when scanning for .py files
rkanavath Jan 6, 2020
6be413b
wip: use a gisbase as dist directory
rkanavath Jan 6, 2020
bd8ecd1
WIP: temporary fix for find_library output variable
rkanavath Jan 6, 2020
3894b07
CMake: move wxpython cmake codes to gui/wxpython
rkanavath Jan 6, 2020
8b6ebda
raise ScriptError
rkanavath Jan 6, 2020
06901f1
revert to pre cmake version
rkanavath Jan 7, 2020
b36845a
wip wip build docs
rkanavath Jan 7, 2020
da009ff
minor cleanup
rkanavath Jan 8, 2020
ebad9cf
install html docs for driver db
rkanavath Jan 8, 2020
304562f
update building html docs (wip)
rkanavath Jan 8, 2020
3a3e87c
add missing dependencies for v.lrs
rkanavath Jan 8, 2020
6b6e535
update building python modules (wip)
rkanavath Jan 8, 2020
af5f5ff
use target property to check if running python script (docs)
rkanavath Jan 8, 2020
e004cbc
cleanup cmake helper functions (exe, libs, python, docs)
rkanavath Jan 8, 2020
3debd97
copy strings.h and unistd.h on msvc
rkanavath Jan 8, 2020
7a21f7c
revert defined check to __MINGW32__ (one case)
rkanavath Jan 8, 2020
c8cf813
python files (target) depend only grass.script if building docs
rkanavath Jan 8, 2020
b05216f
fix build docs for windows and linux (wip)
rkanavath Jan 8, 2020
0e631ea
seperate list of g.gui.* modules
rkanavath Jan 8, 2020
553c1b1
try to make generic build docs (wip)
rkanavath Jan 8, 2020
ff70f95
build docs html for not win32 (wip)
rkanavath Jan 8, 2020
af44299
fix cmake syntax error
rkanavath Jan 8, 2020
3b82042
update pgm extension for running html description
rkanavath Jan 9, 2020
75a3fa2
remove temp files after docs are finished
rkanavath Jan 9, 2020
f1b0f54
CMake: fix IN_LIST syntax
rkanavath Jan 9, 2020
7d5d94a
ficx cmake syntax error
rkanavath Jan 9, 2020
c46ceeb
fix again linux html description for python with a main script
rkanavath Jan 9, 2020
eb0adf9
wip: include from config build is breaking msvc
rkanavath Jan 9, 2020
e175ba3
msvc: disable db drivers (wip)
rkanavath Jan 9, 2020
a6f81c5
keep _WIN32. issue on windows was from autconf build
rkanavath Jan 9, 2020
e6fd74f
add test.raster3d.lib into NO_HTML_DESCR_TARGETS
rkanavath Jan 9, 2020
efe74ca
CMake: missing endif()
rkanavath Jan 9, 2020
f3f0fa4
x extension on running html descr
rkanavath Jan 9, 2020
8e057ea
copy r.in.wms directory to etc/
rkanavath Jan 9, 2020
1c4313b
fix building py modules
rkanavath Jan 9, 2020
822cee9
add grass dll directory to path windows grass.bat
rkanavath Jan 9, 2020
655a505
alpine linux uses ash
rkanavath Jan 9, 2020
0944c95
debug linux build failures
rkanavath Jan 10, 2020
2361d67
cmake missing endif
rkanavath Jan 10, 2020
94fa319
set main script file only for those selected modules
rkanavath Jan 10, 2020
4a0213d
cmake: fix python docs for linux and windows
rkanavath Jan 10, 2020
96614a6
create scripts directory in gisbase
rkanavath Jan 10, 2020
6e15712
cmake debug message
rkanavath Jan 10, 2020
2247694
add missing include
rkanavath Jan 12, 2020
12bc38e
add cmake find scripts for liblas, netcdf, postgresql
rkanavath Jan 12, 2020
51f3491
update proj4 detection to support 4.x, 5.x , 6.x versions
rkanavath Jan 12, 2020
26e98a2
update cmake functions to build grass modules
rkanavath Jan 12, 2020
94c8b13
add proj4 version defines (support 5.x+)
rkanavath Jan 12, 2020
570b669
add options for v.in.dwg and liblas modules
rkanavath Jan 12, 2020
8704aa4
activate build of modules deactivated
rkanavath Jan 12, 2020
fae4ca8
detecting of new 3rdd party libraries
rkanavath Jan 12, 2020
793226f
fix i.landsat.acca on msvc
rkanavath Jan 12, 2020
664a6f0
add dll export macro for iostream, dspf, calc
rkanavath Jan 12, 2020
effacbb
fix r.mapcalc on msvc
rkanavath Jan 12, 2020
1b5d775
fix r.terraflow on msvc
rkanavath Jan 12, 2020
38d6459
use _WIN32 rather than __MINGW32__ for msvc
rkanavath Jan 12, 2020
b28b17f
use infinity macro to build on msvc
rkanavath Jan 12, 2020
223e858
missing include on msvc
rkanavath Jan 12, 2020
601eab3
copy VERSIONUMBER and license to gisbase/etc
rkanavath Jan 12, 2020
c510ec5
support for multiple proj4 version
rkanavath Jan 12, 2020
fbf2ec7
update building lib/python (except ctypes)
rkanavath Jan 12, 2020
f21ca4c
use INFINITY macro to work with msvc
rkanavath Jan 12, 2020
19a5e52
fix building gui/wxpython/xml
rkanavath Jan 12, 2020
ba30799
void* arithmetic is not allowed in msvc
rkanavath Jan 12, 2020
c5659de
copy __init__.py for python/grass/
rkanavath Jan 12, 2020
0c8eb17
fix wrong cmake varible used
rkanavath Jan 12, 2020
3114d3c
copy init py to etc/python/grass/
rkanavath Jan 12, 2020
06857c8
db/drviers: odbc, sqlite, dbf, ogr, postgresql
rkanavath Jan 12, 2020
68a8679
check for PQCmdTuples in postgresql
rkanavath Jan 12, 2020
96c9f11
add defines to be posix conformat on msvc
rkanavath Jan 12, 2020
954c94a
bring in testing using ctest (wip)
rkanavath Jan 12, 2020
2283e79
improve proj4 detection
rkanavath Jan 12, 2020
c691c99
keep proj4 version string in cache (very useful later)
rkanavath Jan 12, 2020
a33052b
find optional packages quietly
rkanavath Jan 12, 2020
48620b6
use PRIMARY_DEPENDS option in build_module
rkanavath Jan 12, 2020
527fea6
generate wxpython menu xml stuff after building all executables
rkanavath Jan 12, 2020
f5cf997
ogsf and nviz depends on grass_raster
rkanavath Jan 12, 2020
fc724af
update gui/wxpython build
rkanavath Jan 12, 2020
b48e328
add missing modules to build
rkanavath Jan 13, 2020
82e9a20
missing v.clip
rkanavath Jan 13, 2020
9e83f6f
install html file is exists
rkanavath Jan 13, 2020
b2d1d61
cmake cleanup
rkanavath Jan 13, 2020
601f7aa
reorder dependencies of gui/wxpython modules
rkanavath Jan 13, 2020
b2c7bb9
avoid breakage in autconf build
rkanavath Jan 13, 2020
2915948
missing file copy
rkanavath Jan 13, 2020
88a4b6f
fix mkhtml doc building, exe, lib, python, gui
rkanavath Jan 18, 2020
a088243
fix find scripts on windows
rkanavath Jan 20, 2020
511b542
fix always out of date for custom targets
rkanavath Jan 20, 2020
f493d49
fix missing optional dependds to grass gis library
rkanavath Jan 20, 2020
e376a6a
fix missing math.h include
rkanavath Jan 20, 2020
2e65c3a
wrong path used under cmake binary directory
rkanavath Jan 20, 2020
53326c4
keep autoconf build conflict with cmake
rkanavath Jan 20, 2020
1dc86e8
.bat files must be in scripts/
rkanavath Jan 20, 2020
95259c8
fix installation of gui/images, gui/icons
rkanavath Feb 17, 2020
3c221d3
Revert "install html file is exists"
rkanavath Feb 17, 2020
383bbe5
Apply suggestions from code review
neteler Feb 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ OBJ.*
locale/*
bin.*/*
dist.*/*
.vs/*
CMakeSettings.json
config.log
config.status*
error.log
Expand Down
224 changes: 224 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
# AUTHOR(S): Rashad Kanavath <rashad km gmail>
# PURPOSE: Grass root that adds options to activate/deactivate 3rd party libraries
# COPYRIGHT: (C) 2020 by the GRASS Development Team
# This program is free software under the GPL (>=v2)
# Read the file COPYING that comes with GRASS for details.

cmake_minimum_required(VERSION 3.3)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

#if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
# set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
#endif()

project(GRASSGIS)

set(BUILD_SHARED_LIBS ON)
#message(FATAL_ERROR "VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}")
if(MSVC)
if(BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/find_scripts;${CMAKE_SOURCE_DIR}/cmake/modules;${CMAKE_MODULE_PATH}")

set(default_option_enabled ON)
if(WIN32)
set(default_option_enabled OFF)
endif()

if(CMAKE_BUILD_TYPE)
set( grass_build_type "${CMAKE_BUILD_TYPE}" )
string( TOLOWER "${grass_build_type}" grass_build_type_lc )
set(find_library_suffix "_RELEASE")
if( grass_build_type_lc STREQUAL "debug" )
set(find_library_suffix "_DEBUG")
endif()
else()
set(find_library_suffix "")
endif()

option(WITH_CAIRO "Build with cairo support ." ON)
option(WITH_X11 "Build with X11 support ." ${default_option_enabled})
option(WITH_OPENGL "Build with opengl support ." ON)
option(WITH_SQLITE "enable sqlite support" ON)
option(WITH_POSTGRES "enable postgres support" ON)
option(WITH_NLS "enable nls support" ${default_option_enabled})
option(WITH_BZLIB "enable bzlib support" ON)
option(WITH_BLAS "enable blas support" ON)
option(WITH_LAPACK "enable lapack support" ON)
option(WITH_LIBLAS "enable libLAS support" ON)
option(WITH_OPENDWG "enable v.in.dwg" OFF)

option(WITH_PYTHON "Build python bindings" ON)
option(WITH_LARGEFILES "enable largefile support" ${default_option_enabled})
option(WITH_DOCS "Build documentation" ON)
if(APPLE)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
set(CMAKE_MACOSX_RPATH TRUE)
endif()

set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")

include(get_host_arch)
get_host_arch(BUILD_ARCH)

include(get_versions)
get_versions("include/VERSION"
GRASS_VERSION_MAJOR
GRASS_VERSION_MINOR
GRASS_VERSION_RELEASE
GRASS_VERSION_DATE)

set(GRASS_VERSION_NUMBER ${GRASS_VERSION_MAJOR}.${GRASS_VERSION_MINOR}.${GRASS_VERSION_RELEASE})
message(STATUS "GRASS_VERSION_NUMBER = '${GRASS_VERSION_NUMBER}'")
set(GRASS_VERSION_UPDATE_PKG "0.2")

include(set_compiler_flags)
set_compiler_flags()

include(repo_status)
repo_status("${CMAKE_CURRENT_LIST_DIR}" GRASS_VERSION_GIT)

enable_testing()

# Setup build locations.
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
endif()

include(build_module)
include(build_program)
include(build_program_in_subdir)
include(build_library_in_subdir)
include(copy_python_files_in_subdir)
include(build_script_in_subdir)
include(build_gui_in_subdir)
include(check_target)

add_subdirectory(thirdparty)
set(MKHTML_PY ${CMAKE_BINARY_DIR}/tools/mkhtml.py)

set(GISBASE ${CMAKE_BINARY_DIR}/gisbase)
file(TO_NATIVE_PATH "${GISBASE}" GISBASE_NATIVE)
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/bin" BINARY_DIR)
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/lib" LIB_DIR)
file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}" MODULE_TOPDIR)
file(TO_NATIVE_PATH "${GISBASE}/scripts" SCRIPTS_DIR)
file(TO_NATIVE_PATH "${GISBASE}/etc/config/rc" GISRC)
file(TO_NATIVE_PATH "${GISBASE}/etc/python" ETC_PYTHON_DIR)
file(TO_NATIVE_PATH "${GISBASE}/gui/wxpython" GUI_WXPYTHON_DIR)
if(WIN32)
set(sep "\;")
set(env_path "")
else()
set(sep ":")
set(env_path ":$ENV{PATH}")
endif()


set(grass_env_command ${CMAKE_COMMAND} -E env
"PATH=${BINARY_DIR}${sep}${SCRIPTS_DIR}${env_path}"
"PYTHONPATH=${ETC_PYTHON_DIR}${sep}${GUI_WXPYTHON_DIR}${sep}$ENV{PYTHONPATH}"
"LD_LIBRARY_PATH=${LIB_DIR}${sep}$ENV{LD_LIBRARY_PATH}"
"GISBASE=${GISBASE_NATIVE}"
"GISRC=${GISRC}"
"LC_ALL=C"
"LANG=C"
"LANGUAGE=C"
"MODULE_TOPDIR=${MODULE_TOPDIR}"
"VERSION_NUMBER=\"${GRASS_VERSION_NUMBER}\""
"VERSION_DATE=\"${GRASS_VERSION_DATE}\"")



set(NO_HTML_DESCR_TARGETS "g.parser;ximgview;test.raster3d.lib")
add_subdirectory(include)

include_directories("${CMAKE_BINARY_DIR}/include")
if(MSVC)
include_directories("${CMAKE_SOURCE_DIR}/msvc")
endif()

execute_process(
COMMAND ${CMAKE_COMMAND} -E echo "Creating directories in ${GISBASE}"
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/bin/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/scripts/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/demolocation/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/config/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/driver/db/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/tools/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/lib/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/lister/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/python/grass/lib
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/wxpython/xml/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/icons/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/images/
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/docs/html/
)

add_subdirectory(lib)
add_subdirectory(tools)
set(modules_list)


set(ALL_SUBDIRS
general
db
display
imagery
misc
raster
raster3d
scripts
vector
temporal
# ps
)

foreach(d ${ALL_SUBDIRS})
add_subdirectory(${d})
endforeach()
add_custom_target(ALL_MODULES
COMMAND ${CMAKE_COMMAND} -E echo "Building all modules"
DEPENDS ${modules_list})

###message(FATAL_ERROR "modules_list=${modules_list}")

if(WITH_PYTHON)
add_subdirectory(gui)
endif()

if(WITH_DOCS)
add_subdirectory(doc)
add_subdirectory(man)
endif() # WITH_DOCS


####add_subdirectory(locale)

# TODO: To be discussed
# add_subdirectory(testsuite)
# add_subdirectory(macosx)

if(WITH_X11)
build_program_in_subdir(visualization/ximgview DEPENDS grass_gis X11)
endif()
35 changes: 35 additions & 0 deletions cmake/copy_g_gui_module.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# AUTHOR(S): Rashad Kanavath <rashad km gmail>
# PURPOSE: Copy g.gui script plus .bat file if on windows
# COPYRIGHT: (C) 2020 by the GRASS Development Team
# This program is free software under the GPL (>=v2)
# Read the file COPYING that comes with GRASS for details.
# -DSOURCE_DIR
# -DGISBASE
# -DG_NAME
# -DSRC_SCRIPT_FILE
# -DBINARY_DIR

set(SCRIPT_EXT "")
if(WIN32)
set(SCRIPT_EXT ".py")
endif()

if(WIN32)
set(PGM_NAME ${G_NAME})
configure_file(
${SOURCE_DIR}/cmake/windows_launch.bat.in
${GISBASE}/scripts/${G_NAME}.bat @ONLY)
endif(WIN32)

set(TMP_SCRIPT_FILE ${BINARY_DIR}/CMakeFiles/${G_NAME}${SCRIPT_EXT})
configure_file(${SRC_SCRIPT_FILE} ${TMP_SCRIPT_FILE} COPYONLY)
file(
COPY ${TMP_SCRIPT_FILE}
DESTINATION ${GISBASE}/scripts/
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)


file(REMOVE ${TMP_SCRIPT_FILE})
61 changes: 61 additions & 0 deletions cmake/ctypesgen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# AUTHOR(S): Rashad Kanavath <rashad km gmail>
# PURPOSE: Cmake building of lib/python/ctypes (TODO)
# COPYRIGHT: (C) 2020 by the GRASS Development Team
# This program is free software under the GPL (>=v2)
# Read the file COPYING that comes with GRASS for details.

set(ENV{GISRC} "${BIN_DIR}/demolocation/.grassrc${GRASS_VERSION_MAJOR}${GRASS_VERSION_MINOR}")
set(ENV{GISBASE} "${BIN_DIR}")
set(ENV{PATH} "${BIN_DIR}/bin:${BIN_DIR}/scripts:$ENV{PATH}")
set(ENV{PYTHONPATH} "${BIN_DIR}/gui/wxpython:${BIN_DIR}/etc/python:$ENV{PYTHONPATH}")
if(NOT MSVC)
set(ENV{LD_LIBRARY_PATH} "${BIN_DIR}/lib:$ENV{LD_LIBRARY_PATH}")
endif()
set(ENV{LC_ALL} C)

set(LIBRARIES)
foreach(LIB ${LIBS})
if(WIN32)
list(APPEND LIBRARIES "--library=${BIN_DIR}/bin/${LIB}.dll")
elseif(APPLE)
list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.so")
else()
#This can be linux or unix
list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.so")
endif()
endforeach()

set(HEADERS)
foreach(HDR ${HDRS})
list(APPEND HEADERS "${BIN_DIR}/include/grass/${HDR}")
endforeach()

foreach(req OUT_FILE HDRS LIBS CTYPESGEN_PY COMPILER )
if(NOT DEFINED ${req} OR "${${req}}" STREQUAL "")
message(FATAL_ERROR "you must set ${req}")
endif()
endforeach()

if(MSVC)
set(CTYPESFLAGS "${COMPILER} -E -DPACKAGE=\"grasslibs\"")
else()
set(CTYPESFLAGS "${COMPILER} -E -DPACKAGE=\"grasslibs\" -D__GLIBC_HAVE_LONG_LONG")
endif()

message(STATUS "Running ${PYTHON_EXECUTABLE} ${CTYPESGEN_PY} --cpp=${CTYPESFLAGS} --includedir=\"${BIN_DIR}/include\" --runtime-libdir=\"${BIN_DIR}/lib\" ${HEADERS} ${LIBRARIES} --output=${OUT_FILE}")
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${CTYPESGEN_PY}
--cpp=${CTYPESFLAGS}
--includedir="${BIN_DIR}/include"
--runtime-libdir="${BIN_DIR}/lib"
${HEADERS}
${LIBRARIES}
--output=${OUT_FILE}
OUTPUT_VARIABLE ctypesgen_OV
ERROR_VARIABLE ctypesgen_EV
RESULT_VARIABLE ctypesgen_RV
)

if( ctypesgen_RV )
message(FATAL_ERROR "ctypesgen.py: ${ctypesgen_EV} \n ${ctypesgen_OV}")
endif()
Loading