TriBITS icon indicating copy to clipboard operation
TriBITS copied to clipboard

Header only subpackage error

Open hcedwar opened this issue 10 years ago • 2 comments
trafficstars

Header only subpackages should be supported.

hcedwar avatar Dec 04 '14 16:12 hcedwar

The plan would be to provide a simple function like:

TRIBITS_ADD_HEADERS(
  [HEADERS <h0> <h1> ...]
  [HEADERS_INSTALL_SUBDIR <subdir>]
  [NOINSTALLHEADERS <nih0> <hih1> ...]
  )

The option INSTALL_SUBDIR, <subdir> is new. It would allow you to install your headers under <install-dir>/include/<subdir>/ instead of just <install-dir>/include/ like happens now by default. I know some packages like to do this.

What this function would do is:

  1. Add the include directories for to ${PACKAGE_NAME}_INCLUDE_DIRS
  2. Add INSTALL() commands for the headers listed in HEADERS.

Would this satisfy your needs?

bartlettroscoe avatar Dec 04 '14 16:12 bartlettroscoe

There has been some recent queries about header-only packages and subpackages in TriBITS. The plan described above would work, but it would increase the code and therefore complexity in TriBITS.

The better plan would be to refactor TriBITS to use updated CMake features would directly allow that. The newer add_library( <target-name> ... INTERFACE ... ) option along with targert_add_include_directories() would provide easy direct support for that, and would eliminate a lot of (complex) code in TriBITS that has to manually manage the list of include directories for each SE package.

But the add_library( ... INTERFACE ...) option was only added in CMake 3.0 but currently the Trilinos project requires backward compatibility with CMake 2.8.11 and that version does not support the INTERFACE option as shown at:

  • https://cmake.org/cmake/help/v2.8.11/cmake.html#command:add_library

It looks like we need to upgrade the minimum version of CMake to at least 3.0 to allow the usage of ADD_LIBRARY(INTERFACE) as shown at:

https://cmake.org/cmake/help/v3.0/command/add_library.html

The current workaround is to create a dummy source file and a dummy library. Several examples of that in Trilinos.

It would be great if we could upgrade the minimum version of CMake required by Trilinos and TriBITS. To chime in on that, please add a comment to:

https://github.com/trilinos/Trilinos/issues/1761

The more recent, the better.

bartlettroscoe avatar May 15 '18 13:05 bartlettroscoe