Skip to content

[Code scan] Require MKL interface library in non-MPI detection #7568

Description

@njzjz

This issue is a result of a Codex global repository scan.

The non-MPI branch in FindMKL.cmake calls find_package_handle_standard_args(MKL MKL_INTERFACE_LIB MKL_THREAD MKL_CORE MKL_INCLUDE) without DEFAULT_MSG. With CMake's signature, the second argument is treated as the custom failure message, not as a required variable. As a result, MKL_INTERFACE_LIB can be omitted from the required variable list and MKL_FOUND can be set even when the interface library was not found.

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set MKL_FOUND to TRUE
# if all listed variables are TRUE
if(ENABLE_MPI)
find_package_handle_standard_args(MKL DEFAULT_MSG MKL_INTERFACE_LIB MKL_THREAD MKL_CORE MKL_SCALAPACK MKL_BLACS MKL_INCLUDE)
else()
find_package_handle_standard_args(MKL MKL_INTERFACE_LIB MKL_THREAD MKL_CORE MKL_INCLUDE)
endif()

Relevant code:

if(ENABLE_MPI)
  find_package_handle_standard_args(MKL DEFAULT_MSG MKL_INTERFACE_LIB MKL_THREAD MKL_CORE MKL_SCALAPACK MKL_BLACS MKL_INCLUDE)
else()
  find_package_handle_standard_args(MKL MKL_INTERFACE_LIB MKL_THREAD MKL_CORE MKL_INCLUDE)
endif()

Suggested fix:

Use the same signature in both branches:

find_package_handle_standard_args(MKL DEFAULT_MSG MKL_INTERFACE_LIB MKL_THREAD MKL_CORE MKL_INCLUDE)

This ensures MKL_INTERFACE_LIB is actually required before imported targets are created.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions