-
-
Notifications
You must be signed in to change notification settings - Fork 293
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
CMake build environment with Visual Studio support #2684
Closed
Closed
Changes from 12 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
616be6a
parent 464ffca1e1fbb98107593ee60c43a8449e567eed
rkanavath 98cb9a0
revert C related INFINITY/NAN changes (this is taken care of in #2681)
neteler a1c304b
Sync to PR Cmake build2 #348 (replaces #348)
neteler 2572080
CI fix for pylint in gui/wxpython called with wildcard
neteler 637160d
cmake/find_scripts/FindPROJ.cmake: update to PROJ > 4
neteler d505352
cmake/find_scripts/FindPostgreSQL.cmake: update to https://github.com…
neteler 0099daa
various path updates (sync to main)
neteler 297f2b3
grass7 -> grass8; msg cosmetics
neteler 77c79a1
CI: cmake compile script
neteler f590798
fix syntax
neteler b79ac0e
fix Build step
neteler a189cb7
Build step debugging
neteler b957a81
Simplify cmake command call
neteler 0d4e0da
Remove debugging leftover.
neteler 20c00ba
make -> cmake
neteler c158111
update year
neteler 44acbfa
python_bandref -> python_semantic_label
neteler 4e8ddc7
remove outdated bandref
neteler ab8a0a3
bandref -> semantic_label
neteler 0834a87
added python/CMakeLists.txt (from https://github.com/OSGeo/grass/pull…
neteler ec65ecb
add_subdirectory(python)
neteler e094369
fix path to grass/script/setup.py
neteler 7aeb0b6
remove files deleted in PR #1400
neteler 2838cc9
Fix missing EOL
neteler 74207c5
just peek in the folder (by @echoix)
neteler ea058ff
sync clang-format changes from main
neteler 5f1dcf0
Merge branch 'main' into cmake_build
neteler 3cb0241
apply clang-format
nilason 2e0e73b
cmake_minimum_required version 3.11
neteler f258904
update to CMake 3.11.4
neteler 816b835
add VERBATIM
neteler 3eae792
pylint: ignore cmakelists.txt
nilason c160dd5
homogenize ubuntu image name
neteler 644abd4
Merge branch 'main' into cmake_build
neteler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# 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-focal: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
CMAKE_OPTIONS: -DPython_LOOKUP_VERSION=3.8 -DUSE_CCACHE=ON | ||
cache-name: cmake-ubuntu-focal | ||
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.9.1 | ||
run: | | ||
cd ${GITHUB_WORKSPACE} | ||
wget https://github.com/Kitware/CMake/releases/download/v3.9.1/cmake-3.9.1-Linux-x86_64.tar.gz | ||
tar xzf cmake-3.9.1-Linux-x86_64.tar.gz | ||
echo "CMAKE_DIR=$GITHUB_WORKSPACE/cmake-3.9.1-Linux-x86_64/bin" >> $GITHUB_ENV | ||
echo "$GITHUB_WORKSPACE/cmake-3.9.1-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 \ | ||
neteler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 -p $GITHUB_WORKSPACE/build | ||
cd $GITHUB_WORKSPACE/build | ||
cmake ${CMAKE_OPTIONS} .. | ||
neteler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ls $GITHUB_WORKSPACE/build | ||
sudo apt-get install -y -q mlocate ; sudo updatedb | ||
locate include/Make/Platform.make | ||
neteler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Build | ||
run: | | ||
cd $GITHUB_WORKSPACE/build | ||
make -j$(nproc) | ||
neteler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: ccache statistics | ||
run: ccache -s | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
# 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.3) | ||
neteler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
|
||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason that cmake is installed that way on the runner? I understand that it isn't really for the GitHub runners, since cmake is installed by default (un ubuntu-latest (22.04LTS) it is currently cmake 3.25.1), but for documenting what was used, maybe for local porting. However, GitHub workflow files are already not runnable as is locally (I'm not talking about self-hosted runners here).
If there was no specific reason for using that version of cmake (released August 10, 2017), we could take it out, install one from apt-get (ubuntu), or use a GitHub action step that is integrated, like https://github.com/marketplace/actions/get-cmake#if-you-want-to-use--latest-stable-you-can-use-this-one-liner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was only my guess-work, maybe totally wrong. Here I took inspiration from the GDAL workflow while having zero knowledge about cmake :-)