sundials icon indicating copy to clipboard operation
sundials copied to clipboard

The targets cannot be found

Open NancyLi1013 opened this issue 3 years ago • 3 comments

Hi, I'm maintainer of vcpkg, when using sundials, I found that the current usage is not correct.

The package sundials:x64-windows provides CMake targets:

    find_package(SUNDIALS CONFIG REQUIRED)
    # Note: 24 target(s) were omitted.
    target_link_libraries(main PRIVATE SUNDIALS::KLU SUNDIALS::HYPRE SUNDIALS::MAGMA SUNDIALS::XBRAID)

It seems that all these features are disabled, since the values are all OFF in SUNDIALSConfig.cmake file.

Could you please help take a look?

Thanks in advance!

The errors are like this:

-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29337.0
-- The CXX compiler identification is MSVC 19.28.29337.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at F:/tool/vcpkg/scripts/buildsystems/vcpkg.cmake:660 (_add_executable):
  Target "main" links to target "SUNDIALS::KLU" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?
Call Stack (most recent call first):
  CMakeLists.txt:6 (add_executable)


CMake Error at F:/tool/vcpkg/scripts/buildsystems/vcpkg.cmake:660 (_add_executable):
  Target "main" links to target "SUNDIALS::HYPRE" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Call Stack (most recent call first):
  CMakeLists.txt:6 (add_executable)


CMake Error at F:/tool/vcpkg/scripts/buildsystems/vcpkg.cmake:660 (_add_executable):
  Target "main" links to target "SUNDIALS::XBRAID" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Call Stack (most recent call first):
  CMakeLists.txt:6 (add_executable)


CMake Error at F:/tool/vcpkg/scripts/buildsystems/vcpkg.cmake:660 (_add_executable):
  Target "main" links to target "SUNDIALS::TRILINOS" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Call Stack (most recent call first):
  CMakeLists.txt:6 (add_executable)

NancyLi1013 avatar Mar 02 '21 09:03 NancyLi1013

I also noticed that all generated files including .lib and .dll are installed to /lib directory,

I checked the source code here and found this in /cmake/macros/SundialsAddLibrary.cmake

 install(TARGETS ${_actual_target_name} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT sundials-targets)

It should be like this:

 install(TARGETS ${_actual_target_name} EXPORT sundials-targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)

Could you please also help check this?

NancyLi1013 avatar Mar 02 '21 09:03 NancyLi1013

Since SUNDIALSConfig.cmake lists these options as off I'm guessing SUNDIALS was configured with the default settings. In this case any targets related to third-party libraries (i.e., KLU, hypre, MAGMA, and XBraid) are not built and installed. To use an external library with SUNDIALS you'll need to enable the corresponding option and provide information for where the library is installed. For example, with KLU the relevant options are KLU_ENABLE, KLU_INCLUDE_DIR, and KLU_LIBRARY_DIR.

With regards to the target install command, this does need to be updated for Windows systems. Note that ${CMAKE_INSTALL_LIBDIR} is used instead of lib as the default library install directory may be changed with the CMAKE_INSTALL_LIBDIR variable. Similarly named variables apply for the RUNTIME and ARCHIVE destinations (the default values are set by include(GNUInstallDirs)).

gardner48 avatar Mar 02 '21 15:03 gardner48

Hi @gardner48

Thanks for your above information.

For the targets that are configured with the default settings, I think those should not be exported in the usage if they are disabled. The usage should keep consistent with those features. For example. if KLU is not built and installed, SUNDIALS::KLU should not be showed in the exported targets lists.

So I think the current usage is not reasonable.

Also, if I just want to use sundials code, how should I use it in my project?

For the target install command, I agree your opinion completely.

NancyLi1013 avatar Mar 03 '21 03:03 NancyLi1013

Closing due to inactivity. The build issues mentioned have been fixed.

balos1 avatar Mar 29 '24 21:03 balos1