123456789101112131415161718192021222324252627282930313233343536373839 |
- cmake_minimum_required(VERSION 3.0)
- # Setup the project.
- # Its name is defined to be the controller directory name.
- get_filename_component(PROJECT ${CMAKE_SOURCE_DIR} NAME)
- project(${PROJECT})
- # Get C or C++ sources in the current directory (only).
- file(GLOB C_SOURCES *.c)
- file(GLOB CPP_SOURCES *.cpp)
- set(SOURCES ${C_SOURCES} ${CPP_SOURCES})
- # Set the Webots home path (change it according to your installation method)
- set(WEBOTS_HOME "/usr/local/webots")
- #set(WEBOTS_HOME "/snap/webots/current/usr/share/webots")
- FIND_PACKAGE(Protobuf REQUIRED)
- # Link with the Webots controller library.
- link_directories($ENV{WEBOTS_HOME}/lib/controller)
- set (LIBRARIES m ${CMAKE_SHARED_LIBRARY_PREFIX}Controller${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_SHARED_LIBRARY_PREFIX}CppController${CMAKE_SHARED_LIBRARY_SUFFIX})
- include_directories(
- /usr/local/webots/include/controller/cpp
- )
- # Setup the target executable.
- add_executable(${PROJECT} ${SOURCES}
- timedlockdata.hpp
- emqx-client/paho_client.cpp
- emqx-client/mqttmsg.cpp
- emqx-client/message.pb.cc)
- target_link_libraries(${PROJECT} ${LIBRARIES}
- paho-mqtt3a
- ${GLOG_LIBRARIES} ${PROTOBUF_LIBRARIES}
- libglog.a libgflags.a
- )
- # Copy the target executable at the right location.
- add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E
- copy ${CMAKE_BINARY_DIR}/${PROJECT} ${CMAKE_SOURCE_DIR}
- )
|