From fe92b8447162db3d007d6f12a3c3d33a2c02e468 Mon Sep 17 00:00:00 2001 From: Peta Carlyle Date: Sat, 19 Jun 2021 11:50:07 +1000 Subject: [PATCH] Adds mac build support --- cmake/Modules/Findwebots.cmake | 24 +++++++++++++++-- .../teleport_controller/CMakeLists.txt | 27 ++++++++----------- shared/message/CMakeLists.txt | 1 + 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/cmake/Modules/Findwebots.cmake b/cmake/Modules/Findwebots.cmake index 13610b9f7..b3e91df85 100644 --- a/cmake/Modules/Findwebots.cmake +++ b/cmake/Modules/Findwebots.cmake @@ -42,14 +42,34 @@ if(NOT webots_FOUND) mark_as_advanced(webots_${lib}_LIBRARY) endforeach(lib ${webots_libraries}) - # Link all of our imported targets to our imported library + # Find the webots robotis libraries + set(robotis_libraries "robotis-op2;managers") + foreach(lib ${robotis_libraries}) + find_library( + "webots_robotis_${lib}_LIBRARY" + NAMES ${lib} + PATHS ${WEBOTS_HOME}/projects/robots/robotis/darwin-op/libraries + PATH_SUFFIXES robotis-op2 managers + DOC "The Webots Robotis (${lib}) library" + ) + + # Setup an imported target for this library + add_library(webots::robotis::${lib} UNKNOWN IMPORTED) + set_target_properties(webots::robotis::${lib} PROPERTIES IMPORTED_LOCATION ${webots_robotis_${lib}_LIBRARY}) + + # Setup and export our variables + set(required_vars ${required_vars} "webots_robotis_${lib}_LIBRARY") + list(APPEND webots_LIBRARIES webots::robotis::${lib}) + mark_as_advanced(webots_robotis_${lib}_LIBRARY) + endforeach(lib ${webots_libraries}) + add_library(webots::webots INTERFACE IMPORTED) target_link_libraries(webots::webots INTERFACE ${webots_LIBRARIES}) # Make sure the libraries exist in the parent scope set(webots_LIBRARIES ${webots_LIBRARIES}) - # Find our include path + # Find our webots include path find_path( "webots_INCLUDE_DIR" NAMES "webots/Robot.hpp" diff --git a/controllers/teleport_controller/CMakeLists.txt b/controllers/teleport_controller/CMakeLists.txt index d1216132c..278bb8709 100644 --- a/controllers/teleport_controller/CMakeLists.txt +++ b/controllers/teleport_controller/CMakeLists.txt @@ -9,25 +9,20 @@ add_executable(teleport_controller ${controller_sources}) # Make sure we can find the utility folder target_include_directories(teleport_controller PRIVATE ${YAML_CPP_INCLUDE_DIRS}) target_include_directories(teleport_controller PRIVATE "${PROJECT_SOURCE_DIR}/shared") -target_include_directories( - teleport_controller PRIVATE "${WEBOTS_HOME}/projects/robots/robotis/darwin-op/libraries/managers/include" -) -target_include_directories( - teleport_controller PRIVATE "${WEBOTS_HOME}/projects/robots/robotis/darwin-op/libraries/managers" -) -target_include_directories( - teleport_controller - PRIVATE "${WEBOTS_HOME}/projects/robots/robotis/darwin-op/libraries/robotis-op2/robotis/Framework/include" -) +#target_include_directories( +# teleport_controller PRIVATE "${WEBOTS_HOME}/projects/robots/robotis/darwin-op/libraries/managers/include" +#) +#target_include_directories( +# teleport_controller PRIVATE "${WEBOTS_HOME}/projects/robots/robotis/darwin-op/libraries/managers" +#) +#target_include_directories( +# teleport_controller +# PRIVATE "${WEBOTS_HOME}/projects/robots/robotis/darwin-op/libraries/robotis-op2/robotis/Framework/include" +#) # Link against the webots target (this will also add any necessary include directories to our target) target_link_libraries(teleport_controller PRIVATE webots::webots) target_link_libraries(teleport_controller PRIVATE ${YAML_CPP_LIBRARIES}) -target_link_libraries( - teleport_controller PRIVATE ${WEBOTS_HOME}/projects/robots/robotis/darwin-op/libraries/robotis-op2/librobotis-op2.so -) -target_link_libraries( - teleport_controller PRIVATE ${WEBOTS_HOME}/projects/robots/robotis/darwin-op/libraries/managers/libmanagers.so -) + # Generate binary in controller source directory set_target_properties( teleport_controller PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_NAME teleport_controller diff --git a/shared/message/CMakeLists.txt b/shared/message/CMakeLists.txt index 202981a51..ead8f1692 100644 --- a/shared/message/CMakeLists.txt +++ b/shared/message/CMakeLists.txt @@ -27,6 +27,7 @@ add_library( messages_protobuf OBJECT "${PROJECT_BINARY_DIR}/shared/message/messages.pb.cc" "${PROJECT_BINARY_DIR}/shared/message/messages.pb.h" ) +target_link_libraries(messages_protobuf PRIVATE protobuf::libprotobuf) # Turn off clang-tidy for them set_target_properties(messages_protobuf PROPERTIES CXX_CLANG_TIDY "")