-
-
Notifications
You must be signed in to change notification settings - Fork 361
CMake build environment with Visual Studio support #2684
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
Changes from all commits
616be6a
98cb9a0
a1c304b
2572080
637160d
d505352
0099daa
297f2b3
77c79a1
f590798
b79ac0e
a189cb7
b957a81
0d4e0da
20c00ba
c158111
44acbfa
4e8ddc7
ab8a0a3
0834a87
ec65ecb
e094369
7aeb0b6
2838cc9
74207c5
ea058ff
5f1dcf0
3cb0241
2e0e73b
f258904
816b835
3eae792
c160dd5
644abd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# inspired by "build GDAL library and to run test with CMake" | ||
# from https://github.com/OSGeo/gdal/blob/master/.github/workflows/cmake_builds.yml | ||
|
||
name: Build and test with CMake | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'doc/**' | ||
branches-ignore: | ||
- 'backport**' | ||
pull_request: | ||
paths-ignore: | ||
- 'doc/**' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
CMAKE_UNITY_BUILD: OFF | ||
|
||
permissions: | ||
contents: read # to fetch code (actions/checkout) | ||
|
||
jobs: | ||
|
||
build-linux-ubuntu-20.04: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
CMAKE_OPTIONS: -DPython_LOOKUP_VERSION=3.8 -DUSE_CCACHE=ON | ||
cache-name: cmake-ubuntu-20.04 | ||
steps: | ||
- name: Checkout GRASS | ||
uses: actions/checkout@v3 | ||
- name: Setup cache | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: ${{ github.workspace }}/.ccache | ||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.base_ref }}${{ github.ref_name }}-${{ github.run_id }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ env.cache-name }}-${{ github.base_ref }} | ||
${{ runner.os }}-${{ env.cache-name }} | ||
- name: Install CMake 3.11.4 | ||
run: | | ||
cd ${GITHUB_WORKSPACE} | ||
wget https://github.com/Kitware/CMake/releases/download/v3.11.4/cmake-3.11.4-Linux-x86_64.tar.gz | ||
tar xzf cmake-3.11.4-Linux-x86_64.tar.gz | ||
echo "CMAKE_DIR=$GITHUB_WORKSPACE/cmake-3.11.4-Linux-x86_64/bin" >> $GITHUB_ENV | ||
echo "$GITHUB_WORKSPACE/cmake-3.11.4-Linux-x86_64/bin" >> $GITHUB_PATH | ||
- run: | | ||
cmake --version | ||
- name: Install dependencies | ||
run: | | ||
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable | ||
sudo apt-get update | ||
sudo apt-get install -y -q build-essential \ | ||
flex make bison gcc libgcc1 g++ ccache \ | ||
python3 python3-dev \ | ||
python3-opengl python3-wxgtk4.0 \ | ||
python3-dateutil libgsl-dev python3-numpy \ | ||
wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \ | ||
libwxbase3.0-dev libbz2-dev zlib1g-dev gettext \ | ||
libtiff5-dev libpnglite-dev libcairo2 libcairo2-dev \ | ||
sqlite3 libsqlite3-dev \ | ||
libpq-dev libreadline6-dev libfreetype6-dev \ | ||
libfftw3-3 libfftw3-dev \ | ||
libboost-thread-dev libboost-program-options-dev libpdal-dev\ | ||
subversion libzstd-dev checkinstall \ | ||
libglu1-mesa-dev libxmu-dev \ | ||
ghostscript wget -y make ccache g++ | ||
sudo apt-get update -y | ||
- name: Configure ccache | ||
run: | | ||
echo CCACHE_BASEDIR=$PWD >> ${GITHUB_ENV} | ||
echo CCACHE_DIR=$PWD/.ccache >> ${GITHUB_ENV} | ||
echo CCACHE_MAXSIZE=250M >> ${GITHUB_ENV} | ||
ccache -z | ||
working-directory: ${{ github.workspace }} | ||
- name: Configure | ||
run: | | ||
mkdir build | ||
cmake ${CMAKE_OPTIONS} -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... this still fails in the CI (using CMake 3.11.4). It still a more recent CMake version needed? (I cannot find any more the related comment by @echoix) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default version in Ubuntu 20.04 is 3.16.x, and GitHub runners already include 3.25.1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which version to be used, do you have any recommendation (e.g., we may try 3.13 - or later)? |
||
- name: Build | ||
run: | | ||
cd $GITHUB_WORKSPACE/build | ||
cmake --build . -j$(nproc) | ||
- name: ccache statistics | ||
run: ccache -s | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
# AUTHOR(S): Rashad Kanavath <rashad km gmail> | ||
# PURPOSE: GRASS GIS root that adds options to activate/deactivate 3rd party libraries | ||
# COPYRIGHT: (C) 2020-2022 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.11) | ||
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" OFF) | ||
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}/utils/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}/utils/ | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/lib/ | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/python/ | ||
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(utils) | ||
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() | ||
|
||
neteler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
add_subdirectory(python) | ||
|
||
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() |
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}) |
Uh oh!
There was an error while loading. Please reload this page.