-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Centralized backend list; AsAvailable->AUTO
- Loading branch information
Showing
9 changed files
with
72 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,74 @@ | ||
set(SOCI_EMPTY ${PROJECT_IS_TOP_LEVEL} CACHE STRING "Include the 'empty' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") | ||
set(SOCI_EXISTING_BACKENDS | ||
"Empty" | ||
|
||
set(SOCI_DB2 "AsAvailable" CACHE STRING "Include the 'DB2' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") | ||
set(SOCI_FIREBIRD "AsAvailable" CACHE STRING "Include the 'Firebird' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") | ||
set(SOCI_MYSQL "AsAvailable" CACHE STRING "Include the 'MySQL' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") | ||
set(SOCI_ODBC "AsAvailable" CACHE STRING "Include the 'ODBC' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") | ||
set(SOCI_ORACLE "AsAvailable" CACHE STRING "Include the 'Oracle' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") | ||
set(SOCI_POSTGRESQL "AsAvailable" CACHE STRING "Include the 'Postgresql' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") | ||
set(SOCI_SQLITE3 "AsAvailable" CACHE STRING "Include the 'SQLite3' backend. Can be bool-valued or one of 'Enabled', 'Disabled' and 'AsAvailable'") | ||
"DB2" | ||
"Firebird" | ||
"MySQL" | ||
"ODBC" | ||
"Oracle" | ||
"PostgreSQL" | ||
"SQLite3" | ||
) | ||
set(SOCI_ENABLED_BACKENDS "") | ||
|
||
foreach(CURRENT_BACKEND IN LISTS SOCI_EXISTING_BACKENDS) | ||
string(TOUPPER "${CURRENT_BACKEND}" CURRENT_BACKEND_UPPER) | ||
string(TOLOWER "${CURRENT_BACKEND}" CURRENT_BACKEND_LOWER) | ||
|
||
foreach(CURRENT IN ITEMS "db2" "empty" "firebird" "mysql" "odbc" "oracle" "postgresql" "sqlite3") | ||
string(TOUPPER "${CURRENT}" CURRENT_UPPER) | ||
set(CURRENT_ENABLED_VAR "SOCI_${CURRENT_BACKEND_UPPER}") | ||
|
||
# Add option to enable/disable the current backend. Note: if the cache variable already exists | ||
# (e.g. because it has been specified on the command line), this will NOT overwrite the | ||
# explicitly specified value | ||
set( | ||
${CURRENT_ENABLED_VAR} | ||
"AUTO" | ||
CACHE | ||
STRING | ||
"Whether to include the '${CURRENT_BACKEND}' backend. Can be a boolean value or 'AUTO' indicating that it shall be included unless its dependencies can't be satisfied." | ||
) | ||
|
||
# Backwards compatibility with the old cmake setup that used WITH_* variables | ||
# These are now only defined if the user specified them. | ||
if (DEFINED WITH_${CURRENT_UPPER}) | ||
message(DEPRECATION "Use of the WITH_${CURRENT_UPPER} option is deprecated - use the new SOCI_${CURRENT_UPPER} instead") | ||
set(SOCI_${CURRENT_UPPER} "${WITH_${CURRENT_UPPER}}" CACHE STRING "") | ||
if (DEFINED WITH_${CURRENT_BACKEND_UPPER}) | ||
message(DEPRECATION "Use of the WITH_${CURRENT_BACKEND_UPPER} option is deprecated - use the new ${CURRENT_ENABLED_VAR} instead") | ||
if (WITH_${CURRENT_BACKEND_UPPER} AND ${CURRENT_ENABLED_VAR}) | ||
# Overwrite the new-style enable-option unless that was set to disable the current backend | ||
# (Note that non-empty string - in particular "AUTO" - also convert to a true expression). | ||
# However, the legacy behavior was to only include the backend, if its dependencies are met, | ||
# so we set to AUTO rather than ON. | ||
set(${CURRENT_ENABLED_VAR} "AUTO" CACHE STRING "" FORCE) | ||
endif() | ||
# Delete the legacy variable from cache | ||
unset(WITH_${CURRENT_UPPER} CACHE) | ||
unset(WITH_${CURRENT_BACKEND_UPPER} CACHE) | ||
endif() | ||
|
||
set(SOCI_${CURRENT_UPPER}_AS_AVAILABLE OFF CACHE INTERNAL "" FORCE) | ||
|
||
if (SOCI_${CURRENT_UPPER} STREQUAL "Enabled") | ||
set(SOCI_${CURRENT_UPPER} ON CACHE BOOL "" FORCE) | ||
elseif(SOCI_${CURRENT_UPPER} STREQUAL "Disabled") | ||
set(SOCI_${CURRENT_UPPER} OFF CACHE BOOL "" FORCE) | ||
elseif(SOCI_${CURRENT_UPPER} STREQUAL "AsAvailable") | ||
set(SOCI_${CURRENT_UPPER} ON CACHE BOOL "" FORCE) | ||
set(SOCI_${CURRENT_UPPER}_AS_AVAILABLE ON CACHE INTERNAL "" FORCE) | ||
elseif(SOCI_${CURRENT_UPPER} MATCHES "[Oo][Nn]|[Oo][Ff][Ff]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Yy][Ee][Ss]|[Nn][Oo]|[YyNn01]") | ||
# Do nothing - these are already booleans | ||
|
||
# Internal variable indicating whether the current backend's include mode is AUTO | ||
set(CURRENT_AUTO_VAR "SOCI_${CURRENT_BACKEND_UPPER}_AUTO") | ||
set(${CURRENT_AUTO_VAR} OFF CACHE INTERNAL "" FORCE) | ||
|
||
# Convert the value of the current backend's include flag to uppercase | ||
string(TOUPPER "${${CURRENT_ENABLED_VAR}}" ${CURRENT_ENABLED_VAR}) | ||
|
||
set(INCLUDE_CURRENT_BACKEND OFF) | ||
if (${CURRENT_ENABLED_VAR} STREQUAL "AUTO") | ||
set(INCLUDE_CURRENT_BACKEND ON) | ||
set(${CURRENT_AUTO_VAR} ON) | ||
elseif(${CURRENT_ENABLED_VAR} MATCHES "^(ON|OFF|TRUE|FALSE|YES|NO|[YN01])$") | ||
set(INCLUDE_CURRENT_BACKEND ${${CURRENT_ENABLED_VAR}}) | ||
else() | ||
message(FATAL_ERROR "Unsupported value '${SOCI_${CURRENT_UPPER}}' for option SOCI_${CURRENT_UPPER}") | ||
message(FATAL_ERROR "Invalid value '${${CURRENT_ENABLED_VAR}}' for option '${CURRENT_ENABLED_VAR}'") | ||
endif() | ||
|
||
if (SOCI_${CURRENT_UPPER}) | ||
add_subdirectory(${CURRENT}) | ||
if (${CURRENT_ENABLED_VAR}) | ||
add_subdirectory(${CURRENT_BACKEND_LOWER}) | ||
|
||
# Verify that the backend hasn't been disabled (happens if include mode is AUTO and there are | ||
# unmet dependencies. | ||
if (${CURRENT_ENABLED_VAR}) | ||
list(APPEND SOCI_ENABLED_BACKENDS "${CURRENT_BACKEND}") | ||
endif() | ||
endif() | ||
endforeach() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
if (SOCI_DB2_AS_AVAILABLE) | ||
if (SOCI_DB2_AUTO) | ||
set(REQUIRED_FLAG "") | ||
else() | ||
set(REQUIRED_FLAG "REQUIRED") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
if (SOCI_MYSQL_AS_AVAILABLE) | ||
if (SOCI_MYSQL_AUTO) | ||
set(REQUIRED_FLAG "") | ||
else() | ||
set(REQUIRED_FLAG "REQUIRED") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
if (SOCI_ODBC_AS_AVAILABLE) | ||
if (SOCI_ODBC_AUTO) | ||
set(REQUIRED_FLAG "") | ||
else() | ||
set(REQUIRED_FLAG "REQUIRED") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
if (SOCI_ORACLE_AS_AVAILABLE) | ||
if (SOCI_ORACLE_AUTO) | ||
set(REQUIRED_FLAG "") | ||
else() | ||
set(REQUIRED_FLAG "REQUIRED") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters