Skip to content

CMake integration for all 14 examples#245

Merged
mbarger99 merged 50 commits into
aphysci:masterfrom
FlinkerBluid:master
Aug 4, 2025
Merged

CMake integration for all 14 examples#245
mbarger99 merged 50 commits into
aphysci:masterfrom
FlinkerBluid:master

Conversation

@FlinkerBluid

Copy link
Copy Markdown
Contributor

All 14 examples should now work with CMake. Note: You will have to source your own protobuf jar file, and tell CMake where it is.

@mbarger99 mbarger99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have more to go through here, but it looks great so far.

Comment thread cmake/FindZeroMQ.cmake Outdated
Comment thread src/api/java/CMakeLists.txt Outdated

# TODO check GRAVITY_USING_EXTERNAL_PROTOBUF
set(PUBLIC_JAR "/usr/share/java/protobuf.jar" "${Protobuf_SRC_ROOT_FOLDER}/java/target/protobuf-java-${Protobuf_VERSION}.jar")
set(PUBLIC_JAR "${JAVA_PROTOBUF_JAR}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should at least include the second element (Protobuf_SRC_ROOT_FOLDER...) here so that people don't have to specify JAVA_PROTOBUF_JAR if they've already specified Protobuf_SRC_ROOT_FOLDER. @JBBee, is the /user/share location a standard location that we should also keep here? Maybe it would make sense to set the /user/share path as the default for JAVA_PROTOBUF_JAR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for now, will see what Justin says.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbarger99 @FlinkerBluid sorry for the delay here - let's see, I see this is outdated now. Are you still waiting on any input from me here? If so, I'm not sure I completely understand the question. Feel free to hit me up in the chat.

Comment thread src/api/java/CMakeLists.txt Outdated
Comment thread test/examples/1-BasicDataProduct/CMakeLists.txt Outdated
Comment thread test/examples/10-Archiving/ArchiveTest.cpp
EXAMPLE_BIN_DIR=@GravityExamples_BINARY_DIR@
SD_BIN_DIR=@ServiceDirectory_BINARY_DIR@

export PATH=$PATH:../../../src/components/cpp/bin

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of specifying paths for every executable below, I think it would be easier to read if we updated the PATH here with those folders, and then invoked them with no path like before. This applies to all the run.sh files.

Comment thread test/examples/10-Archiving/CMakeLists.txt Outdated
SD_BIN_DIR=@ServiceDirectory_BINARY_DIR@

export PATH=$PATH:../../../src/components/cpp/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../../../src/api/cpp:../../../src/keyvalue_parser:$ZMQ_LIB_DIR:$PROTOBUF_LIB_DIR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also update these relative paths to use a cmake var in case they ever move.

Comment thread test/examples/11-PythonPubSub/pypub.py Outdated
import time

from gravity import GravityNode, GravityDataProduct, gravity, GravitySubscriber, Log
from gravity import GravityNode, GravityDataProduct, gravity, GravitySubscriber, SpdLog

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You made the right fix here to convert the old code to spdlog, but we can further improve this by using SpdLogHandler - that funnels logs from the Python logger to the Gravity log. Would be good to use that here instead.



gravity_protobuf_generate(APPEND_PATH LANGUAGE python PROTOC_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}" GENERATE_EXTENSIONS .py OUT_VAR SRCS PROTOS ${PROTO_FILES})
gravity_protobuf_generate(APPEND_PATH LANGUAGE python PROTOC_OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}" GENERATE_EXTENSIONS .py OUT_VAR SRCS PROTOS ${PROTO_FILES})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will generate the protobufs in the source directory rather than the binary directory right? We want to keep generated files (aside from run.sh) under build and out of the source tree - is there a need to change this?

import time
import gravity
from gravity import GravityNode, GravityDataProduct, gravity, GravityRequestor, GravityServiceProvider, Log
from gravity import GravityNode, GravityDataProduct, gravity, GravityRequestor, GravityServiceProvider, SpdLog

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See SpdLogHandler comment above. Would be good to change that here too.

Comment thread test/examples/13-Relay/CMakeLists.txt Outdated
@mbarger99 mbarger99 requested a review from JBBee July 25, 2025 17:57
@mbarger99 mbarger99 requested a review from cbrundick July 25, 2025 17:57
Comment thread CMakeLists.txt
set(JAVA_HOME "" CACHE PATH "Path to JDK to use")
set(Protobuf_SRC_ROOT_FOLDER "" CACHE PATH "Path to Protobuf source build")
set(ZMQ_HOME "" CACHE PATH "Path to your local ZeroMQ installation")
set(JAVA_PROTOBUF_JAR "/usr/share/java/protobuf.jar" CACHE PATH "Location of protobuf jar file")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me - making it a cache variable with a default, you can over-ride from the command line if necessary

@mbarger99 mbarger99 merged commit 20d197c into aphysci:master Aug 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants