TriBITSPub / TriBITS

TriBITS: Tribal Build, Integrate, and Test System,
http://tribits.org
Other
36 stars 46 forks source link

Add cmake_minimum_required() calls to <Package>Config.cmake files #522

Closed bartlettroscoe closed 2 years ago

bartlettroscoe commented 2 years ago

Seems the expected convention for <Package>Config.cmake files is to include a call to cmake_minimum_version() to handle any features of CMake that may need newer policies, like if (... IN_LIST ...). In particular, the example in the book "Professional CMake: 11th edition" shows:

# We use if(...IN_LIST...), make sure it is available
if(CMAKE_VERSION VERSION_LESS 3.3)
  set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
    "MyProj requires CMake 3.3 or later"
    )
  set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
  return()
endif()
cmake_minimum_required(VERSION 3.3...3.21)

This came up due to Kokkos adding extra CMake code to KokkosConfig_install.cmake as shown in:

https://github.com/trilinos/Trilinos/blob/78aac8eb821d3a9817db214c364353fdda0c0c19/packages/kokkos/cmake/kokkos_install.cmake#L32-L44

None of the TriBITS-generated <Package>Config.cmake or <Project>Config.cmake files is using if (... IN_LIST ...).

See more details in SNL internal issue TRILINOSHD-128.

bartlettroscoe commented 2 years ago

For a longer discussion of why we need to do this, see https://github.com/trilinos/Trilinos/pull/10930#discussion_r954990717.

bartlettroscoe commented 2 years ago

With the merge of PRs #523 and #524 and the updated snapshot of TriBITS 'master' into Trilinos 'develop' with the merge of PR trilinos/Trilinos#10930, this issue is resolved.