Page MenuHomePhabricator

[services] Expose top-level CMakeList.txt for cpp projects
ClosedPublic

Authored by jon on Jun 19 2022, 11:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 22, 5:39 AM
Unknown Object (File)
Fri, Nov 22, 5:37 AM
Unknown Object (File)
Fri, Nov 22, 5:04 AM
Unknown Object (File)
Fri, Nov 22, 5:03 AM
Unknown Object (File)
Fri, Nov 22, 4:56 AM
Unknown Object (File)
Thu, Nov 21, 11:01 PM
Unknown Object (File)
Sat, Nov 16, 4:08 AM
Unknown Object (File)
Tue, Nov 5, 10:28 PM

Details

Summary

A top-level CMakeList.txt is required
because CMake does not like importing from sibling directories.
Instead it's best practices to have CMake add the
related subdirectories, and then add the link dependencies
from the parent directory.

This is part of a larger effort to bring more structure to the C++ codebase https://linear.app/comm/issue/ENG-1310/export-nativecpp-projects-as-cmake-projects

The intent is to be able to reference the dependencies as packages, instead of just as GLOB'ing over certain directories; which is a major anti-pattern in CMake as it create a bunch of footguns such as finding multiple files with main() defined, or picking up unrelated code in generated folders.

Test Plan
nix develop 
cd native/cpp/CommonCpp/
rm -rf build && mkdir build && cd build && cmake .. && make -j
# should build everything under CommonCpp

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

jon retitled this revision from Expose top-level CMakeList.txt for cpp projects to [services] Expose top-level CMakeList.txt for cpp projects.
Harbormaster returned this revision to the author for changes because remote builds failed.Jun 19 2022, 11:49 AM
Harbormaster failed remote builds in B9808: Diff 13572!

Use comm-client as target name to avoid confusion

Harbormaster returned this revision to the author for changes because remote builds failed.Jun 19 2022, 3:58 PM
Harbormaster failed remote builds in B9819: Diff 13583!
native/cpp/CommonCpp/CMakeLists.txt
11 ↗(On Diff #13583)

We have two similar CryptoTools here.

jon marked an inline comment as done.

Remove bad merge resolution

jon published this revision for review.Jun 27 2022, 9:36 AM
jon added inline comments.
native/cpp/CommonCpp/CMakeLists.txt
11 ↗(On Diff #13583)

looks like a bad merge resolution. Thanks

ashoat requested changes to this revision.Jun 28 2022, 1:05 PM

@jonringer-comm, repeating some feedback I've left for you previously. Would be great if you could integrate this feedback going forward... it would save both you and your reviewers time if we can reduce the number of times feedback has to be repeated to you.

native/cpp/CommonCpp/CMakeLists.txt
14–32

Same issues as I highlighted in D3867:

  1. Close parens are not indented properly
  2. Extraneous newlines at the end of the file
This revision now requires changes to proceed.Jun 28 2022, 1:05 PM

Update diff with changes to protobuf CMake Project

ashoat requested changes to this revision.Jul 3 2022, 11:51 AM

My feedback above has not been addressed. @jonringer-comm – if you update a diff without addressing comments, you should hit "Plan Changes" to keep it off your reviewers' queues

This revision now requires changes to proceed.Jul 3 2022, 11:51 AM
jon marked an inline comment as done.

Lint

native/cpp/CommonCpp/CMakeLists.txt
14–32

Sorry about that, was trying to get CI good again

Awesome, resigning to let somebody else take a pass

Update with newer grpc target names

native/cpp/CommonCpp/CMakeLists.txt
14–32 ↗(On Diff #14371)

Parentheses and newlines again...

@jonringer-comm, we really have to get to a point where you're not putting up diffs with these issues. It's a waste of everybody's time for this to be discussed in code review. (I have shared this feedback previously here and here.)

Can you give this suggestion a read (adding a CMake Linter)? That might be the easiest way to resolve these issues going forward.

atul requested changes to this revision.Jul 14 2022, 10:50 AM

Nice, this looks super clean.

Will pretty much auto-Accept once parenthesis/newline issues are resolved

This revision now requires changes to proceed.Jul 14 2022, 10:50 AM
atul requested changes to this revision.EditedAug 11 2022, 12:05 PM

Ah dang, whatever changed after rebasing and whatnot is leading to the following when following the Test Plan:

/Users/atul/comm/native/cpp/CommonCpp/NativeModules/../CryptoTools/CryptoModule.h:7:10: fatal error: 'olm/olm.h' file not found
#include "olm/olm.h"
         ^~~~~~~~~~~
1 error generated.
make[2]: *** [NativeModules/CMakeFiles/comm-modules-native.dir/CommCoreModule.cpp.o] Error 1
make[1]: *** [NativeModules/CMakeFiles/comm-modules-native.dir/all] Error 2
make: *** [all] Error 2
This revision now requires changes to proceed.Aug 11 2022, 12:05 PM
jon edited the test plan for this revision. (Show Details)
jon removed a reviewer: ashoat.
jon marked an inline comment as done.
[ 96%] Linking CXX static library libcomm-modules-native.a
[ 96%] Built target comm-modules-native
1 warning generated.
[100%] Linking CXX static library libcomm-client.a
[100%] Built target comm-client
This revision is now accepted and ready to land.Aug 30 2022, 3:27 PM