Skip to content

Commit

Permalink
Some Linux cmake build fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovettchris committed Feb 15, 2017
1 parent bf5cc70 commit 873bc95
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
Binary file added AirLib/deps/rpclib/lib/x64/linux/librpc.a
Binary file not shown.
7 changes: 4 additions & 3 deletions AirLib/include/common/common_utils/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef common_utils_Utils_hpp
#define common_utils_Utils_hpp

#ifdef _MSC_VER
#if defined(_MSC_VER)
//TODO: limit scope of below statements required to suppress VC++ warnings
#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable:4996)
Expand Down Expand Up @@ -33,15 +33,16 @@

#define STRICT_MODE_ON \
_Pragma("GCC diagnostic pop")
#elif _MSC_VER
#else
#if defined(_MSC_VER)
//'=': conversion from 'double' to 'float', possible loss of data
#define STRICT_MODE_OFF \
__pragma(warning(push)) \
__pragma(warning( disable : 4100 4189 4244 4245 4239 4464 4456 4505 4514 4571 4624 4626 4267 4710 4820 5027 5031))
#define STRICT_MODE_ON \
__pragma(warning(pop))
#endif

#endif
#include <chrono>
#include <thread>
#include <memory>
Expand Down
2 changes: 0 additions & 2 deletions cmake/AirLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ CommonSetup()
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 ##
###########
Expand Down
26 changes: 15 additions & 11 deletions cmake/cmake-modules/CommonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ macro(CommonSetup)
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(CMAKE_CXX_FLAGS "-std=c++14 -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()
Expand All @@ -29,17 +29,21 @@ macro(CommonSetup)
if(NOT "${CMAKE_STATIC_LINKER_FLAGS}" STREQUAL "")
string(SUBSTRING ${CMAKE_STATIC_LINKER_FLAGS} 9 -1 "BUILD_PLATFORM")
endif()

IF(UNIX)
set(BUILD_TYPE "linux")
ELSE()
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()
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")
set(RPC_LIB "${AIRSIM_ROOT}/AirLib/deps/rpclib/lib/${BUILD_PLATFORM}/${BUILD_TYPE}/rpc")

endmacro(CommonSetup)

9 changes: 8 additions & 1 deletion cmake/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#Windows

On Windows run this command to build debug bits:

cmake -G "Visual Studio 14 2015 Win64" -D CMAKE_BUILD_TYPE=Debug CMakeLists.txt
Expand All @@ -7,5 +9,10 @@ To build release bits delete CMakeCache.txt and run this:

cmake -G "Visual Studio 14 2015 Win64" -D CMAKE_BUILD_TYPE=Release CMakeLists.txt
msbuild /p:Platform=x64 /p:Configuration=Release AirSim.sln

#Linux
On Linux you first need a version of GCC that supports `-std=c++14`. Version 4.9 or newer should work. Then run this:

cmake -D CMAKE_C_COMPILER=gcc-4.9 -D CMAKE_CXX_COMPILER=g++-4.9 -D CMAKE_BUILD_TYPE=Debug CMakeLists.txt
make


0 comments on commit 873bc95

Please sign in to comment.