|
| 1 | +cmake_minimum_required(VERSION 2.8.3) |
| 2 | +project(march_hardware) |
| 3 | + |
| 4 | +add_compile_options(-std=c++11) |
| 5 | + |
| 6 | +find_package(catkin REQUIRED COMPONENTS |
| 7 | + roscpp |
| 8 | + roslint |
| 9 | + soem |
| 10 | +) |
| 11 | + |
| 12 | +catkin_package( |
| 13 | + INCLUDE_DIRS include |
| 14 | + CATKIN_DEPENDS |
| 15 | + LIBRARIES ${PROJECT_NAME} |
| 16 | +) |
| 17 | + |
| 18 | +set(ROSLINT_CPP_OPTS "--filter=-build/include,-build/header_guard,-runtime/references" "--linelength=120") |
| 19 | + |
| 20 | +file(GLOB_RECURSE lintfiles |
| 21 | + "src/*.cpp" |
| 22 | + "include/*.h" |
| 23 | +) |
| 24 | + |
| 25 | +roslint_cpp(${lintfiles}) |
| 26 | + |
| 27 | + |
| 28 | +include_directories( |
| 29 | + include |
| 30 | + ${catkin_INCLUDE_DIRS} |
| 31 | + ${soem_INCLUDE_DIRS}/soem |
| 32 | +) |
| 33 | + |
| 34 | +install(DIRECTORY include/${PROJECT_NAME}/ |
| 35 | + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} |
| 36 | +) |
| 37 | + |
| 38 | +add_library(${PROJECT_NAME} |
| 39 | + include/${PROJECT_NAME}/ActuationMode.h |
| 40 | + include/${PROJECT_NAME}/AngleConversions.h |
| 41 | + include/${PROJECT_NAME}/BootShutdownOffsets.h |
| 42 | + include/${PROJECT_NAME}/Encoder.h |
| 43 | + include/${PROJECT_NAME}/EtherCAT/EthercatIO.h |
| 44 | + include/${PROJECT_NAME}/EtherCAT/EthercatMaster.h |
| 45 | + include/${PROJECT_NAME}/EtherCAT/EthercatSDO.h |
| 46 | + include/${PROJECT_NAME}/HighVoltage.h |
| 47 | + include/${PROJECT_NAME}/IMotionCube.h |
| 48 | + include/${PROJECT_NAME}/IMotionCubeState.h |
| 49 | + include/${PROJECT_NAME}/IMotionCubeTargetState.h |
| 50 | + include/${PROJECT_NAME}/Joint.h |
| 51 | + include/${PROJECT_NAME}/LowVoltage.h |
| 52 | + include/${PROJECT_NAME}/MarchRobot.h |
| 53 | + include/${PROJECT_NAME}/NetDriverOffsets.h |
| 54 | + include/${PROJECT_NAME}/PDOmap.h |
| 55 | + include/${PROJECT_NAME}/PowerDistributionBoard.h |
| 56 | + include/${PROJECT_NAME}/Slave.h |
| 57 | + include/${PROJECT_NAME}/TemperatureGES.h |
| 58 | + include/${PROJECT_NAME}/TemperatureSensor.h |
| 59 | + src/Encoder.cpp |
| 60 | + src/EtherCAT/EthercatIO.cpp |
| 61 | + src/EtherCAT/EthercatMaster.cpp |
| 62 | + src/EtherCAT/EthercatSDO.cpp |
| 63 | + src/HighVoltage.cpp |
| 64 | + src/IMotionCube.cpp |
| 65 | + src/IMotionCubeTargetState.cpp |
| 66 | + src/Joint.cpp |
| 67 | + src/LowVoltage.cpp |
| 68 | + src/MarchRobot.cpp |
| 69 | + src/PDOmap.cpp |
| 70 | + src/PowerDistributionBoard.cpp |
| 71 | + src/TemperatureGES.cpp |
| 72 | +) |
| 73 | + |
| 74 | +target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES}) |
| 75 | + |
| 76 | +add_executable(slave_count_check check/SlaveCount.cpp) |
| 77 | +target_link_libraries(slave_count_check ${PROJECT_NAME}) |
| 78 | + |
| 79 | +install(TARGETS ${PROJECT_NAME} |
| 80 | + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} |
| 81 | + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} |
| 82 | +) |
| 83 | + |
| 84 | +install(TARGETS slave_count_check |
| 85 | + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} |
| 86 | +) |
| 87 | + |
| 88 | +## Add gtest based cpp test target and link libraries |
| 89 | +if (CATKIN_ENABLE_TESTING) |
| 90 | + find_package(code_coverage REQUIRED) |
| 91 | + find_package(rostest REQUIRED) |
| 92 | + |
| 93 | + if(ENABLE_COVERAGE_TESTING) |
| 94 | + include(CodeCoverage) |
| 95 | + append_coverage_compiler_flags() |
| 96 | + endif() |
| 97 | + |
| 98 | + add_rostest_gmock(${PROJECT_NAME}-test |
| 99 | + test/march4cpp.test |
| 100 | + test/TestRunner.cpp |
| 101 | + test/TestEncoder.cpp |
| 102 | + test/TestIMotionCube.cpp |
| 103 | + test/TestTemperatureGES.cpp |
| 104 | + test/TestJoint.cpp |
| 105 | + test/TestPDOmap.cpp |
| 106 | + test/TestBootShutdownOffsets.cpp |
| 107 | + test/TestNetDriverOffsets.cpp |
| 108 | + test/TestNetMonitorOffsets.cpp |
| 109 | + test/TestLowVoltage.cpp |
| 110 | + test/TestHighVoltage.cpp |
| 111 | + test/TestPowerDistributionBoard.cpp |
| 112 | + test/mocks/MockTemperatureGES.cpp |
| 113 | + test/mocks/MockTemperatureSensor.cpp |
| 114 | + test/mocks/MockEncoder.cpp |
| 115 | + test/mocks/MockIMotionCube.cpp |
| 116 | + test/mocks/MockJoint.cpp |
| 117 | + ) |
| 118 | + target_link_libraries(${PROJECT_NAME}-test ${catkin_LIBRARIES} ${PROJECT_NAME} gtest) |
| 119 | + |
| 120 | + if(ENABLE_COVERAGE_TESTING) |
| 121 | + set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test*") |
| 122 | + add_code_coverage( |
| 123 | + NAME ${PROJECT_NAME}_coverage |
| 124 | + DEPENDS tests |
| 125 | + ) |
| 126 | + endif() |
| 127 | +endif () |
0 commit comments