Skip to content

Commit c066977

Browse files
committedAug 11, 2024·
Experimeting...
1 parent baeb275 commit c066977

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed
 

‎CMakeLists.txt

+34-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ option(MYSQLPOOL_WITH_TESTS "Enable Tests" OFF)
1919
option(MYSQLPOOL_WITH_INTGRATION_TESTS "Enable Integretion Tests" OFF)
2020
option(MYSQLPOOL_WITH_EXAMPLES "Compile examples" OFF)
2121
option(MYSQLPOOL_EMBEDDED "Do not try to install dependencies" OFF)
22-
option(MYSQLPOOL_BOOST_ALL "Find_Boost support COMPONENT" ON)
22+
option(MYSQLPOOL_BOOST_ALL "Find_Boost support COMPONENT ALL" ON)
2323

2424
set(MYSQLPOOL_LOGGER "clog" CACHE STRING "Log system to use. One of 'clog', 'internal', 'logfault', 'boost' or 'none'")
2525
set(MYSQLPOOL_LOG_LEVEL_STR "info" CACHE STRING "Minimum log level to enable. One of 'none', error', 'warn', 'info', 'debug', 'trace'")
@@ -74,7 +74,8 @@ if (MYSQLPOOL_LOG_WITH_INTERNAL_LOG)
7474
endif()
7575

7676
if (MYSQLPOOL_LOG_WITH_BOOST_LOG)
77-
set(BOOST_LOG_DEP Boost::log_setup Boost::log)
77+
set(BOOST_LOG_DEP Boost::log)
78+
set(BOOST_LOG_LIB log log_setup)
7879
message(STATUS "Using Boost.Log for logging (brace for horrors!)")
7980
endif()
8081

@@ -119,24 +120,46 @@ if(NOT DEFINED USE_BOOST_VERSION)
119120
set(USE_BOOST_VERSION 1.83)
120121
endif()
121122

122-
if (MYSQLPOOL_BOOST_ALL)
123-
set(BOOST_ALL ALL)
124-
endif()
125-
126-
find_package(Boost ${USE_BOOST_VERSION} REQUIRED ${BOOST_ALL})
127-
128-
message("Boost_LIBRARIES: ${Boost_LIBRARIES}")
129123

130124
set(MYSQLPOOL_BOOST_LIBRARIES
131125
${BOOST_LOG_DEP}
132126
Boost::system
133-
Boost::date_time
134-
Boost::coroutine
135127
Boost::context
136128
Boost::chrono
137129
Boost::json
138130
)
139131

132+
set(MYSQLPOOL_BOOST_PROGRAM_OPTIONS Boost::program_options)
133+
134+
if (MYSQLPOOL_BOOST_ALL)
135+
find_package(Boost ${USE_BOOST_VERSION} REQUIRED ALL)
136+
else()
137+
find_package(Boost ${USE_BOOST_VERSION} REQUIRED COMPONENTS
138+
system
139+
context
140+
chrono
141+
json
142+
program_options
143+
${BOOST_LOG_LIB}
144+
)
145+
146+
if (Boost_VERSION VERSION_GREATER_EQUAL "1.85.0")
147+
find_package(Boost ${USE_BOOST_VERSION} REQUIRED COMPONENTS
148+
system
149+
context
150+
chrono
151+
json
152+
charconv
153+
program_options
154+
${BOOST_LOG_LIB}
155+
)
156+
set(MYSQLPOOL_BOOST_PROGRAM_OPTIONS ${MYSQLPOOL_BOOST_PROGRAM_OPTIONS} Boost::charconv)
157+
endif()
158+
endif()
159+
160+
message("Boost_LIBRARIES: ${Boost_LIBRARIES}")
161+
message(MYSQLPOOL_BOOST_LIBRARIES: ${MYSQLPOOL_BOOST_LIBRARIES})
162+
140163
if (Boost_VERSION VERSION_GREATER "1.84.0")
141164
set(MYSQLPOOL_BOOST_LIBRARIES ${MYSQLPOOL_BOOST_LIBRARIES} Boost::charconv)
142165
endif()

‎examples/simple/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
project(simple_sql_app
34
DESCRIPTION "Simple example on how to use mysqlpool-cpp"
45
LANGUAGES CXX
@@ -8,7 +9,7 @@ message("examples: LOGFAULT_INCLUDEDIR=${LOGFAULT_INCLUDEDIR}")
89

910
add_executable(${PROJECT_NAME} main.cpp fun_with_sql.cpp)
1011
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
11-
target_link_libraries(${PROJECT_NAME} mysqlpool Boost::program_options)
12+
target_link_libraries(${PROJECT_NAME} mysqlpool ${MYSQLPOOL_BOOST_PROGRAM_OPTIONS})
1213

1314
target_include_directories(${PROJECT_NAME} PRIVATE
1415
${CMAKE_INCLUDE_PATH}
@@ -19,7 +20,6 @@ target_include_directories(${PROJECT_NAME} PRIVATE
1920
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
2021
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
2122
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
22-
$Boost_INCLUDE_DIR
2323
${LOGFAULT_INCLUDEDIR}
2424
)
2525

0 commit comments

Comments
 (0)
Please sign in to comment.