10
10
# This program is also distributed with certain software (including
11
11
# but not limited to OpenSSL) that is licensed under separate terms,
12
12
# as designated in a particular file or component or in included license
13
- # documentation. The authors of MySQL hereby grant you an
13
+ # documentation. The authors of MySQL hereby grant you an
14
14
# additional permission to link the program and your derivative works
15
15
# with the separately licensed software that they have included with
16
16
# MySQL.
17
17
#
18
18
# Without limiting anything contained in the foregoing, this file,
19
- # which is part of MySQL Connector/C++ , is also subject to the
19
+ # which is part of MySQL Connector/ODBC , is also subject to the
20
20
# Universal FOSS Exception, version 1.0, a copy of which can be found at
21
21
# http://oss.oracle.com/licenses/universal-foss-exception.
22
22
#
27
27
#
28
28
# You should have received a copy of the GNU General Public License
29
29
# along with this program; if not, write to the Free Software Foundation, Inc.,
30
- # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
+ # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
31
32
32
##########################################################################
33
33
@@ -118,7 +118,7 @@ set(ENV_OR_OPT_VARS
118
118
MYSQL_DIR
119
119
MYSQL_INCLUDE_DIR
120
120
MYSQL_LIB_DIR
121
- MYSQL_LIB_DIR_RUNTIME
121
+ MYSQL_LIB_DIR_LIST
122
122
MYSQL_CFLAGS
123
123
MYSQL_CXXFLAGS
124
124
MYSQL_CONFIG_EXECUTABLE
@@ -129,12 +129,6 @@ set(ENV_OR_OPT_VARS
129
129
MYSQL_LINK_FLAGS
130
130
)
131
131
132
- IF (NOT WIN32 )
133
- set (MYSQL_COMPILER_ID
134
- MYSQL_COMPILER_VERSION
135
- )
136
- ENDIF (NOT WIN32 )
137
-
138
132
# Mark the variable names that have values that are paths
139
133
set (ENV_OR_OPT_PATH_VARS
140
134
MYSQL_DIR
@@ -356,10 +350,10 @@ macro(_mysql_config _var _regex _opt)
356
350
_mysql_conf (_mysql_config_output ${_opt} )
357
351
string (REGEX MATCHALL "${_regex} ([^ ]+)" _mysql_config_output "${_mysql_config_output} " )
358
352
string (REGEX REPLACE "^[ \t ]+" "" _mysql_config_output "${_mysql_config_output} " )
359
- string (REGEX REPLACE "${_regex} " "" _mysql_config_output "${_mysql_config_output} " )
360
353
IF (CMAKE_SYSTEM_NAME MATCHES "SunOS" )
361
354
string (REGEX REPLACE " -latomic" "" _mysql_config_output "${_mysql_config_output} " )
362
355
ENDIF ()
356
+ string (REGEX REPLACE "${_regex} " "" _mysql_config_output "${_mysql_config_output} " )
363
357
separate_arguments (_mysql_config_output )
364
358
set (${_var} ${_mysql_config_output} )
365
359
endmacro ()
@@ -384,11 +378,11 @@ macro(_mysql_config_replace _var _regex1 _replace _regex2 _opt)
384
378
_mysql_conf (_mysql_config_output ${_opt} )
385
379
string (REGEX MATCHALL "${_regex2} ([^ ]+)" _mysql_config_output "${_mysql_config_output} " )
386
380
string (REGEX REPLACE "^[ \t ]+" "" _mysql_config_output "${_mysql_config_output} " )
387
- string (REGEX REPLACE "${_regex2} " "" _mysql_config_output "${_mysql_config_output} " )
388
- string (REGEX REPLACE "${_regex1} " "${_replace} " _mysql_config_output "${_mysql_config_output} " )
389
381
IF (CMAKE_SYSTEM_NAME MATCHES "SunOS" )
390
382
string (REGEX REPLACE " -latomic" "" _mysql_config_output "${_mysql_config_output} " )
391
383
ENDIF ()
384
+ string (REGEX REPLACE "${_regex2} " "" _mysql_config_output "${_mysql_config_output} " )
385
+ string (REGEX REPLACE "${_regex1} " "${_replace} " _mysql_config_output "${_mysql_config_output} " )
392
386
separate_arguments (_mysql_config_output )
393
387
set (${_var} ${_mysql_config_output} )
394
388
endmacro ()
@@ -514,20 +508,9 @@ elseif(MYSQL_CONFIG_EXECUTABLE)
514
508
"\" ${MYSQL_CONFIG_EXECUTABLE} \" " )
515
509
endif ()
516
510
517
- set (_found_mysql_h )
518
- foreach (_incdir ${MYSQL_INCLUDE_DIR} )
519
- if (NOT EXISTS "${_incdir} " )
520
- message (FATAL_ERROR "Could not find the directory \" ${_incdir} \" "
521
- "from running \" ${MYSQL_CONFIG_EXECUTABLE} \" " )
522
- endif ()
523
- if (EXISTS "${_incdir} /mysql.h" )
524
- set (_found_mysql_h 1 )
525
- endif ()
526
- endforeach ()
527
-
528
- if (NOT _found_mysql_h )
511
+ if (NOT EXISTS "${MYSQL_INCLUDE_DIR} /mysql.h" )
529
512
message (FATAL_ERROR "Could not find \" mysql.h\" in \" ${MYSQL_INCLUDE_DIR} \" "
530
- "from running \" ${MYSQL_CONFIG_EXECUTABLE} \" " )
513
+ "found from running \" ${MYSQL_CONFIG_EXECUTABLE} \" " )
531
514
endif ()
532
515
533
516
else ()
@@ -608,23 +591,31 @@ elseif(MYSQL_CONFIG_EXECUTABLE)
608
591
# This code assumes there is just one "-L...." and that
609
592
# no space between "-L" and the path
610
593
_mysql_config (MYSQL_LIB_DIR "(^| )-L" "--libs" )
611
- if (NOT MYSQL_LIB_DIR )
612
- message (FATAL_ERROR "Could not find the library dir from running "
613
- "\" ${MYSQL_CONFIG_EXECUTABLE} \" " )
614
- endif ()
615
594
616
- # In case mysql_config returns two paths: (0) runtime and (1) libmysqlclient
595
+ IF (CMAKE_SYSTEM_NAME MATCHES "SunOS" )
596
+ # This is needed to make Solaris binaries using the default runtime lib path
597
+ _mysql_config (DEV_STUDIO_RUNTIME_DIR "(^| )-R" "--libs" )
598
+ ENDIF ()
599
+
600
+
601
+ # In case mysql_config returns several paths: libmysqlclient is last
617
602
LIST (LENGTH MYSQL_LIB_DIR n )
618
603
IF ( ${n} GREATER 1 )
619
- LIST (GET MYSQL_LIB_DIR 0 MYSQL_LIB_DIR_RUNTIME )
604
+ #copy list of directories
605
+ SET (MYSQL_LIB_DIR_LIST ${MYSQL_LIB_DIR} )
606
+
607
+ MATH (EXPR ind "${n} -1" )
608
+ LIST (GET MYSQL_LIB_DIR ${ind} MYSQL_LIB_DIR )
620
609
ENDIF ()
610
+ if (NOT MYSQL_LIB_DIR )
611
+ message (FATAL_ERROR "Could not find the library dir from running "
612
+ "\" ${MYSQL_CONFIG_EXECUTABLE} \" " )
613
+ endif ()
621
614
622
- foreach (_libdir ${MYSQL_LIB_DIR} )
623
- if (NOT EXISTS "${_libdir} " )
624
- message (FATAL_ERROR "Could not find the directory \" ${_libdir} \" "
625
- "from running \" ${MYSQL_CONFIG_EXECUTABLE} \" " )
626
- endif ()
627
- endforeach ()
615
+ if (NOT EXISTS "${MYSQL_LIB_DIR} " )
616
+ message (FATAL_ERROR "Could not find the directory \" ${MYSQL_LIB_DIR} \" "
617
+ "found from running \" ${MYSQL_CONFIG_EXECUTABLE} \" " )
618
+ endif ()
628
619
629
620
# We have the assumed MYSQL_LIB_DIR. The output from "mysql_config"
630
621
# might not be correct for static libraries, so we might need to
@@ -655,9 +646,14 @@ elseif(MYSQL_CONFIG_EXECUTABLE)
655
646
else ()
656
647
657
648
_mysql_config (MYSQL_LIBRARIES "(^| )-l" "--libs" )
658
-
649
+ FOREACH (__lib IN LISTS MYSQL_LIBRARIES )
650
+ string (REGEX MATCH "mysqlclient([^ ]*)" _matched_lib __lib )
651
+ IF (_matched_lib )
652
+ set (_search_libs ${matched_lib} )
653
+ ENDIF ()
654
+ ENDFOREACH ()
659
655
# First library is assumed to be the client library
660
- list (GET MYSQL_LIBRARIES 0 _search_libs )
656
+ # list(GET MYSQL_LIBRARIES 0 _search_libs)
661
657
find_library (MYSQL_LIB
662
658
NAMES
663
659
${_search_libs}
@@ -705,6 +701,19 @@ if(MYSQLCLIENT_STATIC_LINKING AND
705
701
list (APPEND MYSQL_LIBRARIES "rt" )
706
702
endif ()
707
703
704
+ # For dynamic linking use the built-in sys and strings
705
+ if (NOT MYSQLCLIENT_STATIC_LINKING )
706
+ list (APPEND SYS_LIBRARIES "mysql_sys" )
707
+ list (APPEND SYS_LIBRARIES "mysql_strings" )
708
+ list (APPEND SYS_LIBRARIES ${MYSQL_LIBRARIES} )
709
+ SET (MYSQL_LIBRARIES ${SYS_LIBRARIES} )
710
+
711
+ #if(NOT MYSQLCLIENT_STATIC_LINKING AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
712
+ # list(REVERSE MYSQL_LIBRARIES)
713
+ #endif()
714
+
715
+ endif ()
716
+
708
717
if (MYSQL_EXTRA_LIBRARIES )
709
718
separate_arguments (MYSQL_EXTRA_LIBRARIES )
710
719
list (APPEND MYSQL_LIBRARIES ${MYSQL_EXTRA_LIBRARIES} )
@@ -818,24 +827,16 @@ endif()
818
827
# set(CMAKE_CXX_FLAGS_${CMAKEBT} "${CMAKE_CXX_FLAGS_${CMAKEBT}} ${MYSQL_CXXFLAGS}")
819
828
820
829
include_directories ("${MYSQL_INCLUDE_DIR} " )
821
- link_directories ("${MYSQL_LIB_DIR} " " ${MYSQL_LIB_DIR_RUNTIME} " )
830
+ link_directories ("${MYSQL_LIB_DIR} " )
822
831
823
- IF (CMAKE_SYSTEM_NAME STREQUAL "SunOS" )
824
- SET (RPATH " ${RPATH} ${MYSQL_LIB_DIR_RUNTIME} " )
832
+ MESSAGE (STATUS "MYSQL_LIB_DIR_LIST = ${MYSQL_LIB_DIR_LIST} " )
833
+ IF (MYSQL_LIB_DIR_LIST )
834
+ FOREACH (__libpath IN LISTS MYSQL_LIB_DIR_LIST )
835
+ link_directories ("${__libpath} " )
836
+ ENDFOREACH ()
825
837
ENDIF ()
826
838
827
- ##########################################################################
828
- #
829
- # Get libmysqlclient compiler ID and VERSION
830
- #
831
- ##########################################################################
832
- IF (NOT WIN32 )
833
- _mysql_conf (MYSQL_COMPILER_VERSION "" )
834
- STRING (REGEX MATCH "Compiler:[a-zA-Z0-9\\ . ]+" MYSQL_COMPILER_VERSION ${MYSQL_COMPILER_VERSION} )
835
- STRING (REGEX REPLACE "Compiler: " "" MYSQL_COMPILER_VERSION ${MYSQL_COMPILER_VERSION} )
836
- STRING (REGEX MATCH "[a-zA-Z0-9]+" MYSQL_COMPILER_ID ${MYSQL_COMPILER_VERSION} )
837
- STRING (REGEX REPLACE "[a-zA-Z0-9]+ " "" MYSQL_COMPILER_VERSION ${MYSQL_COMPILER_VERSION} )
838
- ENDIF (NOT WIN32 )
839
+
839
840
840
841
##########################################################################
841
842
#
@@ -848,7 +849,6 @@ message(STATUS "MySQL client environment/cmake variables set that the user can o
848
849
message (STATUS " MYSQL_DIR : ${MYSQL_DIR} " )
849
850
message (STATUS " MYSQL_INCLUDE_DIR : ${MYSQL_INCLUDE_DIR} " )
850
851
message (STATUS " MYSQL_LIB_DIR : ${MYSQL_LIB_DIR} " )
851
- message (STATUS " MYSQL_LIB_DIR_RUNTIME : ${MYSQL_LIB_DIR_RUNTIME} " )
852
852
message (STATUS " MYSQL_CONFIG_EXECUTABLE : ${MYSQL_CONFIG_EXECUTABLE} " )
853
853
message (STATUS " MYSQL_CXX_LINKAGE : ${MYSQL_CXX_LINKAGE} " )
854
854
message (STATUS " MYSQL_CFLAGS : ${MYSQL_CFLAGS} " )
@@ -867,8 +867,3 @@ message(STATUS " MYSQL_VERSION : ${MYSQL_VERSION}")
867
867
message (STATUS " MYSQL_VERSION_ID : ${MYSQL_VERSION_ID} " )
868
868
message (STATUS " MYSQL_LIB : ${MYSQL_LIB} " )
869
869
message (STATUS " MYSQL_LIBRARIES : ${MYSQL_LIBRARIES} " )
870
-
871
- IF (NOT WIN32 )
872
- message (STATUS " MYSQL_COMPILER_ID : ${MYSQL_COMPILER_ID} " )
873
- message (STATUS " MYSQL_COMPILER_VERSION : ${MYSQL_COMPILER_VERSION} " )
874
- ENDIF (NOT WIN32 )
0 commit comments