Permalink
Browse files

Changed FindMySQL.cmake to make version check

reviewed by: lolek
Linux:cmake: Fix copytables link library name

review by Marcin
  • Loading branch information...
1 parent 8a45331 commit f32b9eeeb63c1e01a06d90b61a8bc3d4fca27e4a Miguel Tadeu committed Dec 2, 2015
View
@@ -101,7 +101,7 @@ find_python_module(paramiko 1.15.1 QUIET)
if(NOT PY_PARAMIKO)
message(WARNING "Paramiko wasn't found, you can still build Workbench, but may not work properly.")
endif()
-find_package(MySQL REQUIRED)
+find_package(MySQL 5.6.0 REQUIRED)
if (UNIX)
set(MYSQL_DEFINITIONS "-DBIG_JOINS=1" "-fno-strict-aliasing")
endif()
@@ -4,7 +4,7 @@ include_directories(.
${SIGC++_INCLUDE_DIRS}
${GRT_INCLUDE_DIRS}
${PCRE_INCLUDE_DIRS}
- ${MYSQL_INCLUDE_DIRS}
+ ${MySQL_INCLUDE_DIRS}
${SQLITE3_INCLUDE_DIRS}
${CTemplate_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS}
@@ -17,55 +17,81 @@
# - Find mysql client library and includes
#
-# MYSQL_FOUND - True if mysql was found
-# MYSQL_INCLUDE_DIRS - the include dir where mysql.h lives
-# MYSQL_LIBRARIES - list of mysql libraries
+# MySQL_FOUND - True if mysql was found
+# MySQL_INCLUDE_DIRS - the include dir where mysql.h lives
+# MySQL_LIBRARIES - list of mysql libraries
-if (MYSQL_LIBRARIES AND MYSQL_INCLUDE_DIRS)
- # in cache already, be silent and skip the rest
- set(MYSQL_FOUND TRUE)
+include(FindPackageHandleStandardArgs)
+
+if (MySQL_LIBRARIES AND MySQL_INCLUDE_DIRS)
+ # in cache already, be silent and skip the rest
+ set(MySQL_FOUND TRUE)
else ()
- if (MYSQL_CONFIG_PATH)
- EXEC_PROGRAM(${MYSQL_CONFIG_PATH} ARGS --variable=pkgincludedir RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_INCLUDE_DIRS)
- if (NOT _return_VALUE)
- EXEC_PROGRAM(${MYSQL_CONFIG_PATH} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_LIBRARIES)
+ if (EXISTS ${MySQL_CONFIG_PATH})
+
+ execute_process(COMMAND ${MySQL_CONFIG_PATH} --version
+ RESULT_VARIABLE MySQL_ProcessResult
+ OUTPUT_VARIABLE MySQL_VERSION
+ ERROR_VARIABLE MySQL_ProcessError
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(COMMAND ${MySQL_CONFIG_PATH} --variable=pkgincludedir
+ RESULT_VARIABLE MySQL_ProcessResult
+ OUTPUT_VARIABLE MySQL_INCLUDE_DIRS
+ ERROR_VARIABLE MySQL_ProcessError
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(COMMAND ${MySQL_CONFIG_PATH} --libs
+ RESULT_VARIABLE MySQL_ProcessResult
+ OUTPUT_VARIABLE MySQL_LIBRARIES
+ ERROR_VARIABLE MySQL_ProcessError
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE)
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(MySQL DEFAULT_MSG
- MYSQL_INCLUDE_DIRS MYSQL_LIBRARIES
- )
- mark_as_advanced(MYSQL_INCLUDE_DIRS MYSQL_LIBRARIES)
+ find_package_handle_standard_args(MySQL
+ FOUND_VAR MySQL_FOUND
+ REQUIRED_VARS MySQL_INCLUDE_DIRS MySQL_LIBRARIES
+ VERSION_VAR MySQL_VERSION
+ )
+ message("MySQL_INCLUDE_DIRS: ${MySQL_INCLUDE_DIRS}")
+ message("MySQL_LIBRARIES: ${MySQL_LIBRARIES}")
+# mark_as_advanced(MySQL_INCLUDE_DIRS MySQL_LIBRARIES)
else ()
- MESSAGE(FATAL_ERROR "Cannot find ${MYSQL_CONFIG_PATH} (MYSQL_CONFIG_PATH)")
- endif ()
- else ()
- # Find the include dir:
- FIND_PATH(MYSQL_INCLUDE_DIRS mysql.h
- /usr/include/mysql
- /usr/local/include/mysql
- /opt/mysql/mysql/include
- /opt/mysql/mysql/include/mysql
- /usr/local/mysql/include
- /usr/local/mysql/include/mysql
- $ENV{ProgramFiles}/MySQL/*/include
- $ENV{SystemDrive}/MySQL/*/include
- )
+ # Find the include dir:
+ find_path(MySQL_INCLUDE_DIRS mysql.h
+ /usr/include/mysql
+ /usr/local/include/mysql
+ /opt/mysql/mysql/include
+ /opt/mysql/mysql/include/mysql
+ /usr/local/mysql/include
+ /usr/local/mysql/include/mysql
+ $ENV{ProgramFiles}/MySQL/*/include
+ $ENV{SystemDrive}/MySQL/*/include
+ )
+
+ find_file(MySQL_VERSION_FILE mysql_version.h ${MySQL_INCLUDE_DIRS})
+ file(STRINGS "${MySQL_VERSION_FILE}" MySQL_VERSION_LINE REGEX "MYSQL_SERVER_VERSION")
+ string(REGEX REPLACE "#define MYSQL_SERVER_VERSION[ \t]+\"([0-9.]+)\"" "\\1" MySQL_VERSION "${MySQL_VERSION_LINE}")
+
+ # Find the library:
+ set(MySQL_LIBRARY_NAMES mysqlclient mysqlclient_r)
+ find_library(MySQL_LIBRARIES
+ NAMES ${MySQL_LIBRARY_NAMES}
+ PATHS /usr/lib
+ /usr/local/lib
+ /usr/local/mysql/lib
+ /opt/mysql/mysql/lib
+ $ENV{ProgramFiles}/MySQL/*/lib
+ PATH_SUFFIXES mysql
+ )
- # Find the library:
- SET(MYSQL_LIBRARY_NAMES mysqlclient mysqlclient_r)
- FIND_LIBRARY(MYSQL_LIBRARIES
- NAMES ${MYSQL_LIBRARY_NAMES}
- PATHS /usr/lib
- /usr/local/lib
- /usr/local/mysql/lib
- /opt/mysql/mysql/lib
- $ENV{ProgramFiles}/MySQL/*/lib
- PATH_SUFFIXES mysql
- )
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(MySQL DEFAULT_MSG
- MYSQL_INCLUDE_DIRS MYSQL_LIBRARIES
- )
- mark_as_advanced(MYSQL_INCLUDE_DIRS MYSQL_LIBRARIES)
- endif ()
+ find_package_handle_standard_args(MySQL
+ FOUND_VAR MySQL_FOUND
+ REQUIRED_VARS MySQL_INCLUDE_DIRS MySQL_LIBRARIES
+ VERSION_VAR MySQL_VERSION
+ )
+# mark_as_advanced(MySQL_INCLUDE_DIRS MySQL_LIBRARIES)
+ endif ()
endif ()
@@ -61,7 +61,7 @@ configure-stamp:
dh_testdir
# Add here commands to configure the package.
cmake . -DCMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX) -DCMAKE_BUILD_TYPE=Release \
- -DMYSQL_CONFIG_PATH=$(MYSQL_HOME)/bin/mysql_config -DUSE_BUNDLED_MYSQLDUMP=1 \
+ -DMySQL_CONFIG_PATH=$(MYSQL_HOME)/bin/mysql_config -DUSE_BUNDLED_MYSQLDUMP=1 \
-DMYSQLCPPCONN_LIBRARY="-L$(CPPCONN_HOME)/lib -lmysqlcppconn" \
-DMYSQLCPPCONN_INCLUDE_DIR=$(CPPCONN_HOME)/include \
-DGDAL_INCLUDE_DIR=$(GDAL_HOME)/include -DGDAL_LIBRARY=$(GDAL_HOME)/lib/libgdal.so \
@@ -207,7 +207,7 @@ CXXFLAGS="-std=c++11 $CXXFLAGS" \
%endif
%cmake -DCMAKE_BUILD_TYPE=Release \
-DREAL_EXECUTABLE_DIR=%{_libexecdir}/mysql-workbench \
- -DMYSQL_CONFIG_PATH=%{mysql_home}/bin/mysql_config \
+ -DMySQL_CONFIG_PATH=%{mysql_home}/bin/mysql_config \
-DMYSQLCPPCONN_LIBRARY="-L%{mysqlcppconn_dir}/lib -lmysqlcppconn" \
-DMYSQLCPPCONN_INCLUDE_DIR=%{mysqlcppconn_dir}/include \
-DIODBC_CONFIG_PATH=%{odbc_home}/bin/iodbc-config \
@@ -114,7 +114,7 @@ target_link_libraries(mysql-workbench-bin
${PCRE_LIBRARIES}
${CAIRO_LIBRARIES}
${LIBZIP_LIBRARIES}
- ${MYSQL_LIBRARIES}
+ ${MySQL_LIBRARIES}
${SQLITE3_LIBRARIES}
${GNOME_KEYRING_LIBRARIES}
)
@@ -1,4 +1,4 @@
-include_directories(. ../include ${PROJECT_SOURCE_DIR}/modules/db.mysql.sqlparser/src ${MYSQL_INCLUDE_DIRS})
+include_directories(. ../include ${PROJECT_SOURCE_DIR}/modules/db.mysql.sqlparser/src ${MySQL_INCLUDE_DIRS})
if (UNIX)
include_directories(./linux)
@@ -20,7 +20,7 @@ include_directories(.
${GRT_INCLUDE_DIRS}
${PCRE_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}
- ${MYSQL_INCLUDE_DIRS}
+ ${MySQL_INCLUDE_DIRS}
)
if (MYSQL_DEFINITIONS)
@@ -2,7 +2,7 @@ include_directories(.
${GTK2_INCLUDE_DIRS}
${SIGC++_INCLUDE_DIRS}
${GRT_INCLUDE_DIRS}
- ${MYSQL_INCLUDE_DIRS}
+ ${MySQL_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}
${TINYXML_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/generated
@@ -72,7 +72,7 @@ include_directories(.
${PROJECT_SOURCE_DIR}/modules/db.mysql.sqlide/src
${GTK2_INCLUDE_DIRS}
${PCRE_INCLUDE_DIRS}
- ${MYSQL_INCLUDE_DIRS}
+ ${MySQL_INCLUDE_DIRS}
${CTemplate_INCLUDE_DIRS}
${GRT_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}
@@ -83,7 +83,7 @@ add_library(wb.model.grt
src/wb_model.cpp
)
-target_link_libraries(wb.model.grt grt ${GRT_LIBRARIES} ${GTK2_LIBRARIES} ${PCRE_LIBRARIES} ${MYSQL_LIBRARIES} ${CTemplate_LIBRARIES})
+target_link_libraries(wb.model.grt grt ${GRT_LIBRARIES} ${GTK2_LIBRARIES} ${PCRE_LIBRARIES} ${MySQL_LIBRARIES} ${CTemplate_LIBRARIES})
set_target_properties(wb.model.grt
PROPERTIES PREFIX ""
@@ -2,7 +2,7 @@ include_directories(.
${GTK2_INCLUDE_DIRS}
${SIGC++_INCLUDE_DIRS}
${GRT_INCLUDE_DIRS}
- ${MYSQL_INCLUDE_DIRS}
+ ${MySQL_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}
${VSQLITE_INCLUDE_DIRS}
${TINYXML_INCLUDE_DIRS}
@@ -24,7 +24,7 @@ add_library(wb.mysql.import.grt
src/wb_mysql_import_dbd4.cpp
)
-target_link_libraries(wb.mysql.import.grt wbscintilla ${GRT_LIBRARIES} ${GTK2_LIBRARIES} ${SIGC++_LIBRARIES} ${TINYXML_LIBRARIES} ${MYSQL_LIBRARIES})
+target_link_libraries(wb.mysql.import.grt wbscintilla ${GRT_LIBRARIES} ${GTK2_LIBRARIES} ${SIGC++_LIBRARIES} ${TINYXML_LIBRARIES} ${MySQL_LIBRARIES})
set_target_properties(wb.mysql.import.grt
PROPERTIES PREFIX ""
@@ -1,7 +1,7 @@
include_directories(
${ODBC_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
- ${MYSQL_INCLUDE_DIRS}
+ ${MySQL_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/backend/wbprivate
)
@@ -17,12 +17,13 @@ if (UNIX)
copytable/main.cpp
copytable/converter.cpp
)
+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_target_properties(wbcopytables-bin PROPERTIES COMPILE_FLAGS "-fPIE")
else()
set_target_properties(wbcopytables-bin PROPERTIES COMPILE_FLAGS "-fPIE -pie")
endif()
- target_link_libraries(wbcopytables-bin wbbase ${MYSQL_LIBRARIES} ${ODBC_LIBRARIES} ${PCRE_LIBRARIES} ${PYTHON_LIBRARIES})
+ target_link_libraries(wbcopytables-bin wbbase ${MySQL_LIBRARIES} ${ODBC_LIBRARIES} ${PCRE_LIBRARIES} ${PYTHON_LIBRARIES})
install(TARGETS wbcopytables-bin DESTINATION ${WB_INSTALL_DIR_EXECUTABLE})
else()
@@ -38,7 +39,7 @@ else()
set_target_properties(wbcopytables PROPERTIES COMPILE_FLAGS "-fPIE -pie")
endif()
- target_link_libraries(wbcopytables wbbase ${MYSQL_LIBRARIES} ${ODBC_LIBRARIES} ${PCRE_LIBRARIES} ${PYTHON_LIBRARIES})
+ target_link_libraries(wbcopytables wbbase ${MySQL_LIBRARIES} ${ODBC_LIBRARIES} ${PCRE_LIBRARIES} ${PYTHON_LIBRARIES})
install(TARGETS wbcopytables DESTINATION ${WB_INSTALL_BIN_DIR})
endif()
@@ -17,4 +17,4 @@ else()
set_target_properties(genwrap PROPERTIES COMPILE_FLAGS "-fPIE -pie")
endif()
-target_link_libraries(genwrap grt wbbase wbpublic ${X11_LIBRARIES} ${PCRE_LIBRARIES} ${MYSQL_LIBRARIES} ${CTemplate_LIBRARIES})
+target_link_libraries(genwrap grt wbbase wbpublic ${X11_LIBRARIES} ${PCRE_LIBRARIES} ${MySQL_LIBRARIES} ${CTemplate_LIBRARIES})

0 comments on commit f32b9ee

Please sign in to comment.