Skip to content
Snippets Groups Projects
Commit 2c97da81 authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

CMake fix for find_optional_package

parent 381f7f3e
No related branches found
No related tags found
No related merge requests found
......@@ -8,17 +8,24 @@ endif()
macro (find_optional_package _package)
string(TOUPPER ${_package} _packageUpper)
if (WITH_${_packageUpper})
# WITH_${_packageUpper} option requested by the user
if (NOT DEFINED WITH_${_packageUpper})
# First run and WITH_${_packageUpper} option is not set by the user.
# Enable auto-mode and try to find package.
find_package(${_package} ${ARGN})
elseif (WITH_${_packageUpper})
# Non-first run or WITH_${_packageUpper} was set by the user.
# Force error if the package will not be found.
set(${_packageUpper}_FIND_REQUIRED ON)
endif()
option(WITH_${_packageUpper} "Search for ${_package} package" ON)
if (WITH_${_packageUpper})
find_package(${_package} ${ARGN})
else (WITH_${_packageUpper})
set(${_package}_FOUND OFF)
set(${_packageUpper}_FOUND OFF)
endif ()
if (${_package}_FOUND OR ${_packageUpper}_FOUND)
set(_default ON)
else()
set(_default OFF)
endif()
# Add the user option and (!) update the cache
option(WITH_${_packageUpper} "Search for ${_package} package" ${_default})
# Now ${WITH_${_packageUpper}} is either ON or OFF
file(APPEND "${_OptionalPackagesFile}"
"-- WITH_${_packageUpper}=${WITH_${_packageUpper}}\n")
endmacro (find_optional_package)
......
......@@ -8,4 +8,6 @@ if (MYSQL_FOUND)
add_library(mysql SHARED mysql.cc)
target_link_libraries(mysql ${MYSQL_LIBRARIES})
install(TARGETS mysql LIBRARY DESTINATION ${PLUGIN_DIR})
else()
message(STATUS "MySQL client not found, box.net.sql(mysql) disabled")
endif()
......@@ -11,6 +11,6 @@ if (PostgreSQL_FOUND)
install(TARGETS pg LIBRARY DESTINATION ${PLUGIN_DIR})
else()
message(STATUS "PostgreSQL client not found")
message(STATUS "PostgreSQL client not found, box.net.sql(pg) disabled")
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment