Skip to content

Commit 749d254

Browse files
authored
cmake: use of imported ODBC target (#5312)
Run CI with ODBC.
1 parent 61fc4d1 commit 749d254

File tree

5 files changed

+9
-17
lines changed

5 files changed

+9
-17
lines changed

.github/workflows/cmake.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: Install dependencies
4545
run: |
4646
sudo apt-get update -y
47-
sudo apt-get install -y wget git gawk findutils ninja-build libpq-dev
47+
sudo apt-get install -y wget git gawk findutils ninja-build libpq-dev unixodbc-dev
4848
xargs -a <(awk '! /^ *(#|$)/' ".github/workflows/apt.txt") -r -- \
4949
sudo apt-get install -y --no-install-recommends --no-install-suggests
5050
- name: Print build environment variables
@@ -60,7 +60,7 @@ jobs:
6060
run: |
6161
cmake ${CMAKE_OPTIONS} -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -G Ninja \
6262
-DCMAKE_INSTALL_PREFIX=$HOME/install -DWITH_NLS=OFF -DWITH_GUI=OFF -DWITH_DOCS=OFF \
63-
-DWITH_READLINE=ON
63+
-DWITH_READLINE=ON -DWITH_ODBC=ON
6464
- name: Print CMakeCache.txt
6565
shell: bash -el {0}
6666
run: |

CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ option(WITH_LIBPNG "Build with libpng support ." ON)
101101
option(WITH_SQLITE "Build with SQLite support" ON)
102102
option(WITH_POSTGRES "Build with Postgres support" ON)
103103
option(WITH_MYSQL "Build with MySQL support" OFF)
104-
if(WIN32)
105-
option(WITH_ODBC "Build with ODBC support" OFF)
106-
endif()
104+
option(WITH_ODBC "Build with ODBC support" OFF)
107105
option(WITH_ZSTD "Build with zstd support" ON)
108106
option(WITH_BZLIB "Build with bzlib support" OFF)
109107

cmake/modules/CheckDependentLibraries.cmake

+3-10
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,8 @@ if(WITH_MYSQL)
127127
endif()
128128
endif()
129129

130-
if(WITH_ODBC AND WIN32)
131-
find_package(ODBC QUIET)
132-
if(ODBC_FOUND)
133-
add_library(ODBC INTERFACE IMPORTED GLOBAL)
134-
#[[
135-
set_property(TARGET ODBC PROPERTY INTERFACE_LINK_LIBRARIES ${ODBC_LIBRARIES})
136-
set_property(TARGET PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ODBC_INCLUDE_DIRS})
137-
#]]
138-
endif()
130+
if(WITH_ODBC)
131+
find_package(ODBC REQUIRED)
139132
endif()
140133

141134
if(WITH_ZSTD)
@@ -326,7 +319,7 @@ check_target(SQLite::SQLite3 HAVE_SQLITE3_H)
326319
check_target(PostgreSQL::PostgreSQL HAVE_POSTGRES)
327320
check_target(PostgreSQL::PostgreSQL HAVE_LIBPQ_FE_H)
328321
check_target(MYSQL HAVE_MYSQL_H)
329-
check_target(ODBC HAVE_SQL_H)
322+
check_target(ODBC::ODBC HAVE_SQL_H)
330323
check_target(ZSTD HAVE_ZSTD_H)
331324
check_target(BZIP2 HAVE_BZLIB_H)
332325
check_target(Readline::Readline HAVE_READLINE_READLINE_H)

db/drivers/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ build_program_in_subdir(
8080
DEPENDS
8181
grass_gis
8282
grass_dbstubs
83+
grass_dbmibase
8384
grass_dbmidriver
8485
grass_sqlp
8586
DEFS
8687
"${grass_dbstubs_DEFS}"
8788
PRIMARY_DEPENDS
88-
ODBC
89+
ODBC::ODBC
8990
HTML_FILE_NAME
9091
grass-odbc
9192
RUNTIME_OUTPUT_DIR

include/config.h.cmake.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
#cmakedefine HAVE_NICE ${HAVE_NICE}
139139

140140
/* Define to 1 if OGR is to be used. */
141-
#cmakedefine HAVE_OGR {HAVE_OGR}
141+
#cmakedefine HAVE_OGR ${HAVE_OGR}
142142

143143
/* Define to 1 if you have the <omp.h> header file. */
144144
#cmakedefine HAVE_OMP_H ${HAVE_OMP_H}

0 commit comments

Comments
 (0)