Skip to content

Commit

Permalink
Disambiguate shared and static libs .lib files on Windows using MSVC (
Browse files Browse the repository at this point in the history
#455)

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 <[email protected]>
Co-authored-by: Cody Balos <[email protected]>
  • Loading branch information
3 people authored May 16, 2024
1 parent 9ebc406 commit 83c3e66
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 13 additions & 6 deletions cmake/macros/SundialsAddLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 4 additions & 0 deletions doc/shared/RecentChanges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 83c3e66

Please sign in to comment.