Skip to content

Commit 28d2f7a

Browse files
committed
Adjust boost dependencies
1 parent 302b79a commit 28d2f7a

4 files changed

Lines changed: 80 additions & 11 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ if(BUILD_TESTING)
5757
endif()
5858

5959

60+
set(FB_CPP_USE_BOOST_DLL_VALUE 0)
61+
if(FB_CPP_USE_BOOST_DLL)
62+
set(FB_CPP_USE_BOOST_DLL_VALUE 1)
63+
endif()
64+
65+
set(FB_CPP_USE_BOOST_MULTIPRECISION_VALUE 0)
66+
if(FB_CPP_USE_BOOST_MULTIPRECISION)
67+
set(FB_CPP_USE_BOOST_MULTIPRECISION_VALUE 1)
68+
endif()
69+
70+
6071
include(CMakePackageConfigHelpers)
6172
write_basic_package_version_file(
6273
"${CMAKE_CURRENT_BINARY_DIR}/fb-cppConfigVersion.cmake"

cmake/fb-cppConfig.cmake.in

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@
22

33
include(CMakeFindDependencyMacro)
44

5-
find_dependency(Boost
6-
COMPONENTS
7-
dll
8-
multiprecision
9-
)
5+
find_dependency(firebird CONFIG)
6+
7+
set(_fb_cpp_use_boost_dll "@FB_CPP_USE_BOOST_DLL_VALUE@")
8+
set(_fb_cpp_use_boost_multiprecision "@FB_CPP_USE_BOOST_MULTIPRECISION_VALUE@")
9+
10+
if(_fb_cpp_use_boost_dll)
11+
find_dependency(Boost COMPONENTS dll)
12+
endif()
13+
14+
if(_fb_cpp_use_boost_multiprecision)
15+
find_dependency(Boost COMPONENTS multiprecision)
16+
endif()
1017

1118
include("${CMAKE_CURRENT_LIST_DIR}/fb-cppTargets.cmake")
1219

20+
unset(_fb_cpp_use_boost_dll)
21+
unset(_fb_cpp_use_boost_multiprecision)
22+
1323
check_required_components(fb-cpp)

src/fb-cpp/CMakeLists.txt

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,29 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
22

33
project(fb-cpp CXX)
44

5+
option(FB_CPP_USE_BOOST_DLL "Enable Boost.DLL support for loading fbclient at runtime" ON)
6+
option(FB_CPP_USE_BOOST_MULTIPRECISION "Enable Boost.Multiprecision helpers for INT128 and DECFLOAT types" ON)
7+
58
file(GLOB_RECURSE SRC
69
"*.h"
710
"*.cpp"
811
)
912

10-
find_package(Boost REQUIRED
11-
COMPONENTS
12-
multiprecision
13-
)
13+
set(_fb_cpp_boost_components "")
14+
if(FB_CPP_USE_BOOST_DLL)
15+
list(APPEND _fb_cpp_boost_components dll)
16+
endif()
17+
if(FB_CPP_USE_BOOST_MULTIPRECISION)
18+
list(APPEND _fb_cpp_boost_components multiprecision)
19+
endif()
20+
21+
if(_fb_cpp_boost_components)
22+
find_package(Boost REQUIRED
23+
COMPONENTS ${_fb_cpp_boost_components}
24+
)
25+
endif()
26+
27+
find_package(firebird CONFIG REQUIRED)
1428

1529

1630
add_library(${PROJECT_NAME}
@@ -24,11 +38,43 @@ target_include_directories(${PROJECT_NAME}
2438
$<INSTALL_INTERFACE:include>
2539
)
2640

41+
if(NOT DEFINED FB_CPP_USE_BOOST_DLL_VALUE)
42+
if(FB_CPP_USE_BOOST_DLL)
43+
set(FB_CPP_USE_BOOST_DLL_VALUE 1)
44+
else()
45+
set(FB_CPP_USE_BOOST_DLL_VALUE 0)
46+
endif()
47+
endif()
48+
49+
if(NOT DEFINED FB_CPP_USE_BOOST_MULTIPRECISION_VALUE)
50+
if(FB_CPP_USE_BOOST_MULTIPRECISION)
51+
set(FB_CPP_USE_BOOST_MULTIPRECISION_VALUE 1)
52+
else()
53+
set(FB_CPP_USE_BOOST_MULTIPRECISION_VALUE 0)
54+
endif()
55+
endif()
56+
57+
target_compile_definitions(${PROJECT_NAME}
58+
PUBLIC
59+
FB_CPP_USE_BOOST_DLL=${FB_CPP_USE_BOOST_DLL_VALUE}
60+
FB_CPP_USE_BOOST_MULTIPRECISION=${FB_CPP_USE_BOOST_MULTIPRECISION_VALUE}
61+
)
62+
2763
target_link_libraries(${PROJECT_NAME}
28-
PRIVATE Boost::multiprecision
29-
${CMAKE_DL_LIBS}
64+
PUBLIC
65+
firebird
66+
PRIVATE
67+
${CMAKE_DL_LIBS}
3068
)
3169

70+
if(FB_CPP_USE_BOOST_MULTIPRECISION)
71+
target_link_libraries(${PROJECT_NAME}
72+
PRIVATE Boost::multiprecision
73+
)
74+
endif()
75+
76+
unset(_fb_cpp_boost_components)
77+
3278
file(GLOB_RECURSE HEADER_FILES
3379
"${CMAKE_CURRENT_LIST_DIR}/*.h"
3480
"${CMAKE_CURRENT_LIST_DIR}/*.hpp"

src/fb-cpp/Statement.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,9 +2207,11 @@ namespace fbcpp
22072207
return std::nullopt;
22082208

22092209
auto data = &message[descriptor.offset];
2210+
#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
22102211
std::optional<BoostInt128> boostInt128;
22112212
std::optional<BoostDecFloat16> boostDecFloat16;
22122213
std::optional<BoostDecFloat34> boostDecFloat34;
2214+
#endif
22132215

22142216
switch (descriptor.adjustedType)
22152217
{

0 commit comments

Comments
 (0)