CMakeLists.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. cmake_minimum_required(VERSION 3.0)
  2. # Setup the project.
  3. # Its name is defined to be the controller directory name.
  4. get_filename_component(PROJECT ${CMAKE_SOURCE_DIR} NAME)
  5. project(${PROJECT})
  6. # Get C or C++ sources in the current directory (only).
  7. file(GLOB C_SOURCES *.c)
  8. file(GLOB CPP_SOURCES *.cpp)
  9. set(SOURCES ${C_SOURCES} ${CPP_SOURCES})
  10. # Set the Webots home path (change it according to your installation method)
  11. set(WEBOTS_HOME "/usr/local/webots")
  12. #set(WEBOTS_HOME "/snap/webots/current/usr/share/webots")
  13. FIND_PACKAGE(Protobuf REQUIRED)
  14. # Link with the Webots controller library.
  15. link_directories($ENV{WEBOTS_HOME}/lib/controller)
  16. set (LIBRARIES m ${CMAKE_SHARED_LIBRARY_PREFIX}Controller${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_SHARED_LIBRARY_PREFIX}CppController${CMAKE_SHARED_LIBRARY_SUFFIX})
  17. include_directories(
  18. /usr/local/webots/include/controller/cpp
  19. )
  20. # Setup the target executable.
  21. add_executable(${PROJECT} ${SOURCES}
  22. timedlockdata.hpp
  23. emqx-client/paho_client.cpp
  24. emqx-client/mqttmsg.cpp
  25. emqx-client/message.pb.cc)
  26. target_link_libraries(${PROJECT} ${LIBRARIES}
  27. paho-mqtt3a
  28. ${GLOG_LIBRARIES} ${PROTOBUF_LIBRARIES}
  29. libglog.a libgflags.a
  30. )
  31. # Copy the target executable at the right location.
  32. add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E
  33. copy ${CMAKE_BINARY_DIR}/${PROJECT} ${CMAKE_SOURCE_DIR}
  34. )