graph icon indicating copy to clipboard operation
graph copied to clipboard

Split CMake identities: superproject and 'developer'

Open jeremy-murphy opened this issue 1 year ago • 11 comments

I prefer to use CMake as a build system, but the existing CMake files in Boost don't really help.

  1. I don't want to treat every library as an active project when I'm only working on one.
  2. I need the header files to be part of the project so that an IDE treats them as the source code of the project.

I'm always maintaining some split-identity CMake like this in order to do work, so I thought I may as well merge it upstream if

  1. It's compatible with super-project plans for CMake, and
  2. other developers would find it useful.

jeremy-murphy avatar Oct 31 '24 01:10 jeremy-murphy

This is still somewhat broken, I haven't got the tests to compile properly yet, I think it's partly missing the required Boost.UTF macros, but also some unexpected static_assert failures.

jeremy-murphy avatar Oct 31 '24 01:10 jeremy-murphy

I actually don't know who else works on Boost.Graph and prefers CMake, so I'll just tag a few recent contributors to see if they are interested: @jan-grimo @danielyxyang @brunom @sehe @jcdong98 @andrea-cassioli-maersk @vslashg

jeremy-murphy avatar Oct 31 '24 01:10 jeremy-murphy

Peter, I assigned you because I assume you know about the super-project CMake business.

jeremy-murphy avatar Oct 31 '24 03:10 jeremy-murphy

I do work with CMake usually/

andrea-cassioli-maersk avatar Oct 31 '24 07:10 andrea-cassioli-maersk

This looks OK at a first glance, but you should change

if (BOOST_SUPERPROJECT_VERSION)

to

if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

which checks whether this is the root project (as opposed to checking whether it's part of the Boost superproject.)

In principle, Boost libraries are also usable without a superproject, as direct subprojects, although in this specific case this probably isn't very practical because of the number of dependencies.

pdimov avatar Oct 31 '24 17:10 pdimov

Also, if you're going to make changes to CMakeLists.txt, you should first add CI jobs that verify that current uses aren't broken. Or I can add them for you if you prefer.

pdimov avatar Oct 31 '24 17:10 pdimov

Also, if you're going to make changes to CMakeLists.txt, you should first add CI jobs that verify that current uses aren't broken. Or I can add them for you if you prefer.

If you have some pre-canned test, then yes, please go ahead!

jeremy-murphy avatar Nov 05 '24 03:11 jeremy-murphy

This looks OK at a first glance, but you should change

if (BOOST_SUPERPROJECT_VERSION)

to

if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

which checks whether this is the root project (as opposed to checking whether it's part of the Boost superproject.)

In principle, Boost libraries are also usable without a superproject, as direct subprojects, although in this specific case this probably isn't very practical because of the number of dependencies.

OK, sure, will do. I see there are some new variables with PROJECT in their name specifically for this purpose, but they require a fairly recent version of CMake, so I'll just go with whatever is supported by our minimum requirement.

jeremy-murphy avatar Nov 05 '24 03:11 jeremy-murphy

CI jobs for testing CMake subdir/install use added. I arbitrarily picked the adj_list_edge_list_set.cpp test as the main.cpp file in both cases.

pdimov avatar Nov 07 '24 10:11 pdimov

CI jobs for testing CMake subdir/install use added. I arbitrarily picked the adj_list_edge_list_set.cpp test as the main.cpp file in both cases.

Actually, I'm a bit confused -- where did you add them to?

jeremy-murphy avatar Dec 19 '24 09:12 jeremy-murphy

Here: https://github.com/boostorg/graph/commit/f1e51a08578a648c27ef61c0581adb9e8440cac4

pdimov avatar Dec 19 '24 09:12 pdimov

@andrea-cassioli-maersk have you tried using this?

jeremy-murphy avatar Aug 18 '25 03:08 jeremy-murphy

not really, but I can give it a shot time permitting

andrea-cassioli-maersk avatar Aug 18 '25 06:08 andrea-cassioli-maersk

If you could, that would be awesome, because I would like to merge it but so far I'm the only person that has used it.

jeremy-murphy avatar Aug 18 '25 07:08 jeremy-murphy

The Cmake itself seems to work, I get some compile errors like

      |                                                   ^
In file included from /Users/andrea.cassioli/workspace/graph/test/adj_matrix_cc.cpp:9:
/opt/homebrew/include/boost/graph/graph_concepts.hpp:142:13: error: use of undeclared identifier 'degree'
  142 |         n = degree(v, cg);
      |             ^

but it might be because I using the boost distribution form brew on OSX, could it be?

andrea-cassioli-maersk avatar Aug 19 '25 10:08 andrea-cassioli-maersk

Thanks for having a look. Hmmmm, I can't think of a good reason why distribution via brew would introduce problems but anything is possible.

jeremy-murphy avatar Aug 21 '25 03:08 jeremy-murphy