SHARE
TWEET

Untitled

a guest Apr 25th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Description: Webots Controller build using CMake.
  2. # Example: Copy CMakeLists.txt in $WEBOTS_HOME/projects/robots/gctronic/e-puck/controllers/e-puck/ and execute the following command:
  3. #     rm -fr build e-puck; mkdir build; cd build; cmake ..; make; cd ..
  4.  
  5. cmake_minimum_required(VERSION 3.0)
  6.  
  7. get_filename_component(PROJECT ${CMAKE_SOURCE_DIR} NAME)  # controller directory name
  8.  
  9. project(${PROJECT})
  10.  
  11. IF (WIN32)
  12.   link_directories($ENV{WEBOTS_HOME}/msys64/mingw64/bin)
  13. ELSE()
  14.   link_directories($ENV{WEBOTS_HOME}/lib)
  15. ENDIF()
  16.  
  17. file(GLOB C_SOURCES *.c)
  18. file(GLOB CPP_SOURCES *.cpp)
  19. set(SOURCES ${C_SOURCES} ${CPP_SOURCES})
  20.  
  21. if (NOT CPP_SOURCES STREQUAL "")  # Sources contain C++ files
  22.   set (LIBRARIES ${CMAKE_SHARED_LIBRARY_PREFIX}Controller${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_SHARED_LIBRARY_PREFIX}CppController${CMAKE_SHARED_LIBRARY_SUFFIX})
  23.   include_directories($ENV{WEBOTS_HOME}/include/controller/c $ENV{WEBOTS_HOME}/include/controller/cpp)
  24. else()  # C
  25.   set (LIBRARIES ${CMAKE_SHARED_LIBRARY_PREFIX}Controller${CMAKE_SHARED_LIBRARY_SUFFIX})
  26.   include_directories($ENV{WEBOTS_HOME}/include/controller/c)
  27. endif()
  28.  
  29. add_executable(${PROJECT} ${SOURCES})
  30.  
  31. target_link_libraries(${PROJECT} ${LIBRARIES})
  32.  
  33. add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E
  34.   copy ${CMAKE_BINARY_DIR}/${PROJECT} ${CMAKE_SOURCE_DIR}
  35. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top