Skip to content

Commit e87a175

Browse files
committed
Fix LTO (aka interprocedural optimization) build with MSVC
Also, disable MSVC LTO for static client libraries - they won't be usable for end-users.
1 parent 040069f commit e87a175

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cmake/libutils.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,5 +370,11 @@ ENDFUNCTION()
370370
FUNCTION (MAYBE_DISABLE_IPO target)
371371
IF(MSVC AND NOT CLANG_CL)
372372
SET_TARGET_PROPERTIES(${target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
373+
IF(CMAKE_CONFIGURATION_TYPES)
374+
FOREACH(cfg ${CMAKE_CONFIGURATION_TYPES})
375+
STRING(TOUPPER "${cfg}" cfg_upper)
376+
SET_TARGET_PROPERTIES(${target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_${cfg_upper} OFF)
377+
ENDFOREACH()
378+
ENDIF()
373379
ENDIF()
374380
ENDFUNCTION()

cmake/mariadb_connector_c.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ SET(CLIENT_PLUGIN_PVIO_SOCKET STATIC)
4040
MESSAGE("== Configuring MariaDB Connector/C")
4141
ADD_SUBDIRECTORY(libmariadb)
4242

43+
IF(MSVC AND TARGET mariadb_obj AND TARGET mariadbclient)
44+
# With MSVC, do not produce LTCG-compiled static client libraries.
45+
# They are not usable by end-users, being tied to exact compiler version
46+
MAYBE_DISABLE_IPO(mariadb_obj)
47+
MAYBE_DISABLE_IPO(mariadbclient)
48+
ENDIF()
49+
4350
IF(UNIX)
4451
INSTALL(CODE "EXECUTE_PROCESS(
4552
COMMAND ${CMAKE_COMMAND} -E make_directory \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR})

0 commit comments

Comments
 (0)