Skip to content

Commit

Permalink
ODBC-243 Added cmake option to compile C/C auth plugins in
Browse files Browse the repository at this point in the history
Supplying -DALL_PLUGINS_STATIC=ON to cmake for project generation will
make all auth plugins to be compiled in. This is only available on
Windows so far, where it's expected to be used only.
  • Loading branch information
lawrinn committed Apr 18, 2021
1 parent 9c8769b commit f3dc446
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
39 changes: 30 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ ADD_OPTION(WITH_UNIT_TESTS "build test suite" ON)
### Setting installation paths - should go before C/C subproject sets its own. We need to have control over those
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/install.cmake")

# Currently limiting this feature to Windows onle, where it's most probably going to be only used
IF(WIN32 AND ALL_PLUGINS_STATIC)
SET(CLIENT_PLUGIN_AUTH_GSSAPI_CLIENT "STATIC")
SET(CLIENT_PLUGIN_DIALOG "STATIC")
SET(CLIENT_PLUGIN_CLIENT_ED25519 "STATIC")
SET(CLIENT_PLUGIN_CACHING_SHA2_PASSWORD "STATIC")
SET(CLIENT_PLUGIN_SHA256_PASSWORD "STATIC")
SET(CLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD "STATIC")
SET(CLIENT_PLUGIN_MYSQL_OLD_PASSWORD "STATIC")
ENDIF()

### Including C/C subproject
IF(EXISTS ${CMAKE_SOURCE_DIR}/libmariadb)
IF(GIT_BUILD_SRCPKG)
Expand Down Expand Up @@ -338,15 +349,25 @@ TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${MARIADB_CLIENT_TARGET_NAME} ${ODBC_INSTL

# Currently on Windows only
IF(WIN32)
ADD_CUSTOM_COMMAND(TARGET maodbc POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -DDRIVER_LIB_DIR=$<TARGET_FILE_DIR:maodbc>
-DPLUGINS_LIB_DIR=$<TARGET_FILE_DIR:dialog>
-DINSTALLER_TOOLS_DIR=$<TARGET_FILE_DIR:change_dsns_driver>
-DPLUGINS_SUBDIR_NAME=${MARIADB_DEFAULT_PLUGINS_SUBDIR}
-DFILE_IN=${CMAKE_SOURCE_DIR}/wininstall/binaries_dir.xml.in
-DFILE_OUT=${CMAKE_SOURCE_DIR}/wininstall/binaries_dir.xml
-P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake
)
IF(ALL_PLUGINS_STATIC)
ADD_CUSTOM_COMMAND(TARGET maodbc POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -DDRIVER_LIB_DIR=$<TARGET_FILE_DIR:maodbc>
-DPLUGINS_LIB_DIR=""
-DINSTALLER_TOOLS_DIR=$<TARGET_FILE_DIR:change_dsns_driver>
-DPLUGINS_SUBDIR_NAME=${MARIADB_DEFAULT_PLUGINS_SUBDIR}
-DFILE_IN=${CMAKE_SOURCE_DIR}/wininstall/binaries_dir.xml.in
-DFILE_OUT=${CMAKE_SOURCE_DIR}/wininstall/binaries_dir.xml
-P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake)
ELSE()
ADD_CUSTOM_COMMAND(TARGET maodbc POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -DDRIVER_LIB_DIR=$<TARGET_FILE_DIR:maodbc>
-DPLUGINS_LIB_DIR=$<TARGET_FILE_DIR:dialog>
-DINSTALLER_TOOLS_DIR=$<TARGET_FILE_DIR:change_dsns_driver>
-DPLUGINS_SUBDIR_NAME=${MARIADB_DEFAULT_PLUGINS_SUBDIR}
-DFILE_IN=${CMAKE_SOURCE_DIR}/wininstall/binaries_dir.xml.in
-DFILE_OUT=${CMAKE_SOURCE_DIR}/wininstall/binaries_dir.xml
-P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake)
ENDIF()
####### MAODBCS #######
ADD_LIBRARY(maodbcs SHARED ${DSN_DIALOG_FILES} ${CMAKE_SOURCE_DIR}/dsn/mariadb_odbc_setup.def)
SET_TARGET_PROPERTIES(maodbcs PROPERTIES LANGUAGE C)
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ ADD_EXECUTABLE(odbc_connstring connstring.c ${CMAKE_SOURCE_DIR}/ma_dsn.c ${COMMO
TARGET_LINK_LIBRARIES(odbc_connstring ${ODBC_LIBS} ${ODBC_INSTLIBS} mariadbclient ${PLATFORM_DEPENDENCIES})
ADD_TEST(odbc_connstring ${EXECUTABLE_OUTPUT_PATH}/odbc_connstring)
SET_TESTS_PROPERTIES(odbc_connstring PROPERTIES TIMEOUT 120)
SET_TESTS_PROPERTIES(odbc_basic PROPERTIES TIMEOUT 300)
SET_TESTS_PROPERTIES(odbc_basic odbc_catalog2 odbc_cursor PROPERTIES TIMEOUT 420)
14 changes: 13 additions & 1 deletion wininstall/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ SET(PRODUCT_VERSION "${MARIADB_ODBC_VERSION_MAJOR}.${MARIADB_ODBC_VERSION_MINOR}

SET(TLS_LIB_BEGIN "!-- ")
SET(TLS_LIB_END " --")

IF(ALL_PLUGINS_STATIC)
SET(PLUGINS_BEGIN "!-- ")
SET(PLUGINS_END " --")
ELSE()
SET(PLUGINS_BEGIN "")
SET(PLUGINS_END "")
ENDIF()
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(PRODUCT_NAME "${PRODUCT_NAME} 64-bit")
SET(PLATFORM "win64")
Expand Down Expand Up @@ -98,6 +106,10 @@ ADD_CUSTOM_TARGET(
ADD_DEPENDENCIES(${MSI_PACKAGE} ODBC_WIX)
ADD_DEPENDENCIES(ODBC_WIX maodbc maodbcs change_dsns_driver)
IF(NOT USE_SYSTEM_INSTALLED_LIB)
ADD_DEPENDENCIES(ODBC_WIX maodbc maodbcs dialog caching_sha2_password auth_gssapi_client sha256_password mysql_clear_password)
IF(ALL_PLUGINS_STATIC)
ADD_DEPENDENCIES(ODBC_WIX maodbc maodbcs)
ELSE()
ADD_DEPENDENCIES(ODBC_WIX maodbc maodbcs dialog caching_sha2_password auth_gssapi_client sha256_password mysql_clear_password)
ENDIF()
ENDIF()

10 changes: 5 additions & 5 deletions wininstall/mariadb_odbc.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
<ComponentRef Id="RegistryKeys" />
<ComponentRef Id="Setup" />
<ComponentRef Id="Driver" />
<ComponentRef Id="CcPlugins" />
<@PLUGINS_BEGIN@ComponentRef Id="CcPlugins" /@PLUGINS_END@>
<ComponentRef Id="InstallerTools" />
<@TLS_LIB_BEGIN@ComponentRef Id="TlsLib" /@TLS_LIB_END@>
</Feature>
<Feature Id="DebugFeature" Title="Debug Information" Level="2">
<ComponentRef Id="Debug" />
</Feature>
<Feature Id="PluginsFeature" Title="Authentification Plugins" Level="2">
<@PLUGINS_BEGIN@Feature Id="PluginsFeature" Title="Authentification Plugins" Level="2">
<ComponentRef Id="CcPlugins" />
<ComponentRef Id="PluginsDebug" />
</Feature>
</Feature@PLUGINS_END@>
<Property Id="WixQuietExec@IS64@CmdLine" Value='"[INSTALLFOLDER]change_dsns_driver.exe" --reg-direct --quiet' />
<CustomAction Id="MoveExistingDsnsToNewDriver" BinaryKey="WixCA" DllEntry="WixQuietExec@IS64@" Impersonate="yes" />
</Product>
Expand Down Expand Up @@ -75,7 +75,7 @@
<File Id="mariadb_odbc_setup_pdb" Name="maodbcs.pdb" DiskId="1" Source="$(var.binaries_dir)/maodbcs.pdb" />
<CreateFolder />
</Component>
<Component Id="CcPlugins" Guid="@GUID_PLUGINS@" Directory="PLUGINSFOLDER" DiskId="1" Win64="@IS_WIN64@">
<@PLUGINS_BEGIN@Component Id="CcPlugins" Guid="@GUID_PLUGINS@" Directory="PLUGINSFOLDER" DiskId="1" Win64="@IS_WIN64@">
<File Id="caching_sha2_password.dll" Name="caching_sha2_password.dll" DiskId="1" Source="$(var.plugins_source_dir)/caching_sha2_password.dll" />
<File Id="dialog_dll" Name="dialog.dll" KeyPath="yes" DiskId="1" Source="$(var.plugins_source_dir)/dialog.dll" />
<File Id="auth_gssapi_client_dll" Name="auth_gssapi_client.dll" DiskId="1" Source="$(var.plugins_source_dir)/auth_gssapi_client.dll" />
Expand All @@ -91,7 +91,7 @@
<File Id="sha256_password_pdb" Name="sha256_password.pdb" DiskId="1" Source="$(var.plugins_source_dir)/sha256_password.pdb" />
<File Id="client_ed25519_pdb" Name="client_ed25519.pdb" DiskId="1" Source="$(var.plugins_source_dir)/client_ed25519.pdb" />
<CreateFolder />
</Component>
</Component@PLUGINS_END@>
<Component Id="InstallerTools" Guid="@GUID_INSTALLER_TOOLS@" Directory="INSTALLFOLDER" DiskId="1" Win64="@IS_WIN64@">
<File Id="change_dsns_driver" Name="change_dsns_driver.exe" DiskId="1" Source="$(var.installer_tools_dir)/change_dsns_driver.exe" />
</Component>
Expand Down

0 comments on commit f3dc446

Please sign in to comment.