aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-07-19 00:33:07 +0200
committerShauren <shauren.trinity@gmail.com>2022-07-19 00:33:07 +0200
commite9152679d78c456e05be3743d7fed308c8304555 (patch)
tree131597b20285646132be248737c3caedbf228d33
parent763c758969447d7164c62f78d2e18978c929956c (diff)
Build: Fixed finding mysql binary on first cmake run
Closes #28133
-rw-r--r--CMakeLists.txt3
-rw-r--r--cmake/macros/FindMySQL.cmake22
-rw-r--r--dep/mysql/CMakeLists.txt2
3 files changed, 21 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4bd17f2c429..6ce6cb4be62 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -78,6 +78,9 @@ if(NOT WITHOUT_GIT)
find_package(Git 1.7)
endif()
+# find mysql client binary (needed by genrev)
+find_package(MySQL OPTIONAL_COMPONENTS binary)
+
# Find revision ID and hash of the sourcetree
include(cmake/genrev.cmake)
diff --git a/cmake/macros/FindMySQL.cmake b/cmake/macros/FindMySQL.cmake
index a1bf1fb274d..f27a13145ab 100644
--- a/cmake/macros/FindMySQL.cmake
+++ b/cmake/macros/FindMySQL.cmake
@@ -260,14 +260,26 @@ if(WIN32)
)
endif(WIN32)
+unset(MySQL_lib_WANTED)
+unset(MySQL_binary_WANTED)
+set(MYSQL_REQUIRED_VARS "")
foreach(_comp IN LISTS MySQL_FIND_COMPONENTS)
if(_comp STREQUAL "lib")
+ set(MySQL_${_comp}_WANTED TRUE)
+ if(MySQL_FIND_REQUIRED_${_comp})
+ list(APPEND MYSQL_REQUIRED_VARS "MYSQL_LIBRARY")
+ list(APPEND MYSQL_REQUIRED_VARS "MYSQL_INCLUDE_DIR")
+ endif()
if(EXISTS "${MYSQL_LIBRARY}" AND EXISTS "${MYSQL_INCLUDE_DIR}")
set(MySQL_${_comp}_FOUND TRUE)
else()
set(MySQL_${_comp}_FOUND FALSE)
endif()
elseif(_comp STREQUAL "binary")
+ set(MySQL_${_comp}_WANTED TRUE)
+ if(MySQL_FIND_REQUIRED_${_comp})
+ list(APPEND MYSQL_REQUIRED_VARS "MYSQL_EXECUTABLE")
+ endif()
if(EXISTS "${MYSQL_EXECUTABLE}" )
set(MySQL_${_comp}_FOUND TRUE)
else()
@@ -283,24 +295,24 @@ unset(_comp)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MySQL
REQUIRED_VARS
- MYSQL_LIBRARY
- MYSQL_INCLUDE_DIR
+ ${MYSQL_REQUIRED_VARS}
HANDLE_COMPONENTS
FAIL_MESSAGE
"Could not find the MySQL libraries! Please install the development libraries and headers"
)
+unset(MYSQL_REQUIRED_VARS)
if(MYSQL_FOUND)
- if(MySQL_lib_FOUND)
+ if(MySQL_lib_WANTED AND MySQL_lib_FOUND)
message(STATUS "Found MySQL library: ${MYSQL_LIBRARY}")
message(STATUS "Found MySQL headers: ${MYSQL_INCLUDE_DIR}")
endif()
- if(MySQL_binary_FOUND)
+ if(MySQL_binary_WANTED AND MySQL_binary_FOUND)
message(STATUS "Found MySQL executable: ${MYSQL_EXECUTABLE}")
endif()
mark_as_advanced(MYSQL_FOUND MYSQL_LIBRARY MYSQL_EXTRA_LIBRARIES MYSQL_INCLUDE_DIR MYSQL_EXECUTABLE)
- if(NOT TARGET MySQL::MySQL AND MySQL_lib_FOUND)
+ if(NOT TARGET MySQL::MySQL AND MySQL_lib_WANTED AND MySQL_lib_FOUND)
add_library(MySQL::MySQL UNKNOWN IMPORTED)
set_target_properties(MySQL::MySQL
PROPERTIES
diff --git a/dep/mysql/CMakeLists.txt b/dep/mysql/CMakeLists.txt
index ba4af695468..a30b0f738f4 100644
--- a/dep/mysql/CMakeLists.txt
+++ b/dep/mysql/CMakeLists.txt
@@ -8,7 +8,7 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-find_package(MySQL REQUIRED COMPONENTS lib OPTIONAL_COMPONENTS binary)
+find_package(MySQL REQUIRED COMPONENTS lib)
add_library(mysql INTERFACE)