Skip to content

Commit 1b98739

Browse files
committed
jdbc/test: Fix use of std::filesystem with gcc8
1 parent 2acdd3d commit 1b98739

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

jdbc/test/CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/include")
4141
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/include/jdbc")
4242
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/include/jdbc/cppconn")
4343

44+
set(MY_TARGET_LINK_LIBRARIES connector-jdbc)
45+
46+
47+
if(DEFINED GCC AND GCC VERSION_LESS 9)
48+
49+
# Note: Some unit tests use std::filesystem part of the standard library
50+
# Before version 9 of gcc that requires linking with the additional library
51+
52+
list(APPEND MY_TARGET_LINK_LIBRARIES -lstdc++fs)
53+
# message(STATUS "Added libstdc++fs for GCC version ${GCC}: ${MY_TARGET_LINK_LIBRARIES}")
54+
55+
endif()
56+
57+
4458
IF(MSBUILD)
4559
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
4660
LINK_DIRECTORIES(${MYSQL_DIR}/lib/debug)
@@ -50,10 +64,6 @@ IF(MSBUILD)
5064

5165
ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS")
5266
ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS")
53-
54-
SET(MY_TARGET_LINK_LIBRARIES connector-jdbc)
55-
ELSEIF(NOT MSBUILD)
56-
SET(MY_TARGET_LINK_LIBRARIES connector-jdbc)
5767
ENDIF()
5868

5969
if(NOT MYSQLCLIENT_STATIC_LINKING)

jdbc/test/unit/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
# along with this program; if not, write to the Free Software Foundation, Inc.,
2727
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2828

29+
list(APPEND MY_TARGET_LINK_LIBRARIES test_framework)
30+
2931
IF(WIN32)
3032
if(MSBUILD)
3133
LINK_DIRECTORIES(${MYSQL_DIR}/lib/$(ConfigurationName))
3234
LINK_DIRECTORIES(../framework/$(ConfigurationName))
3335
endif()
34-
SET(MY_TARGET_LINK_LIBRARIES connector-jdbc test_framework)
3536
SET(MY_TARGET_LINK_LIBRARIES_STATIC_CPPLIB connector-jdbc-static test_framework)
3637
# ADD_DEFINITIONS("-D_SECURE_SCL")
3738
ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS")
@@ -64,7 +65,6 @@ IF(WIN32)
6465
)
6566

6667
ELSEIF(NOT WIN32)
67-
SET(MY_TARGET_LINK_LIBRARIES connector-jdbc test_framework)
6868
FIND_LIBRARY(MYSQLCPPCONN_DYNLOAD_MYSQL_LIB
6969
NAMES
7070
libmysqlclient_r.so
@@ -95,9 +95,6 @@ ELSEIF(NOT WIN32)
9595
)
9696
ENDIF(WIN32)
9797

98-
if(NOT MYSQLCLIENT_STATIC_LINKING)
99-
list(APPEND MY_TARGET_LINK_LIBRARIES MySQL::client)
100-
endif()
10198

10299
IF(CMAKE_COMPILER_IS_GNUCC AND MYSQLCPPCONN_GCOV_ENABLE)
103100
SET(MY_GCOV_LINK_LIBRARIES gcov)

0 commit comments

Comments
 (0)