Skip to content

Commit

Permalink
Fix unix build.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Lovett committed Feb 27, 2017
1 parent 2e7018e commit 425d007
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 24 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,13 @@ deps/
/boost
/eigen
/build_debug
/cmake/CPackSourceConfig.cmake
/cmake/CPackConfig.cmake
/cmake/arch.c
/cmake/rpclib/version.h
/cmake/rpclib/Makefile
/cmake/rpclib
/cmake/output/lib/libMavLinkCom.a
/cmake/output/lib/libAirSim-rpclib.a
/cmake/output/lib/libAirLib.a
/cmake/output/lib
2 changes: 1 addition & 1 deletion AirLib/src/controllers/MavLinkDroneController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ struct MavLinkDroneController::impl {
{
if (connection_ != nullptr) {
//TODO: can we do this?
throw std::exception("Cannot call setSimulationMode after connection was already established for MavLink");
throw std::domain_error("Cannot call setSimulationMode after connection was already established for MavLink");
}

is_simulation_mode_ = is_set;
Expand Down
2 changes: 1 addition & 1 deletion MavLinkCom/common_utils/ThreadUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bool CurrentThread::setMaximumPriority()
return false;
}
return true;
#elif __APPLE__
#elif defined(__APPLE__)
// TODO: How to handle POSIX thread priorities on OSX?
return true;
#else
Expand Down
4 changes: 2 additions & 2 deletions cmake/AirLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ include_directories(
${AIRSIM_ROOT}/AirLib/
${AIRSIM_ROOT}/AirLib/include
${AIRSIM_ROOT}/MavLinkCom/include
${AIRSIM_ROOT}/external/rpclib/include
${RPC_LIB_INCLUDES}
)

add_library(AirLib STATIC
Expand All @@ -34,7 +34,7 @@ add_library(AirLib STATIC
)

## Add these to your app that links this library:
target_link_libraries(${PROJECT_NAME} ${CMAKE_PROJECT_NAME}-${RPCLIB_NAME_SUFFIX})
target_link_libraries(${PROJECT_NAME} ${RPC_LIB})

#string(SUBSTRING ${CMAKE_STATIC_LINKER_FLAGS} 9 -1 "BUILD_PLATFORM")
#find_package(Threads REQUIRED)
Expand Down
7 changes: 6 additions & 1 deletion cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
cmake_minimum_required(VERSION 3.2.2)
project(AirSim)

set(RPCLIB_NAME_SUFFIX rpclib)

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

add_subdirectory("${AIRSIM_ROOT}/external/rpclib" "${CMAKE_CURRENT_BINARY_DIR}/rpclib")

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

5 changes: 2 additions & 3 deletions cmake/DroneServer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ENDIF()
include_directories(
${AIRSIM_ROOT}/DroneServer
${AIRSIM_ROOT}/MavLinkCom/include
${AIRSIM_ROOT}/AirLib/deps/rpclib/include;
${RPC_LIB_INCLUDES}
${AIRSIM_ROOT}/AirLib/include
${Boost_INCLUDE_DIRS}
)
Expand All @@ -39,11 +39,10 @@ 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} ${CMAKE_PROJECT_NAME}-${RPCLIB_NAME_SUFFIX})
target_link_libraries(${PROJECT_NAME} ${RPC_LIB})
IF(UNIX)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
ENDIF()
5 changes: 2 additions & 3 deletions cmake/DroneShell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ENDIF()
# include_directories(include)
include_directories(
${AIRSIM_ROOT}/DroneShell
${AIRSIM_ROOT}/AirLib/deps/rpclib/include;
${RPC_LIB_INCLUDES}
${AIRSIM_ROOT}/DroneShell/include;
${AIRSIM_ROOT}/AirLib/include
${AIRSIM_ROOT}/MavLinkCom/include
Expand All @@ -41,11 +41,10 @@ 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} ${CMAKE_PROJECT_NAME}-${RPCLIB_NAME_SUFFIX})
target_link_libraries(${PROJECT_NAME} ${RPC_LIB})
IF(UNIX)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
ENDIF()
5 changes: 2 additions & 3 deletions cmake/HelloDrone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ENDIF()
include_directories(
${AIRSIM_ROOT}/HelloDrone
${AIRSIM_ROOT}/AirLib/include
${AIRSIM_ROOT}/AirLib/deps/rpclib/include
${RPC_LIB_INCLUDES}
${AIRSIM_ROOT}/MavLinkCom/include
${AIRSIM_ROOT}/MavLinkCom/common_utils
${Boost_INCLUDE_DIRS}
Expand All @@ -38,11 +38,10 @@ 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} ${CMAKE_PROJECT_NAME}-${RPCLIB_NAME_SUFFIX})
target_link_libraries(${PROJECT_NAME} ${RPC_LIB})
IF(UNIX)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
ENDIF()
1 change: 0 additions & 1 deletion cmake/MavLinkCom/MavLinkTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ add_executable(MavLinkTest
${AIRSIM_ROOT}/MavLinkCom/MavLinkTest/main.cpp
)

find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} MavLinkCom)
IF(UNIX)
Expand Down
10 changes: 10 additions & 0 deletions cmake/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ fi
cmake $GCCARGS CMakeLists.txt

make

pushd ..
mkdir -p AirLib/lib/x64/Debug
mkdir -p AirLib/deps/rpclib
mkdir -p AirLib/deps/MavLinkCom
cp -p cmake/output/lib/* AirLib/lib/x64/Debug
cp -rp external/rpclib/include AirLib/deps/rpclib
cp -rp MavLinkCom/include AirLib/deps/MavLinkCom
cp -rp AirLib Unreal/Plugins/AirSim/Source
popd
19 changes: 11 additions & 8 deletions cmake/cmake-modules/CommonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ macro(CommonSetup)
find_path(AIRSIM_ROOT NAMES AirSim.sln PATHS ".." "../.." "../../.." "../../../.." "../../../../.." "../../../../../..")
message(STATUS "found AIRSIM_ROOT=${AIRSIM_ROOT}")

SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
SET(EXECUTABLE_OUTPUT_PATH ${AIRSIM_ROOT}/cmake/output/bin)

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")
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(RPC_LIB_DEFINES "-D MSGPACK_PP_VARIADICS_MSVC=0")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(CMAKE_CXX_STANDARD 14)
else ()
##TODO: Werror removed temporarily. It should be added back after Linux build is stable
set(CMAKE_CXX_FLAGS "-std=c++14 -stdlib=libc++ -ggdb -Wall -Wextra -Wstrict-aliasing -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} ${RPC_LIB_DEFINES} -ldl ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++ -lc++abi")
set(CMAKE_CXX_FLAGS "-std=c++14 -ggdb -lpthread -Wall -Wextra -Wstrict-aliasing -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} ${RPC_LIB_DEFINES} -ldl ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ")
endif ()
set(BUILD_PLATFORM "x64")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand All @@ -44,7 +45,7 @@ macro(CommonSetup)

IF(UNIX)
set(BUILD_TYPE "linux")
set(RPC_LIB "${AIRSIM_ROOT}/AirLib/deps/rpclib/lib/${BUILD_PLATFORM}/${BUILD_TYPE}/librpc.a")

ELSE()
string( TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
if("${BUILD_TYPE}" STREQUAL "debug")
Expand All @@ -54,9 +55,11 @@ macro(CommonSetup)
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}/${BUILD_TYPE}/rpc")
endif()



set(RPC_LIB_INCLUDES " ${AIRSIM_ROOT}/external/rpclib/include")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
set(RPC_LIB ${CMAKE_PROJECT_NAME}-${RPCLIB_NAME_SUFFIX})
set(RPC_BIN_NAME "${AIRSIM_ROOT}/cmake/${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${RPC_LIB}.a")
endmacro(CommonSetup)

2 changes: 1 addition & 1 deletion cmake/cmake-modules/FindEigen3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ else (EIGEN3_INCLUDE_DIR)
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
PATHS
$ENV{EIGEN_ROOT}
PATH_SUFFIXES eigen3 eigen
PATH_SUFFIXES Eigen3 Eigen eigen3 eigen
NO_DEFAULT_PATH
)

Expand Down

0 comments on commit 425d007

Please sign in to comment.