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

cmake: use imported GDAL target and clean up dependencies #5263

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ jobs:
- name: Configure
run: |
cmake ${CMAKE_OPTIONS} -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -G Ninja \
-DCMAKE_C_FLAGS="-I/usr/include -I/usr/include/gdal" \
-DCMAKE_CXX_FLAGS="-I/usr/include -I/usr/include/gdal" \
-DCMAKE_C_FLAGS="-I/usr/include" -DCMAKE_CXX_FLAGS="-I/usr/include" \
-DCMAKE_INSTALL_PREFIX=$HOME/install -DWITH_NLS=OFF -DWITH_GUI=OFF -DWITH_DOCS=OFF
- name: Print CMakeCache.txt
shell: bash -el {0}
Expand Down
25 changes: 0 additions & 25 deletions cmake/find_scripts/FindGDAL.cmake

This file was deleted.

10 changes: 2 additions & 8 deletions cmake/modules/CheckDependentLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ if(PROJ_FOUND)
endif()

find_package(GDAL REQUIRED)
if(GDAL_FOUND)
add_library(GDAL INTERFACE IMPORTED GLOBAL)
set_property(TARGET GDAL PROPERTY INTERFACE_LINK_LIBRARIES ${GDAL_LIBRARY})
set_property(TARGET GDAL PROPERTY INTERFACE_INCLUDE_DIRECTORIES
${GDAL_INCLUDE_DIR})
endif()

find_package(ZLIB REQUIRED)
if(ZLIB_FOUND)
Expand Down Expand Up @@ -369,8 +363,8 @@ if(Python3_FOUND)
endif()

check_target(PROJ HAVE_PROJ_H)
check_target(GDAL HAVE_GDAL)
check_target(GDAL HAVE_OGR)
check_target(GDAL::GDAL HAVE_GDAL)
check_target(GDAL::GDAL HAVE_OGR)
check_target(ZLIB HAVE_ZLIB_H)
check_target(ICONV HAVE_ICONV_H)
check_target(LIBPNG HAVE_PNG_H)
Expand Down
3 changes: 2 additions & 1 deletion db/drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ build_program_in_subdir(
grass_dbmibase
grass_dbmidriver
grass_sqlp
GDAL
PRIMARY_DEPENDS
GDAL::GDAL
DEFS
"${grass_dbstubs_DEFS}"
HTML_FILE_NAME
Expand Down
35 changes: 23 additions & 12 deletions display/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,33 @@ if(WITH_DOCS)
install(FILES ${OUTDIR}/${GRASS_INSTALL_DOCDIR}/grass_logo.txt
DESTINATION ${GRASS_INSTALL_DOCDIR})
endif()
build_program_in_subdir(d.grid DEPENDS grass_gis grass_symb grass_gproj
grass_display GDAL ${LIBM})
build_program_in_subdir(
d.grid
DEPENDS
grass_gis
grass_symb
grass_gproj
grass_display
${LIBM})
build_program_in_subdir(d.his DEPENDS grass_gis grass_display grass_raster)
build_program_in_subdir(d.histogram DEPENDS grass_gis grass_display
grass_raster ${LIBM})
build_program_in_subdir(d.info DEPENDS grass_gis grass_display)
build_program_in_subdir(d.labels DEPENDS grass_gis grass_display ${LIBM})
build_program_in_subdir(d.legend DEPENDS grass_gis grass_display grass_raster
grass_raster3d ${LIBM})
build_program_in_subdir(
d.legend
DEPENDS
grass_gis
grass_display
grass_raster
grass_raster3d
${LIBM})
build_program_in_subdir(d.legend.vect DEPENDS grass_gis grass_display
grass_symb ${LIBM})
build_program_in_subdir(d.linegraph DEPENDS grass_gis grass_display grass_symb
grass_raster)
build_program_in_subdir(d.northarrow DEPENDS grass_gis grass_display grass_symb ${LIBM})
build_program_in_subdir(d.northarrow DEPENDS grass_gis grass_display grass_symb
${LIBM})
if(WITH_DOCS)
file(MAKE_DIRECTORY ${OUTDIR}/${GRASS_INSTALL_DOCDIR}/northarrows)
file(GLOB d_northarrow_png
Expand All @@ -103,8 +116,9 @@ if(WITH_DOCS)
install(DIRECTORY ${OUTDIR}/${GRASS_INSTALL_DOCDIR}/northarrows
DESTINATION ${GRASS_INSTALL_DOCDIR})
endif()
build_program_in_subdir(d.path DEPENDS grass_gis grass_display grass_vector GDAL)
build_program_in_subdir(d.profile DEPENDS grass_gis grass_display grass_raster ${LIBM})
build_program_in_subdir(d.path DEPENDS grass_gis grass_display grass_vector)
build_program_in_subdir(d.profile DEPENDS grass_gis grass_display grass_raster
${LIBM})
build_program_in_subdir(d.rast DEPENDS grass_gis grass_display grass_raster)
build_program_in_subdir(d.rast.arrow DEPENDS grass_gis grass_raster
grass_display ${LIBM})
Expand All @@ -125,7 +139,6 @@ build_program_in_subdir(
grass_raster
grass_symb
grass_vector
GDAL
${LIBM})
build_program_in_subdir(
d.vect.chart
Expand All @@ -137,7 +150,6 @@ build_program_in_subdir(
grass_gis
grass_symb
grass_vector
GDAL
${LIBM})
build_program_in_subdir(
d.vect.thematic
Expand All @@ -149,6 +161,5 @@ build_program_in_subdir(
grass_display
grass_gis
grass_symb
grass_vector
GDAL)
build_program_in_subdir(d.where DEPENDS grass_gis grass_display grass_gproj GDAL)
grass_vector)
build_program_in_subdir(d.where DEPENDS grass_gis grass_display grass_gproj)
15 changes: 6 additions & 9 deletions general/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ build_program_in_subdir(g.pnmcomp DEPENDS grass_gis)
if(WITH_LIBPNG)
build_program_in_subdir(g.ppmtopng DEPENDS grass_gis LIBPNG)
endif()
build_program_in_subdir(g.proj DEPENDS grass_gis grass_gproj GDAL PROJ)
# LIBES = $(GPROJLIB) $(VECTORLIB) $(DIG2LIB) $(RASTER3DLIB) $(RASTERLIB)
# $(GISLIB) $(MATHLIB) $(PROJLIB)
build_program_in_subdir(g.proj DEPENDS grass_gis grass_gproj PROJ OPTIONAL_DEPENDS GDAL::GDAL)

build_program_in_subdir(
g.region
DEPENDS
Expand All @@ -36,7 +35,6 @@ build_program_in_subdir(
grass_gmath
grass_parson
PROJ
GDAL
${LIBM})

build_program_in_subdir(g.rename DEPENDS grass_gis grass_manage grass_raster)
Expand All @@ -46,11 +44,11 @@ build_program_in_subdir(
g.version
DEPENDS
grass_gis
PROJ
GDAL
SQLITE
OPTIONAL_DEPENDS
GDAL::GDAL
GEOS::geos_c
PROJ
SQLITE
DEFS
"-DGRASS_VERSION_NUMBER=\"${GRASS_VERSION_NUMBER}\""
"-DGRASS_VERSION_GIT=\"${GRASS_VERSION_GIT}\""
Expand All @@ -74,8 +72,7 @@ build_program_in_subdir(
grass_manage
grass_raster
grass_raster3d
grass_vector
GDAL)
grass_vector)
add_dependencies(g.list cell vector)

build_program_in_subdir(g.remove DEPENDS grass_gis grass_manage grass_raster)
Expand Down
1 change: 0 additions & 1 deletion general/manage/lister/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ build_program(
grass_dbmibase
grass_gis
grass_raster
GDAL
RUNTIME_OUTPUT_DIR
"${GRASS_INSTALL_ETCDIR}/lister"
NO_DOCS)
12 changes: 6 additions & 6 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ build_library_in_subdir(
DEFS
"-DGDAL_LINK=1"
DEPENDS
GDAL
GDAL::GDAL
PROJ
grass_gis
grass_gproj
Expand Down Expand Up @@ -137,7 +137,7 @@ add_subdirectory(fonts)

add_subdirectory(vector)

build_library_in_subdir(imagery DEPENDS grass_gis grass_vector grass_raster GDAL)
build_library_in_subdir(imagery DEPENDS grass_gis grass_vector grass_raster GDAL::GDAL)

build_library_in_subdir(cluster DEPENDS grass_imagery grass_gis grass_raster)

Expand All @@ -159,7 +159,7 @@ build_library_in_subdir(
grass_dbmidriver
grass_gmath
grass_segment
GDAL
GDAL::GDAL
HEADERS
"lidar.h")

Expand All @@ -174,7 +174,7 @@ build_program_in_subdir(
grass_gis
grass_raster3d
grass_raster
GDAL)
GDAL::GDAL)

build_library_in_subdir(
gpde
Expand Down Expand Up @@ -222,7 +222,7 @@ if(WITH_OPENGL)
grass_raster
grass_raster3d
grass_vector
GDAL
GDAL::GDAL
OPENGL
TIFF)

Expand All @@ -244,7 +244,7 @@ add_subdirectory(temporal)
build_library_in_subdir(iostream SRC_REGEX "*.cpp" DEPENDS grass_gis)

build_library_in_subdir(manage DEPENDS grass_gis grass_raster grass_vector
grass_raster3d GDAL)
grass_raster3d GDAL::GDAL)
file(COPY manage/element_list DESTINATION ${OUTDIR}/${GRASS_INSTALL_ETCDIR})
install(FILES ${OUTDIR}/${GRASS_INSTALL_ETCDIR}/element_list
DESTINATION ${GRASS_INSTALL_ETCDIR})
Expand Down
4 changes: 3 additions & 1 deletion lib/proj/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ build_module(
DEPENDS
grass_driver
grass_gis
GDAL
GDAL::GDAL
ZLIB
PROJ
SOURCES
"${grass_gproj_SOURCES}"
INCLUDES
"../driver")

target_include_directories(grass_gproj PUBLIC ${GDAL_INCLUDE_DIR})
5 changes: 2 additions & 3 deletions lib/rst/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# add_subdirectory(data) add_subdirectory(qtree) add_subdirectory(interp_float)

build_library_in_subdir(
data
NAME
Expand Down Expand Up @@ -33,9 +31,10 @@ build_library_in_subdir(
grass_vector
grass_qtree
grass_interpdata
GDAL
${LIBM}
OPTIONAL_DEPENDS
OPENMP
HEADERS
"interpf.h")

target_include_directories(grass_interpfl PUBLIC ${GDAL_INCLUDE_DIR})
8 changes: 5 additions & 3 deletions lib/vector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build_library_in_subdir(
NAME
grass_vector
DEPENDS
GDAL
GDAL::GDAL
grass_btree2
grass_dbmibase
grass_dbmiclient
Expand All @@ -23,6 +23,8 @@ build_library_in_subdir(
OPTIONAL_DEPENDS
GEOS::geos_c)

target_include_directories(grass_vector PUBLIC ${GDAL_INCLUDE_DIR})

if(TARGET POSTGRES)
# target_include_directories(grass_vector SYSTEM PUBLIC
# ${PostgreSQL_INCLUDE_DIR})
Expand All @@ -43,7 +45,7 @@ build_library_in_subdir(
grass_dbmibase
grass_dbmiclient
grass_dbmidriver
GDAL)
GDAL::GDAL)

build_library_in_subdir(
neta
Expand All @@ -56,7 +58,7 @@ build_library_in_subdir(
grass_gis
grass_dgl
grass_vector
GDAL)
GDAL::GDAL)

if(WITH_DOCS)
generate_html(TARGET grass_vector NAME vectorascii)
Expand Down
2 changes: 1 addition & 1 deletion lib/vector/diglib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ build_module(
grass_gmath
grass_gis
grass_rtree
GDAL
GDAL::GDAL
${LIBM})
1 change: 0 additions & 1 deletion ps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ build_program_in_subdir(
grass_dbmiclient
grass_dbmidriver
grass_symb
GDAL
${LIBM})

add_custom_command(
Expand Down
Loading
Loading