Skip to content

Commit

Permalink
ODBC-330 Added WiX as prerequisite in BUILD.md and check of WiX binaries
Browse files Browse the repository at this point in the history
If they are not found in given location, and WIX_DIR was provided by
user, the error is returned. If they are not found at location pointed
by env WIX variable, then msi build targets are not generated, but no
error returned.
Fixed error, that WIX_DIR had to have slash or backslash at the end.
  • Loading branch information
lawrinn committed Aug 4, 2021
1 parent 5914ebf commit 0c7ff3a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
8 changes: 6 additions & 2 deletions BUILD.md
@@ -1,18 +1,22 @@
# Building the Connector/ODBC

Following are build instructions for various operating systems.
Following are build instructions for various operating systems. Paths and filenames are given for example, and may be different on your
system of for your purposes.

## Windows

Prior to start building on Windows you need to have following tools installed:
- Microsoft Visual Studio https://visualstudio.microsoft.com/downloads/
- Git https://git-scm.com/download/win
- cmake https://cmake.org/download/
If you need msi package to be generated by the build process, you also need:
- WiX Toolset https://wixtoolset.org/releases/
and provide WIX_DIR parameter for cmake with path to WiX binaries, or set WIX env variable with path to WiX installation directory.

```
git clone https://github.com/MariaDB/mariadb-connector-odbc.git
cd mariadb-connector-odbc
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCONC_WITH_MSI=OFF -DWITH_SSL=SCHANNEL .
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCONC_WITH_MSI=OFF -DWITH_SSL=SCHANNEL -DWIX_DIR="C:\Program Files (x86)\WiX Toolset v3.11\bin\" .
cmake --build . --config RelWithDebInfo
msiexec.exe /i wininstall\mariadb-connector-odbc-3.0.6-win32.msi
```
Expand Down
31 changes: 24 additions & 7 deletions wininstall/CMakeLists.txt
Expand Up @@ -9,10 +9,30 @@ IF(WITH_REVNO)
STRING(REPLACE "\n" "" revno ${revno})
ENDIF()

SET(WIXNOTFOUND_ERROR ON)
IF(NOT WIX_DIR)
SET(WIX_DIR "$ENV{WIX}/bin/")
SET(WIX_DIR "$ENV{WIX}/bin")
MESSAGE(STATUS "WiX directory: ${WIX_DIR}")
# Return error only if WIX_DIR was specified by user, but wix binaries are not found there
SET(WIXNOTFOUND_ERROR OFF)
ENDIF()

ADD_EXECUTABLE(change_dsns_driver change_dsns_driver.c ${CMAKE_SOURCE_DIR}/ma_dsn.c ${CMAKE_SOURCE_DIR}/ma_platform_win32.c ${CMAKE_SOURCE_DIR}/ma_common.c)
TARGET_LINK_LIBRARIES(change_dsns_driver ${ODBC_LIBS} ${ODBC_INSTLIBS} legacy_stdio_definitions Shlwapi Pathcch)

FIND_PROGRAM(WIXBIN "${WIX_DIR}/candle.exe")

IF(NOT WIXBIN)
IF(WIXNOTFOUND_ERROR)
MESSAGE(FATAL_ERROR "WiX binaries have not been found in given location. Don't define WIX_DIR, if you don't need msi package generation")
ELSE()
MESSAGE(STATUS "WiX binaries are not found, skipping generating of msi building projects")
RETURN()
ENDIF()
ELSE()
MESSAGE(STATUS "WiX binaries are found in given location ${WIXBIN}")
ENDIF()

SET(PRODUCT_NAME "MariaDB ODBC Driver")
SET(PRODUCT_MANUFACTURER "MariaDB")
SET(PRODUCT_VERSION "${MARIADB_ODBC_VERSION_MAJOR}.${MARIADB_ODBC_VERSION_MINOR}.${MARIADB_ODBC_VERSION_PATCH}")
Expand Down Expand Up @@ -63,9 +83,6 @@ ELSE()
SET(GUID_INSTALLER_TOOLS "786BD2C3-20B0-4b8f-8D9B-374C736E3A1B")
ENDIF()

ADD_EXECUTABLE(change_dsns_driver change_dsns_driver.c ${CMAKE_SOURCE_DIR}/ma_dsn.c ${CMAKE_SOURCE_DIR}/ma_platform_win32.c ${CMAKE_SOURCE_DIR}/ma_common.c)
TARGET_LINK_LIBRARIES(change_dsns_driver ${ODBC_LIBS} ${ODBC_INSTLIBS} legacy_stdio_definitions Shlwapi Pathcch)

CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/wininstall/mariadb_odbc.xml.in
${CMAKE_BINARY_DIR}/wininstall/mariadb_odbc.xml)
IF(${revno})
Expand Down Expand Up @@ -94,14 +111,14 @@ MESSAGE(STATUS "MSI package name ${MSI_PACKAGE}")

ADD_CUSTOM_TARGET(
${MSI_PACKAGE}
COMMAND ${WIX_DIR}light.exe -ext WixUIExtension -ext WixUtilExtension mariadb_odbc.wixobj -o ${MSI_PACKAGE})
COMMAND "${WIX_DIR}/light.exe" -ext WixUIExtension -ext WixUtilExtension mariadb_odbc.wixobj -o ${MSI_PACKAGE})

SET_TARGET_PROPERTIES(${MSI_PACKAGE} PROPERTIES EXCLUDE_FROM_ALL OFF)

ADD_CUSTOM_TARGET(
ODBC_WIX
DEPENDS mariadb_odbc.xm binaries_dir.xm
COMMAND ${WIX_DIR}candle.exe -ext WixUIExtension -ext WixUtilExtension mariadb_odbc.xml -o mariadb_odbc.wixobj)
DEPENDS mariadb_odbc.xml binaries_dir.xml
COMMAND "${WIX_DIR}/candle.exe" -ext WixUIExtension -ext WixUtilExtension mariadb_odbc.xml -o mariadb_odbc.wixobj)

ADD_DEPENDENCIES(${MSI_PACKAGE} ODBC_WIX)
ADD_DEPENDENCIES(ODBC_WIX maodbc maodbcs change_dsns_driver)
Expand Down

0 comments on commit 0c7ff3a

Please sign in to comment.