Skip to content

Commit

Permalink
add mavlink includes to build.cmd and add cmake files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown committed Feb 15, 2017
1 parent bf3dcf9 commit 9ed24af
Show file tree
Hide file tree
Showing 11 changed files with 459 additions and 1 deletion.
6 changes: 5 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ msbuild /p:Platform=x64 /p:Configuration=Release DroneShell.sln
set MAVLINK_TARGET_LIB=AirLib\deps\MavLinkCom\lib
if NOT exist %MAVLINK_TARGET_LIB% mkdir %MAVLINK_TARGET_LIB%

set MAVLINK_TARGET_INCLUDE=AirLib\deps\MavLinkCom\include
if NOT exist %MAVLINK_TARGET_INCLUDE% mkdir %MAVLINK_TARGET_INCLUDE%

if NOT exist Unreal\Plugins\AirSim\Source\AirLib mkdir Unreal\Plugins\AirSim\Source\AirLib

robocopy /MIR MavLinkCom\lib AirLib\deps\MavLinkCom\lib
robocopy /MIR MavLinkCom\include %MAVLINK_TARGET_INCLUDE%
robocopy /MIR MavLinkCom\lib %MAVLINK_TARGET_LIB%
robocopy /MIR AirLib Unreal\Plugins\AirSim\Source\AirLib /XD temp
48 changes: 48 additions & 0 deletions cmake/AirLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 2.8.3)
project(AirLib)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../cmake-modules/CommonSetup.cmake")
CommonSetup()

## System dependencies are found with CMake's conventions
find_package(Eigen3 3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

message(STATUS "TEST=${CMAKE_CURRENT_LIST_DIR}/${AIRSIM_ROOT}/AirLib/src/control/DroneControlBase.cpp")

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${AIRSIM_ROOT}/AirLib/
${AIRSIM_ROOT}/AirLib/include
${AIRSIM_ROOT}/MavLinkCom/include
${AIRSIM_ROOT}/AirLib//deps/rpclib/include
)

add_library(AirLib STATIC
${AIRSIM_ROOT}/AirLib/src/control/DroneControlBase.cpp
${AIRSIM_ROOT}/AirLib/src/control/MavLinkDroneControl.cpp
${AIRSIM_ROOT}/AirLib/src/control/MavLinkHelper.cpp
${AIRSIM_ROOT}/AirLib/src/control/ObstacleMap.cpp
${AIRSIM_ROOT}/AirLib/src/control/RpcLibClient.cpp
${AIRSIM_ROOT}/AirLib/src/control/RpcLibServer.cpp
${AIRSIM_ROOT}/AirLib/src/control/SafetyEval.cpp
)

## Add these to your app that links this library:

#string(SUBSTRING ${CMAKE_STATIC_LINKER_FLAGS} 9 -1 "BUILD_PLATFORM")
#find_package(Threads REQUIRED)
#target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
#target_link_libraries(${PROJECT_NAME} AirLib)
#target_link_libraries(${PROJECT_NAME} MavLinkCom)
#target_link_libraries(${PROJECT_NAME} ../AirLib/deps/rpclib/lib/${BUILD_PLATFORM}/$(Configuration)/rpc)
#IF(UNIX)
#target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
#ENDIF()
10 changes: 10 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8.3)
project(AirSim)

add_subdirectory("AirLib")
add_subdirectory("MavLinkCom")
add_subdirectory("MavLinkTest")
add_subdirectory("HelloDrone")
add_subdirectory("DroneShell")
add_subdirectory("DroneServer")

49 changes: 49 additions & 0 deletions cmake/DroneServer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 2.8.3)
project(DroneServer)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../cmake-modules/CommonSetup.cmake")
CommonSetup()

## System dependencies are found with CMake's conventions
find_package(Eigen3 3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system filesystem )

IF(UNIX)
ELSE()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CONSOLE ")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE /LIBPATH:${Boost_INCLUDE_DIRS}/stage/lib")
ENDIF()

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${AIRSIM_ROOT}/DroneServer
${AIRSIM_ROOT}/MavLinkCom/include
${AIRSIM_ROOT}/AirLib/deps/rpclib/include;
${AIRSIM_ROOT}/AirLib/include
${Boost_INCLUDE_DIRS}
)


## Declare the executable
add_executable(DroneServer
${AIRSIM_ROOT}/DroneServer/main.cpp
)

find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} AirLib)
target_link_libraries(${PROJECT_NAME} MavLinkCom)
target_link_libraries(${PROJECT_NAME} ${RPC_LIB})
IF(UNIX)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
ENDIF()
51 changes: 51 additions & 0 deletions cmake/DroneShell/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 2.8.3)
project(DroneShell)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../cmake-modules/CommonSetup.cmake")
CommonSetup()

## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system filesystem )

## System dependencies are found with CMake's conventions
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
find_package(Eigen3 3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

IF(UNIX)
ELSE()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CONSOLE ")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE /LIBPATH:${Boost_INCLUDE_DIRS}/stage/lib")
ENDIF()

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${AIRSIM_ROOT}/DroneShell
${AIRSIM_ROOT}/AirLib/deps/rpclib/include;
${AIRSIM_ROOT}/DroneShell/include;
${AIRSIM_ROOT}/AirLib/include
${AIRSIM_ROOT}/MavLinkCom/include
${Boost_INCLUDE_DIRS}
)


## Declare the executable
add_executable(DroneShell
${AIRSIM_ROOT}/DroneShell/src/main.cpp
)

find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} AirLib)
target_link_libraries(${PROJECT_NAME} MavLinkCom)
target_link_libraries(${PROJECT_NAME} ${RPC_LIB})
IF(UNIX)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
ENDIF()
48 changes: 48 additions & 0 deletions cmake/HelloDrone/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 2.8.3)
project(HelloDrone)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../cmake-modules/CommonSetup.cmake")
CommonSetup()

## System dependencies are found with CMake's conventions
find_package(Eigen3 3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system filesystem )

IF(UNIX)
ELSE()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CONSOLE ")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE /LIBPATH:${Boost_INCLUDE_DIRS}/stage/lib")
ENDIF()

###########
## Build ##
###########

## Specify additional locations of header files
include_directories(
${AIRSIM_ROOT}/HelloDrone
${AIRSIM_ROOT}/AirLib/include
${AIRSIM_ROOT}/AirLib/deps/rpclib/include
${AIRSIM_ROOT}/MavLinkCom/include
${AIRSIM_ROOT}/MavLinkCom/common_utils
${Boost_INCLUDE_DIRS}
)


## Declare the executable
add_executable(HelloDrone
${AIRSIM_ROOT}/HelloDrone/main.cpp
)

find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} MavLinkCom)
target_link_libraries(${PROJECT_NAME} AirLib)
target_link_libraries(${PROJECT_NAME} ${RPC_LIB})
IF(UNIX)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
ENDIF()
66 changes: 66 additions & 0 deletions cmake/MavLinkCom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 2.8.3)
project(MavLinkCom)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../cmake-modules/CommonSetup.cmake")
CommonSetup()

message(STATUS "Boost_INCLUDE_DIR=${Boost_INCLUDE_DIR}")

## System dependencies are found with CMake's conventions
# SET(Boost_DEBUG TRUE)
find_package(Boost REQUIRED COMPONENTS system)

if(Boost_FOUND)

endif()

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${AIRSIM_ROOT}/MavLinkCom
${AIRSIM_ROOT}/MavLinkCom/common_utils
${AIRSIM_ROOT}/MavLinkCom/include
${Boost_INCLUDE_DIRS}
)


LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkConnection.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkFtpClient.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkLog.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkMessageBase.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkMessages.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkNode.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkTcpServer.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkVehicle.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkVideoStream.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/MavLinkSemaphore.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/impl/MavLinkConnectionImpl.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/impl/MavLinkFtpClientImpl.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/impl/MavLinkNodeImpl.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/impl/MavLinkTcpServerImpl.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/impl/MavLinkVehicleImpl.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/impl/MavLinkVideoStreamImpl.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/serial_com/SerialPort.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/serial_com/TcpServer.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/serial_com/TcpClientPort.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/serial_com/UdpClientPort.cpp")
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/serial_com/UdpServer.cpp")

IF(UNIX)
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/impl/linux/MavLinkFindSerialPorts.cpp")
ELSE()
LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/impl/windows/MavLinkFindSerialPorts.cpp")
ENDIF()

add_library(MavLinkCom STATIC ${MAVLINK_SOURCES})

## Add these to your app that links this library:
# find_package(Threads REQUIRED)
# target_link_libraries (${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
# target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
44 changes: 44 additions & 0 deletions cmake/MavLinkTest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 2.8.3)
project(MavLinkTest)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../cmake-modules/CommonSetup.cmake")
CommonSetup()

## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system filesystem )

IF(UNIX)
ELSE()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CONSOLE ")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE /LIBPATH:${Boost_INCLUDE_DIRS}/stage/lib")
ENDIF()

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${AIRSIM_ROOT}/MavLinkTest
${AIRSIM_ROOT}/MavLinkCom/include
${AIRSIM_ROOT}/MavLinkCom/common_utils
${Boost_INCLUDE_DIRS}
)

## Declare the executable
add_executable(MavLinkTest
${AIRSIM_ROOT}/MavLinkTest/Commands.cpp
${AIRSIM_ROOT}/MavLinkTest/UnitTests.cpp
${AIRSIM_ROOT}/MavLinkTest/main.cpp
)

find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} AirLib)
target_link_libraries(${PROJECT_NAME} MavLinkCom)
IF(UNIX)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
ENDIF()
45 changes: 45 additions & 0 deletions cmake/cmake-modules/CommonSetup.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Common setup instructions shared by all AirSim CMakeLists.

macro(CommonSetup)
message(STATUS "Running CommonSetup...")

SET(AIRSIM_ROOT "../..")
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

IF(UNIX)
## I had to remove the following for Eigen to build properly: -Wlogical-op -Wsign-promo
## boost does not built cleam, so I had to disable these checks:
set(BOOST_OVERRIDES " -Wno-error=undef -Wno-error=ctor-dtor-privacy -Wno-error=old-style-cast -Wno-error=shadow -Wno-error=redundant-decls -Wno-error=missing-field-initializers -Wno-error=unused-parameter")
## Mavlink requires turning off -pedantic and -Wno-error=switch-default
set(MAVLINK_OVERRIDES "-Wno-error=switch-default ")
set(CMAKE_CXX_FLAGS "-std=c++11 -ggdb -Wall -Wextra -Wstrict-aliasing -Werror -fmax-errors=2 -Wunreachable-code -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option ${MAVLINK_OVERRIDES} ${BOOST_OVERRIDES} -Wl,--no-as-needed -ldl -ldl ${CMAKE_CXX_FLAGS}")
set(BUILD_PLATFORM "x64")

ELSE()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0600 /GS /W4 /wd4100 /wd4505 /wd4820 /wd4464 /wd4514 /wd4710 /wd4571 /Zc:wchar_t /ZI /Zc:inline /fp:precise /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_UNICODE /DUNICODE /WX- /Zc:forScope /Gd /EHsc ")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NXCOMPAT /DYNAMICBASE /INCREMENTAL:NO ")
ENDIF()

## common boost settings to make sure we are all on the same page
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
#set(Boost_USE_STATIC_RUNTIME ON)

## strip /machine: from CMAKE_STATIC_LINKER_FLAGS
if(NOT "${CMAKE_STATIC_LINKER_FLAGS}" STREQUAL "")
string(SUBSTRING ${CMAKE_STATIC_LINKER_FLAGS} 9 -1 "BUILD_PLATFORM")
endif()

string( TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
if("${BUILD_TYPE}" STREQUAL "debug")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_DEBUG /MDd /RTC1 /Gm /Od ")
elseif("${BUILD_TYPE}" STREQUAL "release")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MD /O2 /Oi /GL /Gm- /Gy /TP ")
else()
message(FATAL_ERROR "Please specify '-D CMAKE_BUILD_TYPE=Debug' or Release on the cmake command line")
endif()

set(RPC_LIB "${AIRSIM_ROOT}/AirLib/deps/rpclib/lib/${BUILD_PLATFORM}/$(Configuration)/rpc")

endmacro(CommonSetup)

Loading

0 comments on commit 9ed24af

Please sign in to comment.