Skip to content

Add support for macOS and Clang

Benjamin Morgan requested to merge bmorgan/GitCondDB:build-updates into master

The build of GitCondDB currently assumes use of the GNU compiler and standard library. This MR adds support for other compilers that may or may not use libstdc++ and have differing levels of support for std::filesystem.

A CMake-time check is implemented to compile a test program progressively check for:

  • Full native support for std::filesystem without additional libraries
  • Otherwise, check for requirement to link to stdc++fs or c++fs
  • Otherwise, use boost_filesystem

The required links and compile definitions are then propagated as needed through usage requirements on the GitCondDB target. One slight awkwardness in the current implementation is the need to set the compile definition indicating Boost filesystem usage on the tests. It's PRIVATE scope to GitCondDB so shouldn't propagate to clients, except that the tests check the internals, and so do need it. Only way around this would be to implement a private "gitconddb_fs.h" header, generated at CMake-time and #included by DBImpl.h. I'm happy to implement that, but wanted to check first on preferences!

All of this is really a temporary measure until GCC 9 and macOS Catalina are minimum requirements, but hopefully assists portability and adoption with zero impact on existing users.

A couple of additional portability fixes are included:

  • Use of GNUInstallDirs for conventional installation variables and locations
  • Use of PROJECT_ rather than CMAKE_ variables for in-project locations to support usage of GitCondDB as a subproject of others.
  • Addition of an ALIAS target "GitCondDB::GitCondDB" to the primary GitCondDB target to support usage of GitCondDB as a subproject of others.

Merge request reports