Skip to content

Commit

Permalink
Properly declare imported 'm' library
Browse files Browse the repository at this point in the history
As per modern CMake recommendations, want to inform CMake that 'm'
('libm') is an imported library outside of the project.  Necessary when
using LINK_LIBRARIES_ONLY_TARGETS to allow CMake to error-check target
dependencies (since this is now a target dependency and not a direct
library dependency).

User Support Ticket(s) or Story Referenced: TRILFRAME-601
  • Loading branch information
sebrowne committed Oct 5, 2023
1 parent adb1dff commit 8c972a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ SET(Trilinos_MUST_FIND_ALL_TPL_LIBS_DEFAULT TRUE)

SET(CMAKE_LINK_LIBRARIES_ONLY_TARGETS ON)

add_library(toolchain::m INTERFACE IMPORTED)
set_property(TARGET toolchain::m PROPERTY IMPORTED_LIBNAME "m")

# Set up C++ language standard selection
include(SetTrilinosCxxStandard)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ENDIF()
# LibM not available under MSVC.
IF(NOT MSVC)
# Add libm linking for ceil, floor and such.
LIST(APPEND IMPORTEDLIBS m)
LIST(APPEND IMPORTEDLIBS toolchain::m)
ENDIF()

TRIBITS_ADD_LIBRARY(
Expand Down
2 changes: 1 addition & 1 deletion packages/zoltan/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ ENDIF()

IF(NOT MSVC)
# Add libm linking for ceil, floor and such.
LIST(APPEND IMPORTEDLIBS m)
LIST(APPEND IMPORTEDLIBS toolchain::m)
ENDIF()

TRIBITS_ADD_LIBRARY(
Expand Down

0 comments on commit 8c972a7

Please sign in to comment.