Skip to content

Commit 206cfd2

Browse files
committed
Fix build in non-Windows platforms; address PR #281 review feedback
- Fix OdbcJdbcSetup sources: Windows uses full GUI setup (17 files), Linux uses only OdbcInstGetProp.cpp (matching makefile.sources) - Exclude ResourceManagerSink.cpp and TransactionResourceAsync.cpp from Linux build (ATL-only) - Add -D_REENTRANT -D_PTHREADS -DEXTERNAL -DunixODBC for Linux (matching old makefile.linux compile flags) - Fix ODBC linking on Linux: use ODBC::ODBC target instead of empty ODBC_LIBRARIES variable - Change IscDbc from STATIC to OBJECT library (avoids unnecessary intermediate archive; objects consumed directly by OdbcFb) - Add CMAKE_BUILD_TYPE defaulting to Release (single-config generators) - Add per-config compiler optimization flags for GCC/Clang (Debug: -O0 -g3, Release: -O3 -ftree-loop-vectorize, etc.) - Add CPU architecture detection (x86, x86_64, ARM64, generic) with -msse4.1 for x86/x86_64 (from PR #248) CI workflow updates: - linux.yml: use CMake instead of deleted Gcc.lin makefiles - msbuild.yml: add cmake -B build step to fetch Firebird headers (required by updated .vcxproj include paths) - rpi_arm64.yml: use CMake instead of deleted Gcc.lin makefiles - All workflows: trigger on new-build-system branches + PRs
1 parent 5a2d293 commit 206cfd2

5 files changed

Lines changed: 139 additions & 69 deletions

File tree

.github/workflows/linux.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Linux
22

33
on:
44
push:
5+
branches: [ "master", "new-build-system", "new-build-system-no-pr" ]
6+
pull_request:
57
branches: [ "master" ]
68

79
permissions:
@@ -18,16 +20,17 @@ jobs:
1820
- name: Install UnixODBC package
1921
run: sudo apt-get install -y unixodbc unixodbc-dev
2022

21-
- name: Go to build folder & make
22-
working-directory: ${{env.GITHUB_WORKSPACE}}
23-
run: |
24-
cd Builds/Gcc.lin
25-
cp makefile.linux makefile
26-
make
27-
23+
- name: Configure CMake
24+
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
25+
26+
- name: Build
27+
run: cmake --build build --config Release
28+
29+
- name: Run tests (no database — all tests skip)
30+
run: ctest --test-dir build --output-on-failure
31+
2832
- uses: actions/upload-artifact@v4
2933
with:
30-
name: linux_libs
34+
name: linux_x64_libs
3135
path: |
32-
./Builds/Gcc.lin/Release_*
33-
!./Builds/Gcc.lin/Release_*/obj
36+
./build/libOdbcFb.so

.github/workflows/msbuild.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ name: MSBuild
77

88
on:
99
push:
10+
branches: [ "master", "new-build-system", "new-build-system-no-pr" ]
11+
pull_request:
1012
branches: [ "master" ]
1113

1214
env:
@@ -43,6 +45,10 @@ jobs:
4345
working-directory: ${{env.GITHUB_WORKSPACE}}
4446
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
4547

48+
- name: Fetch Firebird headers (required by .vcxproj include paths)
49+
working-directory: ${{env.GITHUB_WORKSPACE}}
50+
run: cmake -B build -DBUILD_TESTING=OFF
51+
4652
- name: Stub
4753
working-directory: ${{env.GITHUB_WORKSPACE}}
4854
run: |

.github/workflows/rpi_arm64.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: RaspberryPI
22

33
on:
44
push:
5+
branches: [ "master", "new-build-system", "new-build-system-no-pr" ]
6+
pull_request:
57
branches: [ "master" ]
68

79
permissions:
@@ -19,17 +21,17 @@ jobs:
1921
base_image: raspios_lite_arm64:latest
2022
copy_repository_path: /opt/fb_odbc
2123
copy_artifact_path: |
22-
Builds/Gcc.lin/Release_*
24+
build/libOdbcFb.so
2325
commands: |
24-
sudo apt-get install -y unixodbc unixodbc-dev
25-
cd /opt/fb_odbc/Builds/Gcc.lin
26-
cp makefile.linux makefile
27-
make
26+
sudo apt-get update
27+
sudo apt-get install -y cmake unixodbc unixodbc-dev
28+
cd /opt/fb_odbc
29+
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
30+
cmake --build build --config Release
2831
2932
- uses: actions/upload-artifact@v4
3033
with:
3134
name: linux_arm64_libs
3235
path: |
33-
Release_*
34-
!Release_*/obj
36+
libOdbcFb.so
3537

CMakeLists.txt

Lines changed: 106 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ cmake_minimum_required(VERSION 3.15)
22

33
project(firebird-odbc-driver LANGUAGES CXX C)
44

5+
# ---------------------------------------------------------------------------
6+
# Default build type (single-config generators only, e.g. Unix Makefiles/Ninja)
7+
# ---------------------------------------------------------------------------
8+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
9+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
10+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel)
11+
endif()
12+
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
13+
514
# Extract version from git tags
615
include(cmake/GetVersionFromGit.cmake)
716

@@ -32,7 +41,28 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
3241
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
3342
option(BUILD_TESTING "Build tests" ON)
3443

35-
# Platform-specific settings
44+
# ---------------------------------------------------------------------------
45+
# CPU architecture detection (from PR #248)
46+
# ---------------------------------------------------------------------------
47+
set(FBODBC_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
48+
49+
if(FBODBC_ARCH STREQUAL "x86" OR FBODBC_ARCH STREQUAL "i686")
50+
add_definitions(-DFBODBC_ARCH_X86)
51+
message(STATUS "Architecture: ${FBODBC_ARCH} (x86)")
52+
elseif(FBODBC_ARCH STREQUAL "x86_64" OR FBODBC_ARCH STREQUAL "AMD64")
53+
add_definitions(-DFBODBC_ARCH_X86_64)
54+
message(STATUS "Architecture: ${FBODBC_ARCH} (x86_64)")
55+
elseif(FBODBC_ARCH STREQUAL "aarch64" OR FBODBC_ARCH STREQUAL "arm64" OR FBODBC_ARCH STREQUAL "ARM64")
56+
add_definitions(-DFBODBC_ARCH_ARM64)
57+
message(STATUS "Architecture: ${FBODBC_ARCH} (ARM64)")
58+
else()
59+
add_definitions(-DFBODBC_ARCH_GENERIC)
60+
message(WARNING "Architecture <${FBODBC_ARCH}> conditionally supported")
61+
endif()
62+
63+
# ---------------------------------------------------------------------------
64+
# Platform-specific compiler settings
65+
# ---------------------------------------------------------------------------
3666
if(WIN32)
3767
add_definitions(-DWIN32 -D_WINDOWS -D_USRDLL)
3868
if(MSVC)
@@ -44,20 +74,34 @@ if(WIN32)
4474
endif()
4575
else()
4676
# Linux/Unix
47-
add_definitions(-DUNIX)
77+
add_definitions(-DUNIX -D_REENTRANT -D_PTHREADS -DEXTERNAL)
4878
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
79+
80+
# Compiler optimization flags (from PR #248 / old makefile.linux)
81+
add_compile_options(
82+
"$<$<CONFIG:Debug>:-O0;-g3;-D_DEBUG;-DDEBUG;-DLOGGING;-fexceptions>"
83+
"$<$<CONFIG:Release>:-O3;-DNDEBUG;-ftree-loop-vectorize>"
84+
"$<$<CONFIG:RelWithDebInfo>:-O2;-g;-DNDEBUG>"
85+
"$<$<CONFIG:MinSizeRel>:-Os;-DNDEBUG>"
86+
)
87+
88+
# SSE4.1 for x86/x86_64 (from PR #248)
89+
if(FBODBC_ARCH STREQUAL "x86" OR FBODBC_ARCH STREQUAL "i686"
90+
OR FBODBC_ARCH STREQUAL "x86_64" OR FBODBC_ARCH STREQUAL "AMD64")
91+
add_compile_options(-msse4.1)
92+
endif()
4993
endif()
5094

95+
# ---------------------------------------------------------------------------
5196
# Find required packages
97+
# ---------------------------------------------------------------------------
5298
if(WIN32)
5399
# On Windows, ODBC is part of the system SDK
54100
set(ODBC_FOUND TRUE)
55101
else()
56102
# On Unix-like systems, find ODBC (unixODBC)
57103
find_package(ODBC REQUIRED)
58-
if(ODBC_FOUND)
59-
include_directories(${ODBC_INCLUDE_DIRS})
60-
endif()
104+
add_definitions(-DunixODBC)
61105
endif()
62106

63107
# Fetch Firebird public headers from GitHub (replaces vendored FBClient.Headers)
@@ -71,15 +115,21 @@ include_directories(
71115
${FIREBIRD_INCLUDE_DIR}
72116
)
73117

74-
# Add IscDbc static library
118+
# ---------------------------------------------------------------------------
119+
# IscDbc — Firebird database connectivity (object library)
120+
# ---------------------------------------------------------------------------
75121
add_subdirectory(IscDbc)
76122

123+
# ---------------------------------------------------------------------------
77124
# Windows resource file for version info
125+
# ---------------------------------------------------------------------------
78126
if(WIN32)
79127
set(ODBCJDBC_RC OdbcJdbc.rc)
80128
endif()
81129

130+
# ---------------------------------------------------------------------------
82131
# Main ODBC driver library sources (from makefile.sources ODBCJDBCSRC)
132+
# ---------------------------------------------------------------------------
83133
set(ODBCJDBC_SOURCES
84134
ConnectDialog.cpp
85135
DescRecord.cpp
@@ -94,42 +144,56 @@ set(ODBCJDBC_SOURCES
94144
OdbcError.cpp
95145
OdbcObject.cpp
96146
OdbcStatement.cpp
97-
ResourceManagerSink.cpp
98147
SafeEnvThread.cpp
99-
TransactionResourceAsync.cpp
100148
)
101149

102-
# OdbcJdbcSetup sources — built into the same DLL (from makefile.sources ODBCJDBCSETUPSRC)
103-
set(ODBCJDBCSETUP_SOURCES
104-
OdbcJdbcSetup/CommonUtil.cpp
105-
OdbcJdbcSetup/DsnDialog.cpp
106-
OdbcJdbcSetup/OdbcJdbcSetup.cpp
107-
OdbcJdbcSetup/ServiceClient.cpp
108-
OdbcJdbcSetup/ServiceTabBackup.cpp
109-
OdbcJdbcSetup/ServiceTabChild.cpp
110-
OdbcJdbcSetup/ServiceTabCtrl.cpp
111-
OdbcJdbcSetup/ServiceTabRepair.cpp
112-
OdbcJdbcSetup/ServiceTabRestore.cpp
113-
OdbcJdbcSetup/ServiceTabStatistics.cpp
114-
OdbcJdbcSetup/ServiceTabUsers.cpp
115-
OdbcJdbcSetup/Setup.cpp
116-
OdbcJdbcSetup/UserDialog.cpp
117-
OdbcJdbcSetup/UsersTabChild.cpp
118-
OdbcJdbcSetup/UsersTabMemberShips.cpp
119-
OdbcJdbcSetup/UsersTabRoles.cpp
120-
OdbcJdbcSetup/UsersTabUsers.cpp
121-
)
150+
# Windows-only sources (ATL-based DTC support, wrapped in #ifdef _WINDOWS)
151+
if(WIN32)
152+
list(APPEND ODBCJDBC_SOURCES
153+
ResourceManagerSink.cpp
154+
TransactionResourceAsync.cpp
155+
)
156+
endif()
122157

123-
# Linux-only setup source
124-
if(NOT WIN32)
125-
list(APPEND ODBCJDBCSETUP_SOURCES OdbcInstGetProp.cpp)
158+
# ---------------------------------------------------------------------------
159+
# OdbcJdbcSetup sources — platform-specific (from makefile.sources)
160+
# ---------------------------------------------------------------------------
161+
if(WIN32)
162+
# Windows: full GUI setup (ODBCJDBCSETUPSRC)
163+
set(ODBCJDBCSETUP_SOURCES
164+
OdbcJdbcSetup/CommonUtil.cpp
165+
OdbcJdbcSetup/DsnDialog.cpp
166+
OdbcJdbcSetup/OdbcJdbcSetup.cpp
167+
OdbcJdbcSetup/ServiceClient.cpp
168+
OdbcJdbcSetup/ServiceTabBackup.cpp
169+
OdbcJdbcSetup/ServiceTabChild.cpp
170+
OdbcJdbcSetup/ServiceTabCtrl.cpp
171+
OdbcJdbcSetup/ServiceTabRepair.cpp
172+
OdbcJdbcSetup/ServiceTabRestore.cpp
173+
OdbcJdbcSetup/ServiceTabStatistics.cpp
174+
OdbcJdbcSetup/ServiceTabUsers.cpp
175+
OdbcJdbcSetup/Setup.cpp
176+
OdbcJdbcSetup/UserDialog.cpp
177+
OdbcJdbcSetup/UsersTabChild.cpp
178+
OdbcJdbcSetup/UsersTabMemberShips.cpp
179+
OdbcJdbcSetup/UsersTabRoles.cpp
180+
OdbcJdbcSetup/UsersTabUsers.cpp
181+
)
182+
else()
183+
# Linux: only OdbcInstGetProp (ODBCJDBCSETUPSRC_LINUX)
184+
set(ODBCJDBCSETUP_SOURCES
185+
OdbcInstGetProp.cpp
186+
)
126187
endif()
127188

189+
# ---------------------------------------------------------------------------
128190
# Create the main ODBC driver library
191+
# ---------------------------------------------------------------------------
129192
add_library(OdbcFb
130193
${ODBCJDBC_SOURCES}
131194
${ODBCJDBCSETUP_SOURCES}
132195
${ODBCJDBC_RC}
196+
$<TARGET_OBJECTS:IscDbc>
133197
)
134198

135199
# Set library output name
@@ -139,11 +203,11 @@ else()
139203
set_target_properties(OdbcFb PROPERTIES OUTPUT_NAME "OdbcFb")
140204
endif()
141205

142-
# Link with IscDbc library
143-
target_link_libraries(OdbcFb PRIVATE IscDbc)
144-
145-
# Platform-specific linking (matching the .vcxproj AdditionalDependencies)
206+
# ---------------------------------------------------------------------------
207+
# Linking
208+
# ---------------------------------------------------------------------------
146209
if(WIN32)
210+
# Match the .vcxproj AdditionalDependencies
147211
target_link_libraries(OdbcFb PRIVATE
148212
odbccp32
149213
version
@@ -153,15 +217,13 @@ if(WIN32)
153217
legacy_stdio_wide_specifiers
154218
)
155219

156-
# Set the .def file for exports (matching the .vcxproj ModuleDefinitionFile)
157-
# Disable automatic manifest generation — the .rc file already embeds one.
158-
# Add explicit exports matching the .vcxproj /EXPORT: flags
220+
# .def file for exports + disable duplicate manifest + extra exports
159221
set_target_properties(OdbcFb PROPERTIES
160222
LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/OdbcJdbc.def /MANIFEST:NO /EXPORT:ConfigDSN /EXPORT:ConfigDriver,PRIVATE /EXPORT:DllRegisterServer,PRIVATE /EXPORT:DllUnregisterServer,PRIVATE /EXPORT:DllInstall,PRIVATE"
161223
)
162224
else()
163225
target_link_libraries(OdbcFb PRIVATE
164-
${ODBC_LIBRARIES}
226+
ODBC::ODBC
165227
odbcinst
166228
dl
167229
pthread
@@ -174,13 +236,17 @@ target_compile_definitions(OdbcFb PRIVATE
174236
$<$<CONFIG:Debug>:LOGGING>
175237
)
176238

239+
# ---------------------------------------------------------------------------
177240
# Testing
241+
# ---------------------------------------------------------------------------
178242
if(BUILD_TESTING)
179243
enable_testing()
180244
add_subdirectory(tests)
181245
endif()
182246

183-
# Installation rules
247+
# ---------------------------------------------------------------------------
248+
# Installation
249+
# ---------------------------------------------------------------------------
184250
install(TARGETS OdbcFb
185251
RUNTIME DESTINATION bin
186252
LIBRARY DESTINATION lib

IscDbc/CMakeLists.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# IscDbc — Firebird database connectivity library (static)
1+
# IscDbc — Firebird database connectivity library (object library)
2+
# Built as OBJECT to avoid an unnecessary intermediate static archive.
3+
# Object files are consumed directly by the main OdbcFb target.
24

35
set(ISCDBC_SOURCES
46
Attachment.cpp
@@ -54,21 +56,12 @@ set(ISCDBC_SOURCES
5456
Values.cpp
5557
)
5658

57-
# Create IscDbc static library
58-
add_library(IscDbc STATIC ${ISCDBC_SOURCES})
59+
# Create IscDbc object library
60+
add_library(IscDbc OBJECT ${ISCDBC_SOURCES})
5961

6062
# Include directories
6163
target_include_directories(IscDbc PUBLIC
6264
${CMAKE_CURRENT_SOURCE_DIR}
6365
${CMAKE_CURRENT_SOURCE_DIR}/..
6466
${FIREBIRD_INCLUDE_DIR}
6567
)
66-
67-
# Platform-specific settings
68-
if(WIN32)
69-
target_compile_definitions(IscDbc PRIVATE WIN32 _WINDOWS)
70-
target_link_libraries(IscDbc PRIVATE ws2_32 advapi32)
71-
else()
72-
target_compile_definitions(IscDbc PRIVATE UNIX)
73-
target_link_libraries(IscDbc PRIVATE dl pthread)
74-
endif()

0 commit comments

Comments
 (0)