Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
98bda80
Add CMake support
rkanavath Jan 14, 2020
628e04b
Avoid use of bare-exception
rkanavath Jan 14, 2020
2d3d0ba
use python3
rkanavath Jan 14, 2020
6ea13bc
check for GRASS_CONFIG_DIR to load rc and env.sh from it
rkanavath Jan 15, 2020
6de92e6
Add cmake configure input files
rkanavath Jan 15, 2020
4c97b17
fix install commands
rkanavath Jan 15, 2020
7aed313
PROJ.4 -> PROJ
rkanavath Jan 15, 2020
cbbb42e
fix ctypesgen
rkanavath Feb 17, 2020
4a915f7
fix build gui/icons
rkanavath Feb 17, 2020
4f75c29
fix cmake deps of nviz, ogsf
rkanavath Feb 17, 2020
abea61c
Support for MSVC. Use _WIN32 instead of __MINGW32__
rkanavath Feb 14, 2020
4478942
MSVC: add unistd.h
rkanavath Feb 14, 2020
a24d946
MSVC: missing strings.h
rkanavath Feb 14, 2020
69d32cd
MSVC: missing dirent on MSVC
rkanavath Feb 14, 2020
2236aa6
MSVC: win32 gettimeofday replacement from postgresql
rkanavath Feb 14, 2020
fb134e0
MSVC: add __declspec attribute on windows
rkanavath Feb 15, 2020
d1caa3e
export static int initialized
rkanavath Feb 15, 2020
57a6ed1
MSVC: ostream header is avaiable in GCC and MSVC
rkanavath Feb 15, 2020
5696858
missing include
rkanavath Feb 15, 2020
bfb3f12
MSVC: disable warning for function without return type
rkanavath Feb 15, 2020
6357415
MSVC: chmod is unix only
rkanavath Feb 15, 2020
e0b7170
MSVC: fix struct complex
rkanavath Feb 15, 2020
af03bf1
MSVC does not support VLAs
rkanavath Feb 15, 2020
ceb1d12
MSVC: Fix pointer arithmetic
rkanavath Feb 15, 2020
f76f205
MSVC: fix nan/inf issues on msvc and gcc
rkanavath Feb 15, 2020
999f45d
missing include unistd.h
rkanavath Feb 18, 2020
4321606
define unistd only if unistd.h is not available
rkanavath Feb 18, 2020
0aec42d
fix msvc broken build (works on gcc)
rkanavath Feb 18, 2020
17b6ea3
msvc: __atribute__ is gcc only
rkanavath Feb 18, 2020
bb380ca
check for _WIN32 to support msvc and mingw
rkanavath Feb 18, 2020
93e3d0e
msvc: include winsock.h for struct timeval
rkanavath Feb 18, 2020
f6c5229
msvc: include sys/time.h, strings.h only if available
rkanavath Feb 18, 2020
3503533
msvc: undef min max and use math.h for math constants
rkanavath Feb 18, 2020
20ca623
msvc: missing headers for windows build
rkanavath Feb 18, 2020
9714a90
msvc: fix warning POINT2D_C already defined
rkanavath Feb 18, 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
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}/etc/config/rc")
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}/lib/${LIB}.${GRASS_VERSION_NUMBER}.dll")
elseif(APPLE)
list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.${GRASS_VERSION_NUMBER}.so")
else()
#This can be linux or unix
list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.${GRASS_VERSION_NUMBER}.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