Windows: Different module definition file for Debug/Release configurations?
Hi,
I am trying to prepare CMakeLists.txt for libpq conan package [0] so shared build would work with VS compilers, and I've got stuck on issue that it seems I have to provide different .def file for Debug or Release builds.
libpq has two .def
files: src/interfaces/libpq/libpqddl.def and src/interfaces/libpq/libpqdddl.def . As a side-note, these are not found in their git repo [1], they are only in the source tarballs, downloaded from the website(???)
Anyway, libpqddl.def defines LIBPQ.DLL, while libpqddll.def defines LIBPQD.DLL. At first, by mistake, I've used only libpqddll.def (because there's no CMAKE_BUILD_TYPE
defined when building conan
package using VS compiler), and that resulted libpq.lib
being linked, though application actually required libpqd.dll, in result crashing when it was not found.
So long story short, looks like there's need to specify different .def
file for debug/release builds. I've tried generator expression like this:
add_library(libpq ${pg_port_src} ${pg_backend_src} ${pg_libpq_src} ${DLL_DEF_FILE} "$<$<CONFIG:Debug>:${DLL_DEF_FILE_DEBUG}>" "$<$<CONFIG:Release>:${DLL_DEF_FILE_RELEASE}>")
...and that results in:
-- Generating done
CMake Error in CMakeLists.txt:
Target "libpq" has source files which vary by configuration. This is not
supported by the "Visual Studio 15 2017" generator.
(that's from CMake 3.15.3).
Diffing libpqdll.def and libpqddll.def I see that only dll name is different, so I guess I could use just single release .def
file (without "d" postfix), but that looks like deviation from the upstream, as they seem to build libpq dll with and without d
postfix in debug/release builds.