From d0ad1c6a9a540e3d74bc759b2eee3bf628bb5176 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Wed, 3 Jul 2019 13:24:15 -0700 Subject: [PATCH 1/2] Convert package to a pure CMake package cherry-picking commit 4d5be00 from @cottsay See: https://github.com/wjwwood/serial/pull/209#issuecomment-520018303 Author: Scott K Logan Date: Wed Jul 3 13:24:15 2019 -0700 Conflicts: CMakeLists.txt package.xml tests/CMakeLists.txt Signed-off-by: Alex Moriarty --- CMakeLists.txt | 40 +++++++++++++++------------------------- Makefile | 4 ++-- cmake/serialConfig.cmake | 3 +++ package.xml | 9 ++++++++- tests/CMakeLists.txt | 15 +++++++++++---- 5 files changed, 39 insertions(+), 32 deletions(-) create mode 100644 cmake/serialConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4927020..230d99f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,31 +1,11 @@ cmake_minimum_required(VERSION 2.8.3) project(serial) -# Find catkin -find_package(catkin REQUIRED) - if(APPLE) find_library(IOKIT_LIBRARY IOKit) find_library(FOUNDATION_LIBRARY Foundation) endif() -if(UNIX AND NOT APPLE) - # If Linux, add rt and pthread - set(rt_LIBRARIES rt) - set(pthread_LIBRARIES pthread) - catkin_package( - LIBRARIES ${PROJECT_NAME} - INCLUDE_DIRS include - DEPENDS rt pthread - ) -else() - # Otherwise normal call - catkin_package( - LIBRARIES ${PROJECT_NAME} - INCLUDE_DIRS include - ) -endif() - ## Sources set(serial_SRCS src/serial.cc @@ -66,16 +46,26 @@ include_directories(include) ## Install executable install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin ) ## Install headers install(FILES include/serial/serial.h include/serial/v8stdint.h - DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial) + DESTINATION include/serial) + +## Install CMake config +install(FILES cmake/serialConfig.cmake + DESTINATION share/serial/cmake) + + +## Install package.xml +install(FILES package.xml + DESTINATION share/serial) ## Tests -if(CATKIN_ENABLE_TESTING) +include(CTest) +if(BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/Makefile b/Makefile index e172072..0f49ddc 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ test: @mkdir -p build cd build && cmake $(CMAKE_FLAGS) .. ifneq ($(MAKE),) - cd build && $(MAKE) run_tests + cd build && $(MAKE) all test else - cd build && make run_tests + cd build && make all test endif diff --git a/cmake/serialConfig.cmake b/cmake/serialConfig.cmake new file mode 100644 index 0000000..e90bdf6 --- /dev/null +++ b/cmake/serialConfig.cmake @@ -0,0 +1,3 @@ +get_filename_component(SERIAL_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(SERIAL_INCLUDE_DIRS "${SERIAL_CMAKE_DIR}/../../../include") +find_library(SERIAL_LIBRARIES serial PATHS ${SERIAL_CMAKE_DIR}/../../../lib/serial) diff --git a/package.xml b/package.xml index 959f9b8..a63b88a 100644 --- a/package.xml +++ b/package.xml @@ -19,6 +19,13 @@ William Woodall John Harrison - catkin + cmake + + + gtest + + + cmake + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ac9a421..196885a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,12 +1,19 @@ if(UNIX) - catkin_add_gtest(${PROJECT_NAME}-test unix_serial_tests.cc) - target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) + find_package(GTest REQUIRED) + include_directories(${GTEST_INCLUDE_DIRS}) + + add_executable(${PROJECT_NAME}-test unix_serial_tests.cc) + target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME} ${GTEST_LIBRARIES}) if(NOT APPLE) target_link_libraries(${PROJECT_NAME}-test util) endif() + add_test("${PROJECT_NAME}-test-gtest" ${PROJECT_NAME}-test) if(NOT APPLE) # these tests are unreliable on macOS - catkin_add_gtest(${PROJECT_NAME}-test-timer unit/unix_timer_tests.cc) - target_link_libraries(${PROJECT_NAME}-test-timer ${PROJECT_NAME}) + add_executable(${PROJECT_NAME}-test-timer unit/unix_timer_tests.cc) + target_link_libraries(${PROJECT_NAME}-test-timer ${PROJECT_NAME} ${GTEST_LIBRARIES}) + add_test("${PROJECT_NAME}-test-timer-gtest" ${PROJECT_NAME}-test-timer) endif() + # Boost is only required for tests/proof_of_concepts which are not enabled by default + # find_package(Boost REQUIRED) endif() From 60ef057aec89f3911f4737f6152a8325c5b5e927 Mon Sep 17 00:00:00 2001 From: Alex Moriarty Date: Tue, 18 Jul 2023 11:29:28 -0300 Subject: [PATCH 2/2] GitHub CI cmake build test linux - Adds Minimal github action ci for linux - Adds myself as maintainer Signed-off-by: Alex Moriarty --- .github/workflows/ci.yaml | 35 +++++++++++++++++++++++++++++++++++ package.xml | 1 + 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..0ec0899 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,35 @@ +name: CMake CI + +on: + # Run workflow on-demand + workflow_dispatch: + # Run workflow on pushes on all branches + push: + +# Run only one workflow per branch at a time +concurrency: + group: environment-${{ github.ref }} + cancel-in-progress: true + +# TODO(moriarty) +# matrix job to test windows and macos +# Requires installing gtest via choco and brew +jobs: + cmake_build_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: lukka/get-cmake@latest + - name: Install gtest with apt + run: | + sudo apt-get update + sudo apt-get install -y libgtest-dev + - name: Run CMake + run: | + cmake -B build + - name: Run make + run: | + make -C build + - name: Run make test + run: | + make -C build test diff --git a/package.xml b/package.xml index a63b88a..cf2a7b0 100644 --- a/package.xml +++ b/package.xml @@ -9,6 +9,7 @@ William Woodall + Alex Moriarty MIT