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

Implement Cmake and Bazel bindings #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(rplidar_sdk)
set(CMAKE_CXX_STANDARD 17)

add_subdirectory(sdk/sdk)
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspace( name = "rp_lidar")
Empty file added sdk/BUILD
Empty file.
33 changes: 33 additions & 0 deletions sdk/sdk/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "rplidar_driver",
srcs = [
"src/rplidar_driver.cpp",
"src/hal/thread.cpp",
] + select({
"@bazel_tools//src/conditions:windows": glob(["src/arch/win32/*.cpp"]),
"//conditions:default": glob(["src/arch/linux/*.cpp"]),
}),
hdrs = glob(["include/*.h"]) + select({
"@bazel_tools//src/conditions:windows": glob(["src/arch/win32/*.hpp"]) + glob(["src/arch/win32/*.h"]),
"//conditions:default": glob(["src/arch/linux/*.hpp"]) + glob(["src/arch/linux/*.h"]),
}) + glob([
"src/*.h",
"src/hal/*.h",
]),
# NOTICE: Ugly hack is ugly, but required in builds that enable -werr
# NOTICE: mainly because there is magic in this lib I don't want to attempt to fix.
copts = [
"-Wno-unused-variable",
"-Wno-sign-compare",
"-Wno-unused-but-set-variable",
"-Wno-parentheses",
"-Wno-unused-result",
],
includes = [
"include",
"src",
],
visibility = ["//visibility:public"],
)
41 changes: 41 additions & 0 deletions sdk/sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.10)


file(GLOB base_sources src/*.cpp src/hal/*.cpp)
file(GLOB base_includes src/*.h src/*.hpp src/hal/*.h src/hal/*.hpp)

# Check if Windows, exclude MinGW
if (WIN32 AND NOT MINGW)
message(STATUS "Detected Windows target...")
file(GLOB platform_srcs src/arch/win32/*.hpp src/arch/win32/*.cpp)
include_directories(src/arch/win32)
elseif (MINGW)
# Library doesn't build under MinGW, no idea why.
message(FATAL_ERROR "Mingw is presently not supported.")
elseif (${CMAKE_SYSTEM_NAME} MATCHES Linux)
message(STATUS "linux target...")
file(GLOB platform_srcs src/arch/linux/*.hpp src/arch/linux/*.cpp)
include_directories(src/arch/linux)

elseif (${CMAKE_SYSTEM_NAME} MATCHES Darwin)
message(STATUS "Apple Mac OS X target...")
file(GLOB platform_srcs src/arch/macOS/*.hpp src/arch/macOS/*.cpp)
include_directories(src/arch/macOS)
else ()
message(FATAL_ERROR "Unknown platform ${CMAKE_SYSTEM_NAME}, build cannot continue.")
endif ()

# glob shared C++ sources
add_library(rplidar_sdk STATIC ${base_sources} ${platform_srcs})

target_include_directories(
rplidar_sdk INTERFACE include src
)

include_directories(src src/hal include)

install(
TARGETS rplidar_sdk
DESTINATION .
)

2 changes: 1 addition & 1 deletion sdk/sdk/src/rplidar_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,7 @@ u_result RPlidarDriverImplCommon::startMotor()
}
}
else {
setLidarSpinSpeed(600);//set default rpm to tof lidar
return setLidarSpinSpeed(600);//set default rpm to tof lidar
}

}
Expand Down