From 83c3e66c060c9044540100734ecf0dbc06ab285f Mon Sep 17 00:00:00 2001 From: Adrien Delsalle Date: Fri, 17 May 2024 00:50:27 +0200 Subject: [PATCH] Disambiguate shared and static libs `.lib` files on Windows using MSVC (#455) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description --- Disambiguate shared and static libs `.lib` files on Windows using MSVC Suffix library output name with `_static` when building both static and shared libs on Windows Closes #454 --------- Co-authored-by: Markus Mützel Co-authored-by: Cody Balos --- CHANGELOG.md | 4 ++++ cmake/macros/SundialsAddLibrary.cmake | 19 +++++++++++++------ doc/shared/RecentChanges.rst | 4 ++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40706c1649..fcf9091a19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Changes to SUNDIALS in release X.Y.Z +Fixed conflicting `.lib` files between shared and static libs when using `MSVC` on Windows + +Fixed invalid `SUNDIALS_EXPORT` generated macro when building both shared and static libs + Created shared user interface for ARKODE user-callable routines, to allow more uniform control over time-stepping algorithms, improved extensibility, and simplified code maintenance. Marked the corresponding stepper-specific diff --git a/cmake/macros/SundialsAddLibrary.cmake b/cmake/macros/SundialsAddLibrary.cmake index ca0d226191..3c66bbe7e3 100644 --- a/cmake/macros/SundialsAddLibrary.cmake +++ b/cmake/macros/SundialsAddLibrary.cmake @@ -200,7 +200,7 @@ macro(sundials_add_library target) # add compile definitions to object library for SUNDIALS_EXPORT if(${_libtype} MATCHES "STATIC") - target_compile_definitions(${obj_target} PRIVATE SUNDIALS_STATIC_DEFINE) + target_compile_definitions(${obj_target} PUBLIC SUNDIALS_STATIC_DEFINE) else() target_compile_definitions(${obj_target} PRIVATE sundials_core_EXPORTS) endif() @@ -296,7 +296,7 @@ macro(sundials_add_library target) # add compile definitions for SUNDIALS_EXPORT if(${_libtype} MATCHES "STATIC") - target_compile_definitions(${_actual_target_name} PRIVATE SUNDIALS_STATIC_DEFINE) + target_compile_definitions(${_actual_target_name} PUBLIC SUNDIALS_STATIC_DEFINE) else() target_compile_definitions(${obj_target} PRIVATE sundials_core_EXPORTS) endif() @@ -325,10 +325,17 @@ macro(sundials_add_library target) # set the correct output name if(sundials_add_library_OUTPUT_NAME) - set_target_properties(${_actual_target_name} PROPERTIES - OUTPUT_NAME ${sundials_add_library_OUTPUT_NAME} - CLEAN_DIRECT_OUTPUT 1 - ) + if((MSVC OR ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")) AND ${_libtype} MATCHES "STATIC") + set_target_properties(${_actual_target_name} PROPERTIES + OUTPUT_NAME "${sundials_add_library_OUTPUT_NAME}_static" + CLEAN_DIRECT_OUTPUT 1 + ) + else() + set_target_properties(${_actual_target_name} PROPERTIES + OUTPUT_NAME ${sundials_add_library_OUTPUT_NAME} + CLEAN_DIRECT_OUTPUT 1 + ) + endif() else() set_target_properties(${_actual_target_name} PROPERTIES OUTPUT_NAME ${target} diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index 4f1e6dbe92..6b3cb4f270 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -37,6 +37,10 @@ Added the following MRI coupling tables **Bug Fixes** +Fixed conflicting ``.lib`` files between shared and static libs when using ``MSVC`` on Windows + +Fixed invalid ``SUNDIALS_EXPORT`` generated macro when building both shared and static libs + Updated the CMake variable ``HIP_PLATFORM`` default to ``amd`` as the previous default, ``hcc``, is no longer recognized in ROCm 5.7.0 or newer. The new default is also valid in older version of ROCm (at least back to version 4.3.1).