Skip to content

Commit

Permalink
fix: INSTALL.md can now be followed to install grSim on macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leikoe committed Dec 31, 2023
1 parent f4fbd04 commit f3f5f70
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ target_include_directories(${app} PRIVATE ${VARTYPES_INCLUDE_DIRS})
list(APPEND libs ${VARTYPES_LIBRARIES})

# Protobuf
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
list(APPEND libs ${PROTOBUF_LIBRARIES})
find_package(protobuf CONFIG REQUIRED)
list(APPEND libs protobuf::libprotobuf)

set (Protobuf_IMPORT_DIRS ${Protobuf_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_CPP PROTO_H
if(protobuf_VERBOSE)
message(STATUS "Using Protocol Buffers ${protobuf_VERSION}")
endif()

set(PROTOS
src/proto/grSim_Commands.proto
src/proto/grSim_Packet.proto
src/proto/grSim_Replacement.proto
Expand Down Expand Up @@ -189,8 +191,7 @@ set(HEADERS
# files to be compiled
set(srcs
${CONFIG_FILES}
${PROTO_CPP}
${PROTO_H}
${PROTOS}
${RESOURCES}
${HEADERS}
${SOURCES}
Expand All @@ -203,6 +204,15 @@ target_sources(${app} PRIVATE ${srcs})
install(TARGETS ${app} DESTINATION bin)
target_link_libraries(${app} ${libs})

set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
file(MAKE_DIRECTORY ${PROTO_BINARY_DIR})
target_include_directories(${app} PUBLIC "$<BUILD_INTERFACE:${PROTO_BINARY_DIR}>")
protobuf_generate(
TARGET ${app}
IMPORT_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/proto"
PROTOC_OUT_DIR "${PROTO_BINARY_DIR}"
)

if(APPLE AND CMAKE_MACOSX_BUNDLE)
# use CMAKE_MACOSX_BUNDLE if you want to build a mac bundle
set(MACOSX_BUNDLE_ICON_FILE "${PROJECT_SOURCE_DIR}/resources/icons/grsim.icns")
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ brew install pkg-config
brew tap robotology/formulae
brew install robotology/formulae/ode
brew install qt
brew install protobuf
brew install protobuf@21
```

If you run into build issues, you may need to run this first:
Expand Down
35 changes: 20 additions & 15 deletions clients/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@ set(libs)
find_package(Qt5 COMPONENTS Core Widgets Network REQUIRED)
list(APPEND libs Qt5::Core Qt5::Widgets Qt5::Network)

find_package(protobuf CONFIG REQUIRED)
list(APPEND libs protobuf::libprotobuf)

find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
list(APPEND libs ${PROTOBUF_LIBRARIES})

protobuf_generate_cpp(PROTO_CPP PROTO_H
../../src/proto/grSim_Replacement.proto
../../src/proto/grSim_Commands.proto
../../src/proto/grSim_Packet.proto
)

set(app client)

add_executable(${app} MACOSX_BUNDLE
${PROTO_CPP}
${PROTO_H}
main.cpp
mainwindow.cpp
mainwindow.h
)
main.cpp
mainwindow.cpp
mainwindow.h
../../src/proto/grSim_Replacement.proto
../../src/proto/grSim_Commands.proto
../../src/proto/grSim_Packet.proto
)

target_link_libraries(${app} ${libs})

# Set the directory where the generated protobuf files will be placed
set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
file(MAKE_DIRECTORY ${PROTO_BINARY_DIR})
target_include_directories(${app} PUBLIC "$<BUILD_INTERFACE:${PROTO_BINARY_DIR}>")

# Generate the sources from the .proto files
protobuf_generate(
TARGET ${app}
IMPORT_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../src/proto"
PROTOC_OUT_DIR "${PROTO_BINARY_DIR}"
)

0 comments on commit f3f5f70

Please sign in to comment.