Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions Workflow & Basic Window Support #18

Open
wants to merge 10 commits into
base: cpp_standalone
Choose a base branch
from
61 changes: 61 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build

on:
- push

jobs:

linux:
name: 🐧 Linux
runs-on: ubuntu-latest

steps:

- name: Checkout repository
uses: actions/checkout@master

- name: Install Boost
run: sudo apt-get install libboost-all-dev ninja-build

- name: Configure CMake project
run: cmake -B build -G Ninja

- name: Build driver
run: cmake --build build

mac:
name: 🍏 macOS
runs-on: macos-latest

steps:

- name: Checkout repository
uses: actions/checkout@master

- name: Install Boost
run: brew install boost ninja

- name: Configure CMake project
run: cmake -B build -G Ninja

- name: Build driver
run: cmake --build build

windows:

name: 🪟 Windows
runs-on: windows-latest

steps:

- name: Checkout repository
uses: actions/checkout@master

- name: Install Boost
run: choco install boost-msvc-14.3

- name: Configure CMake project
run: cmake -B build

- name: Build driver
run: cmake --build build
41 changes: 27 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 2.8.12)
project(sick_safetyscanners_base CXX)

## Use C++11
#add_definitions(-std=c++11 -Wall)
## By adding -Wall and -Werror, the compiler does not ignore warnings anymore,
## enforcing cleaner code.
add_definitions(-std=c++11 -Wall -Werror)

set(CMAKE_CXX_STANDARD 11)

if(CMAKE_GENERATOR MATCHES "Visual Studio")
add_definitions(-D_WIN32_WINNT=0x0601) # Target Windows 7 and later
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
else(CMAKE_GENERATOR MATCHES "Visual Studio")
# By adding -Wall and -Werror, the compiler does not ignore warnings anymore,
# enforcing cleaner code.
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Currently the code does not work without warnings when we use Clang/LLVM:
# - https://github.com/SICKAG/sick_safetyscanners_base/issues/9
add_definitions(-Wall)
else(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_definitions(-Wall -Werror)
endif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif(CMAKE_GENERATOR MATCHES "Visual Studio")

## Find system libraries
find_package(Boost REQUIRED COMPONENTS system thread chrono)
Expand Down Expand Up @@ -117,9 +126,12 @@ add_library(sick_safetyscanners_base SHARED
src/datastructure/UserName.cpp
)

target_compile_options(sick_safetyscanners_base
PUBLIC ${CXX11_FLAG}
PRIVATE -Wall)
if(NOT (CMAKE_GENERATOR MATCHES "Visual Studio"))
target_compile_options(
sick_safetyscanners_base
PUBLIC ${CXX11_FLAG}
PRIVATE -Wall)
endif(NOT (CMAKE_GENERATOR MATCHES "Visual Studio"))

option(USE_ROS_LOGGING "Use ROS Logging instead of printf" OFF)

Expand All @@ -134,8 +146,9 @@ target_include_directories(sick_safetyscanners_base PUBLIC
${Boost_INCLUDE_DIR}
)

target_link_libraries(sick_safetyscanners_base PUBLIC ${Boost_LIBRARIES}
)
target_link_libraries(
sick_safetyscanners_base PUBLIC Boost::system Boost::thread Boost::chrono
Boost::dynamic_linking)

add_library(sick_safetyscanners_base::sick_safetyscanners_base ALIAS sick_safetyscanners_base)

Expand Down Expand Up @@ -164,7 +177,7 @@ install(
install(
DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME}
FILES_MATCHING
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
)
Expand Down
9 changes: 8 additions & 1 deletion include/sick_safetyscanners_base/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@

namespace sick {

#ifdef _WIN32_WINNT
typedef struct timeval {
long tv_sec;
long tv_usec;
} TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
#endif

/*!
* \brief Represents a generic runtime error.
*
Expand Down Expand Up @@ -172,4 +179,4 @@ class timeout_error : public runtime_error
std::string msg_;
};
} // namespace sick
#endif // ifndef SICK_SAFETYSCANNERS_BASE_EXCEPTIONS_H
#endif // ifndef SICK_SAFETYSCANNERS_BASE_EXCEPTIONS_H