Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

Commit 0e6346f

Browse files
authored
Merge pull request #34 from forno/upgrade/v1.3.0
Upgrade to v1.3.0
2 parents 71b2ee9 + f115b38 commit 0e6346f

24 files changed

+981
-942
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
build/
2-
bin/
3-
**/*.swp
1+
/build
2+
Makefile
3+
*.swp

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "thirdpatry/googletest"]
2+
path = thirdpatry/googletest
3+
url = https://github.com/google/googletest.git
4+
ignore = dirty

.travis.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
language: cpp
2-
sudo: false
3-
dist: trusty
42
group: beta
3+
dist: trusty
4+
sudo: false
55
compiler:
6-
- g++
7-
- clang++
6+
- g++
7+
- clang++
8+
before_install:
9+
- cd thirdpatry/googletest/googletest
10+
- cmake -DCMAKE_BUILD_TYPE=RELEASE .
11+
- make
12+
- cd -
13+
- mkdir build
14+
- cd build
815
install:
9-
- make
10-
- mkdir cbuild
11-
- cd cbuild
12-
- cmake .. -DCMAKE_INSTALL_PREFIX=install
13-
- make
14-
- make install
15-
- cd ..
16+
- cmake .. -DCMAKE_INSTALL_PREFIX=install -DENABLE_TEST=ON
17+
- make
18+
- make install
1619
script:
17-
./bin/test
20+
- ctest

CMakeLists.txt

Lines changed: 72 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,95 @@
1-
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.1)
2-
project(ics3 CXX)
3-
4-
SET(PROJECT_VER_MAJOR 1)
5-
SET(PROJECT_VER_MINOR 2)
6-
SET(PROJECT_VER_PATCH 6)
7-
SET(PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}")
8-
SET(PROJECT_APIVER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")
9-
10-
IF(NOT DEFINED CMAKE_BUILD_TYPE)
11-
# No effect for multi-configuration generators (e.g. for Visual Studio)
12-
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose: RelWithDebInfo Release Debug MinSizeRel None")
13-
ENDIF()
14-
15-
SET(MY_DIR ${ics3_SOURCE_DIR})
16-
17-
OPTION(BUILD_SHARED_LIBS "Build shared (ON) or static (OFF) libraries" ON)
18-
OPTION(ENABLE_CXX11 "Enable C++11 support" ON)
19-
20-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
21-
22-
SET(HAVE_CXX11 disabled)
23-
IF(ENABLE_CXX11)
24-
INCLUDE(CheckCXXCompilerFlag)
25-
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
26-
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
27-
IF(COMPILER_SUPPORTS_CXX11)
28-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
29-
SET(LIBICS3_WITH_CXX11_SUPPORT 1)
30-
SET(HAVE_CXX11 yes)
31-
ELSEIF(COMPILER_SUPPORTS_CXX0X)
32-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
33-
SET(HAVE_CXX11 c++0x)
34-
ELSE()
35-
SET(HAVE_CXX11 no)
36-
MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
37-
ENDIF()
38-
ENDIF(ENABLE_CXX11)
1+
cmake_minimum_required(VERSION 2.8.12.1)
2+
project(ics3 C CXX)
3+
4+
set(PROJECT_VER_MAJOR 1)
5+
set(PROJECT_VER_MINOR 3)
6+
set(PROJECT_VER_PATCH 0)
7+
set(PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}")
8+
set(PROJECT_APIVER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")
9+
10+
if(NOT DEFINED CMAKE_BUILD_TYPE)
11+
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose: RelWithDebInfo Release Debug MinSizeRel None")
12+
endif()
13+
14+
option(BUILD_SHARED_LIBS "Build shared (ON) or static (OFF) libraries" ON)
15+
option(ENABLE_TEST "Enable test program building" OFF)
16+
17+
set(MY_DIR ${ics3_SOURCE_DIR})
18+
19+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
20+
21+
include(CheckCXXCompilerFlag)
22+
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
23+
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
24+
if(COMPILER_SUPPORTS_CXX11)
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
26+
elseif(COMPILER_SUPPORTS_CXX0X)
27+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
28+
else()
29+
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
30+
endif()
3931

4032
#set the default path for built executables to the "bin" directory
41-
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
33+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
4234

4335
#set the default path for built libraries to the "lib" directory
44-
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
45-
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
36+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
37+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
4638

4739
# Add includes
48-
INCLUDE_DIRECTORIES(
49-
"${MY_DIR}/include"
50-
${PROJECT_BINARY_DIR} # for generated headers
40+
include_directories(
41+
${MY_DIR}/include
5142
)
5243

53-
FILE(GLOB ICS3_SOURCES
44+
file(GLOB ICS3_SOURCES
5445
${MY_DIR}/src/*.cpp
5546
)
5647

57-
LIST(REMOVE_ITEM ICS3_SOURCES ${MY_DIR}/src/test.cpp)
58-
59-
FILE(GLOB ICS3_HEADERS
48+
file(GLOB ICS3_HEADERS
6049
${MY_DIR}/include/ics3/*.hpp
6150
${MY_DIR}/include/core.hpp
6251
)
6352

64-
SET(SOURCES
53+
set(SOURCES
6554
${ICS3_HEADERS}
6655
${ICS3_SOURCES}
6756
)
6857

69-
ADD_LIBRARY(ics3 ${SOURCES})
70-
SET_TARGET_PROPERTIES(ics3 PROPERTIES
58+
add_library(ics3 ${SOURCES})
59+
set_target_properties(ics3 PROPERTIES
7160
VERSION ${PROJECT_VER}
7261
SOVERSION ${PROJECT_APIVER}
7362
)
7463

75-
TARGET_LINK_LIBRARIES(ics3)
76-
INSTALL(TARGETS ics3 DESTINATION lib RUNTIME DESTINATION bin)
77-
INSTALL(DIRECTORY "${MY_DIR}/include/${PROJECT_NAME}" DESTINATION include)
78-
79-
GET_CMAKE_PROPERTY(vars VARIABLES)
80-
MESSAGE(STATUS "Feature list:")
81-
FOREACH(var ${vars})
82-
IF(var MATCHES ^HAVE_)
83-
STRING(REPLACE HAVE_ "" feature ${var})
84-
MESSAGE(STATUS " ${feature} ${${var}}")
85-
ENDIF()
86-
ENDFOREACH()
64+
target_link_libraries(ics3)
65+
66+
if(ENABLE_TEST)
67+
set(GTEST_ROOT ${MY_DIR}/thirdpatry/googletest/googletest)
68+
find_package(GTest REQUIRED)
69+
find_package(Threads)
70+
71+
include_directories(${GTEST_INCLUDE_DIRS})
72+
add_executable(integrate test/integrate.cpp)
73+
target_link_libraries(integrate ics3 ${GTEST_BOTH_LIBRARIES})
74+
if(THREADS_HAVE_PTHREAD_ARG)
75+
target_compile_options(PUBLIC integrate "-pthread")
76+
endif()
77+
if(CMAKE_THREAD_LIBS_INIT)
78+
target_link_libraries(integrate "${CMAKE_THREAD_LIBS_INIT}")
79+
endif()
80+
81+
enable_testing()
82+
add_test(AllTestInIntegrate ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/integrate)
83+
endif()
84+
85+
install(TARGETS ics3 DESTINATION lib RUNTIME DESTINATION bin)
86+
install(DIRECTORY "${MY_DIR}/include/${PROJECT_NAME}" DESTINATION include)
87+
88+
get_cmake_property(vars VARIABLES)
89+
message(STATUS "Feature list:")
90+
foreach(var ${vars})
91+
if(var MATCHES ^HAVE_)
92+
string(REPLACE HAVE_ "" feature ${var})
93+
message(STATUS " ${feature} ${${var}}")
94+
endif()
95+
endforeach()

Makefile

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ ex)[KRS series servo moters produced by KONDO KAGAKU co., ltd.](http://kondo-rob
1111
1. This software require c++11 compiler. In ubuntu 14.04 or after version have compiler support c++11.
1212
2. This software only support serial mode. You should lock the serial mode for never turn on PWM mode.
1313
3. Linux need serial device that mounted for use it. `script/setup.sh` will mount it to `/dev/ttyUSB0`.
14-
4. The Makefile for debuging. You should take CMake for installation.
1514

1615
## API Reference
1716
Reference [the libics3 wiki](https://github.com/forno/libics3/wiki)

include/core.hpp renamed to include/core.h

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,43 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2424
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2525
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626
*/
27-
#ifndef LIBICS3_ICS3_CORE_H_
28-
#define LIBICS3_ICS3_CORE_H_
29-
30-
#include<array>
31-
#include<memory>
32-
#include<string>
33-
#include<vector>
34-
#include<termios.h>
35-
36-
namespace ics {
37-
class Core {
38-
public:
39-
using value_type = uint8_t;
40-
using Container = std::vector<value_type>;
41-
using IDContainerTx = std::array<value_type, 4>;
42-
using IDContainerRx = std::array<value_type, 5>;
43-
explicit Core(const std::string&, speed_t); // touch by only libics3
44-
~Core() noexcept;
45-
Core(const Core&) = delete;
46-
Core& operator=(const Core&) = delete;
47-
Core(Core&&) noexcept;
48-
Core& operator=(Core&&) noexcept;
49-
50-
static std::shared_ptr<Core> getCore(const std::string&, speed_t);
51-
void communicate(const Container&, Container&);
52-
void communicateID(const IDContainerTx&, IDContainerRx&);
53-
private:
54-
void closeThis() const noexcept;
55-
56-
static termios getTermios() noexcept;
57-
58-
int fd;
59-
termios oldTio;
60-
};
27+
#ifndef LIBICS3_ICS3_CORE_H
28+
#define LIBICS3_ICS3_CORE_H
29+
30+
#include <array>
31+
#include <memory>
32+
#include <string>
33+
#include <vector>
34+
35+
#include <termios.h>
36+
37+
namespace ics
38+
{
39+
class Core
40+
{
41+
public:
42+
using value_type = uint8_t;
43+
using Container = std::vector<value_type>;
44+
using IDContainerTx = std::array<value_type, 4>;
45+
using IDContainerRx = std::array<value_type, 5>;
46+
explicit Core(const std::string&, speed_t); // touch by only libics3
47+
~Core() noexcept;
48+
Core(const Core&) = delete;
49+
Core& operator=(const Core&) = delete;
50+
Core(Core&&) noexcept;
51+
Core& operator=(Core&&) noexcept;
52+
53+
static std::shared_ptr<Core> getCore(const std::string&, speed_t);
54+
void communicate(const Container&, Container&);
55+
void communicateID(const IDContainerTx&, IDContainerRx&);
56+
private:
57+
void closeThis() const noexcept;
58+
59+
static termios getTermios() noexcept;
60+
61+
int fd;
62+
termios oldTio;
63+
};
6164
}
6265

63-
#endif // LIBICS3_ICS3_CORE_H_
66+
#endif // LIBICS3_ICS3_CORE_H

0 commit comments

Comments
 (0)