Crosscompiling timescaledb on linux for windows (mingw-w64)

Hi,

Here I am building an own version of postgresql for linux and windows using gcc on linux. For windows I use mingw-w64 to cross compile.

Now I also need to add timescaledb (2.23.0) to the install. For Linux everything is fine, but not for windows. I do not succeed to cross compile for mingw-w64. It is more or less a cmake problem as it tries to test the compiler for subdirectories (eg. sql) and adds the -rdynamic option to the link command which is not available in the gcc for windows and then fails.

I have created a pg_config shell script to satisfy the bootstrap of timescaledb. That works properly.
And I have create a toolchain definition for cmake (mytoolchain.cmake)

# We are cross-compiling for Windows
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

# Set the path to your custom MinGW-w64 toolchain.
set(TOOLCHAIN_BIN_PATH "/ovde_plugins/gcc11/mingwin/bin")
set(TOOLCHAIN_PREFIX "/ovde_plugins/gcc11/mingwin")

# Set the C and C++ compilers using the toolchain's executables.
set(CMAKE_C_COMPILER "${TOOLCHAIN_BIN_PATH}/x86_64-w64-mingw32-gcc")
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_BIN_PATH}/x86_64-w64-mingw32-g++")
set(CMAKE_RC_COMPILER "${TOOLCHAIN_BIN_PATH}/x86_64-w64-mingw32-windres")

# Specify the target environment for finding libraries and includes.
set(CMAKE_FIND_ROOT_PATH "${TOOLCHAIN_PREFIX}/x86_64-w64-mingw32")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Instruct CMake's internal try_compile tests to build static libraries.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

I invoke the bootstrap of timescaledb afterwards with -DCMAKE_TOOLCHAIN_FILE=_path_to_toolchain_file_

Fine so far. When invoking “make” in the build folder it starts and enters sql folder. Here cmake tries to test the compiler. This test fails immediately. It cannot link as “-rdynamic” is supplied to the link command which is not understood by the windows gcc. An intensive search in the internet yet has not delivered a solution for me. I am using cmake 3.31.9 to build timescaledb.

Has anyone already done that? And has found a solution for this?

Thanks for your help

Roland