Skip to content

Commit

Permalink
Use CMake. (#39)
Browse files Browse the repository at this point in the history
* Use CMake instead of autotools.
* Add release build on Travis and deploy to the github release page.
  • Loading branch information
at-wat committed Jul 31, 2017
1 parent b249c47 commit 15fd8eb
Show file tree
Hide file tree
Showing 73 changed files with 931 additions and 95,276 deletions.
37 changes: 3 additions & 34 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
*.log
*~
*.o
*.a
*.bak
a.out
Makefile
.deps
config.status
config.h
stamp-h1
libtool
.libs
*.la
*.lo
samples/MOI-estimate
samples/cartesian2d-test
samples/run-test
src/ypspur-coordinator
src/ypspur-free
src/ypspur-interpreter
*.coff
*.mot
*.elf
autom4te.cache/
*.bz2
*.gz
*.zip
*.def
*.dll
*.lib
*.exe
*.patch
.spurip_history
*.swp
.lvimrc
build*
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ compiler: gcc

before_install:
- sudo apt-get update -y
- sudo apt-get install -y gcc-mingw-w64-x86-64 gcc-mingw-w64-i686
- sudo apt-get install -y gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 g++-mingw-w64-x86-64 g++-mingw-w64-i686
script:
- mkdir build && cd build && ../configure && make
- mkdir build && cd build && cmake ../ && make
- cd ../
- mkdir build-win64 && mkdir build-win64/install && cd build-win64 && ../configure CC='x86_64-w64-mingw32-gcc -m64 -static-libgcc' --enable-all-static --enable-shared --host=x86_64-w64-mingw32 --prefix=`pwd`/install && make && make install
- mkdir build-win64 && mkdir build-win64/install && cd build-win64 && cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw-x86_64.cmake -DCMAKE_INSTALL_PREFIX=`pwd`/install -DENABLE_ALL_STATIC=ON .. && make && make install
- cd ../
- mkdir build-win32 && mkdir build-win32/install && cd build-win32 && ../configure CC='i686-w64-mingw32-gcc -m32 -static-libgcc' --enable-all-static --enable-shared --host=i686-w64-mingw32 --prefix=`pwd`/install && make && make install
- mkdir build-win32 && mkdir build-win32/install && cd build-win32 && cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw-i686.cmake -DCMAKE_INSTALL_PREFIX=`pwd`/install -DENABLE_ALL_STATIC=ON .. && make && make install
- cd ../
before_deploy:
- sudo apt-get install -y npm
Expand All @@ -29,6 +29,10 @@ before_deploy:
- cd ../../
- cd build-win32/install/ && zip -q ../../packages/yp-spur.win32.$GIT_TAG.zip -r $(ls)
- cd ../../
- cd build-win64/ && zip -q ../packages/yp-spur-samples.win64.$GIT_TAG.zip -r samples/run-test.exe
- cd ../
- cd build-win32/ && zip -q ../packages/yp-spur-samples.win32.$GIT_TAG.zip -r samples/run-test.exe
- cd ../

deploy:
provider: releases
Expand All @@ -38,6 +42,8 @@ deploy:
file:
- packages/yp-spur.win64.$GIT_TAG.zip
- packages/yp-spur.win32.$GIT_TAG.zip
- packages/yp-spur-samples.win64.$GIT_TAG.zip
- packages/yp-spur-samples.win32.$GIT_TAG.zip
on:
tags: true

260 changes: 260 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
cmake_minimum_required(VERSION 3.0.2)
project(yp-spur
VERSION 1.14.0
)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules)

set(YP_VENDOR_NAME "OpenSpur.org")
set(YP_PRODUCT_NAME "Yamabico Project - Spur")
set(YP_PROTOCOL_NAME "YPP:09:03")
set(YP_PARAMS_DIR "robot-params")

option(USE_SSM "Compile with SSM if available." ON)

include(GetGitRevision)
get_git_revision()
set(PROJECT_VERSION_REV "${PROJECT_VERSION} (${GIT_REVISION_SHORT})")


# Find dependencies

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

find_package(PkgConfig)
if(PKGCONFIG_FOUND)
set(HAVE_PKG_CONFIG 1)
endif(PKGCONFIG_FOUND)

if(USE_SSM)
find_package(SSM)
endif(USE_SSM)

configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/include/config.h
)
add_definitions(-DHAVE_CONFIG_H=1)


# Set include dirs

include_directories(
${CMAKE_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_SOURCE_DIR}/auxlib
${CMAKE_SOURCE_DIR}/auxlib/formula-calc/include
)
if(SSM_FOUND)
include_directories(
${SSM_INCLUDE_DIRS}
)
endif(SSM_FOUND)


# Static link options

option(ENABLE_ALL_STATIC "Static link libgcc and libstdc++." OFF)
set(TARGET_STATIC_POSTFIX "")
if(ENABLE_ALL_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc")
set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc")
set(TARGET_STATIC_POSTFIX "-static")
endif(ENABLE_ALL_STATIC)


# Add subdirectories

add_subdirectory(auxlib)
add_subdirectory(samples)


# Build coordinator and utilities

add_executable(ypspur-coordinator
src/adinput.c
src/command_ad.c
src/command.c
src/command_get.c
src/command_joint.c
src/command_param.c
src/command_run.c
src/command_set.c
src/communication.c
src/control_motion.c
src/control_vehicle.c
src/ipcommunication.c
src/msq.win32.c
src/odometry.c
src/param.c
src/serial.c
src/ssm_spur_handler.c
src/utility.c
src/ypprotocol.c
src/yprintf.c
src/ypspur-coordinator.c
)
target_link_libraries(ypspur-coordinator
carte2d${TARGET_STATIC_POSTFIX} formula-calc${TARGET_STATIC_POSTFIX} m Threads::Threads
)
if(SSM_FOUND)
target_link_libraries(ypspur-coordinator
odomssm${TARGET_STATIC_POSTFIX}
${SSM_LIBRARIES}
)
endif(SSM_FOUND)
if(WIN32)
target_link_libraries(ypspur-coordinator wsock32 ws2_32)
endif(WIN32)

add_executable(ypspur-free
src/ypspur-free.c
)
target_link_libraries(ypspur-free
ypspur${TARGET_STATIC_POSTFIX}
)

add_executable(ypspur-interpreter
src/ypspur-interpreter.c
)

target_link_libraries(ypspur-interpreter
ypspur${TARGET_STATIC_POSTFIX}
)


# Build libraries

set(YPSPUR_LIBRARY_VERSION 14.2.0)
set(YPSPUR_LIBRARY_SOVERSION 14)
set(YPSPUR_PUBLIC_HEADERS
include/ypspur.h
include/ypparam.h
)
set(YPSPUR_MD_PUBLIC_HEADERS
include/ypspur-md.h
include/ypparam.h
)
add_library(ypspur SHARED
src/libypspur.c
src/libypspur-md.c
src/ipcommunication.c
src/msq.win32.c
src/yprintf.c
src/utility.c
)
if(WIN32)
target_link_libraries(ypspur wsock32 ws2_32)
endif(WIN32)
set_target_properties(ypspur PROPERTIES
IMPORT_SUFFIX "_import.lib"
VERSION ${YPSPUR_LIBRARY_VERSION}
SOVERSION ${YPSPUR_LIBRARY_SOVERSION}
PUBLIC_HEADER "${YPSPUR_PUBLIC_HEADERS}"
)

add_library(ypspur-static STATIC
src/libypspur.c
src/libypspur-md.c
src/ipcommunication.c
src/msq.win32.c
src/yprintf.c
src/utility.c
)
if(WIN32)
target_link_libraries(ypspur-static wsock32 ws2_32)
endif(WIN32)
set_target_properties(ypspur-static PROPERTIES
OUTPUT_NAME "ypspur"
PUBLIC_HEADER "${YPSPUR_PUBLIC_HEADERS}"
)

add_library(ypspur-md SHARED
src/libypspur-md.c
src/ipcommunication.c
src/msq.win32.c
src/yprintf.c
src/utility.c
)
if(WIN32)
target_link_libraries(ypspur-md wsock32 ws2_32)
endif(WIN32)
set_target_properties(ypspur-md PROPERTIES
IMPORT_SUFFIX "_import.lib"
VERSION ${YPSPUR_LIBRARY_VERSION}
SOVERSION ${YPSPUR_LIBRARY_SOVERSION}
PUBLIC_HEADER "${YPSPUR_MD_PUBLIC_HEADERS}"
)

add_library(ypspur-md-static STATIC
src/libypspur-md.c
src/ipcommunication.c
src/msq.win32.c
src/yprintf.c
src/utility.c
)
if(WIN32)
target_link_libraries(ypspur-md-static wsock32 ws2_32)
endif(WIN32)
set_target_properties(ypspur-md-static PROPERTIES
OUTPUT_NAME "ypspur-md"
PUBLIC_HEADER "${YPSPUR_MD_PUBLIC_HEADERS}"
)


# Install

install(TARGETS
ypspur-coordinator
ypspur
ypspur-static
ypspur-md
ypspur-md-static
ypspur-free
ypspur-interpreter
EXPORT YPSpurExport
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION include
)
install(FILES include/yp-spur.h
DESTINATION include
)
if(SSM_FOUND)
install(DIRECTORY
include/ssmtype
DESTINATION include
)
endif(SSM_FOUND)


# Generate package config and install


install(EXPORT YPSpurExport
DESTINATION share/ypspur/cmake/
FILE YPSpurTargets.cmake
)

set(YPSPUR_CMAKE_DIR share/ypspur/cmake)

include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/YPSpurConfig.cmake.in
${PROJECT_BINARY_DIR}/cmake/ypspur/YPSpurConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/ypspur
PATH_VARS YPSPUR_CMAKE_DIR
)
write_basic_package_version_file(
${PROJECT_BINARY_DIR}/cmake/ypspur/YPSpurConfig-version.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
)

install(
FILES
${PROJECT_BINARY_DIR}/cmake/ypspur/YPSpurConfig.cmake
${PROJECT_BINARY_DIR}/cmake/ypspur/YPSpurConfig-version.cmake
DESTINATION share/ypspur/
)

11 changes: 0 additions & 11 deletions INSTALL

This file was deleted.

12 changes: 0 additions & 12 deletions Makefile.am

This file was deleted.

Loading

0 comments on commit 15fd8eb

Please sign in to comment.