Skip to content

Commit

Permalink
Modernize cmake (#244)
Browse files Browse the repository at this point in the history
Modernize CMake of the client library with regards to

- Properly set C++17 flag using target_compile_features
- Properly include googletest e.g. using
[CMakeFetchContent](https://google.github.io/googletest/quickstart-cmake.html#set-up-a-project)

These proposed changes should make this project easier to maintain and
build in different environments.
  • Loading branch information
urfeex authored Jan 14, 2025
1 parent 00a2e4f commit 93ded01
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 446 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ jobs:
run: |
scripts/start_ursim.sh -m $ROBOT_MODEL -v $URSIM_VERSION -p $PROGRAM_FOLDER -d
env: ${{matrix.env}}
- name: install gtest
run: sudo apt-get install -y libgtest-dev
- name: install boost
run: sudo apt-get install -y libboost-dev
- name: configure
run: mkdir build && cd build && cmake .. -DBUILDING_TESTS=1 -DINTEGRATION_TESTS=1 -DWITH_ASAN=ON
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/industrial-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ jobs:
ROS_DISTRO: ${{matrix.ROS_DISTRO.NAME}}
ROS_REPO: ${{matrix.ROS_REPO}}
CLANG_TIDY: true
CLANG_TIDY_ARGS: '--extra-arg=-std=c++17' # needed for Humble
13 changes: 2 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.14.0)
project(ur_client_library)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/" ${CMAKE_MODULE_PATH})

if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
message("${PROJECT_NAME}: You did not request a specific build type: selecting 'RelWithDebInfo'.")
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()

option(WITH_ASAN "Compile with address sanitizer support" OFF)

##
## Check C++11 support / enable global pedantic and Wall
##
include(DefineCXX17CompilerFlag)
DEFINE_CXX_17_COMPILER_FLAG(CXX17_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")

add_library(urcl SHARED
src/comm/tcp_socket.cpp
src/comm/tcp_server.cpp
Expand Down Expand Up @@ -52,7 +43,7 @@ add_library(urcl SHARED
)
add_library(ur_client_library::urcl ALIAS urcl)
target_compile_options(urcl PRIVATE -Wall -Wextra -Wno-unused-parameter)
target_compile_options(urcl PUBLIC ${CXX17_FLAG})
target_compile_features(urcl PUBLIC cxx_std_17)
if(WITH_ASAN)
target_compile_options(urcl PUBLIC -fsanitize=address)
target_link_options(urcl PUBLIC -fsanitize=address)
Expand Down
55 changes: 0 additions & 55 deletions CMakeModules/DefineCXX11CompilerFlag.cmake

This file was deleted.

55 changes: 0 additions & 55 deletions CMakeModules/DefineCXX14CompilerFlag.cmake

This file was deleted.

55 changes: 0 additions & 55 deletions CMakeModules/DefineCXX17CompilerFlag.cmake

This file was deleted.

15 changes: 0 additions & 15 deletions CMakeModules/FindGTest.CMakeLists.txt.in

This file was deleted.

128 changes: 0 additions & 128 deletions CMakeModules/FindGTestPackage.cmake

This file was deleted.

Loading

0 comments on commit 93ded01

Please sign in to comment.