Description:
When building from source while specifying a CMAKE_DEBUG_POSTFIX, the debug build fails while building 'mysqlclient[POSTFIX].lib' with the following error:
LINK : fatal error LNK1181: cannot open input file 'D:/path/to/mysql-connector-c-6.1.6-src/libmysql/Debug/clientlib.lib' [D:\path\to\mysql-connector-c-6.1.6-src\libmysql\mysqlclient.vcxproj]
Versions: CMake v.3.1.3; Visual Studio Express 2012.
How to repeat:
1.Download/unpack the 6.1.6 source code
2.Create a 'build' directory in the source dir
3.Configure:
cmake -G "Visual Studio 11" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX=.\build
4.Build:
cmake --build . --target INSTALL --config Debug
Suggested fix:
The mysqlclient.lib is built using the MERGE_STATIC_LIBS macro from <source_dir>\cmake\libutils.cmake.
This macro fails to obtain the correct filename for libs when built with a CMAKE_DEBUG_POSTFIX.
The issue can be fixed, for example, by changing line 137:
GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION)
to:
GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION_${CMAKE_BUILD_TYPE})