Skip to content

Commit

Permalink
Enable command line setup/builds for Mac
Browse files Browse the repository at this point in the history
- Update setup/rebuild scripts and cmake settings to enable automated command line setup/builds for Mac using homebrew-installed llvm/clang 3.9.
- Set DepthEffectMaterial for Mac (experimental)
  • Loading branch information
edufford committed Jul 15, 2018
1 parent 860dbe9 commit 78e9e19
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 10 deletions.
37 changes: 36 additions & 1 deletion Rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ done
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR" >/dev/null

UNREAL_PROJECT_FOLDER=./Unreal/CarlaUE4
UNREAL_PROJECT_FOLDER=${PWD}/Unreal/CarlaUE4 # use full path
UE4_INTERMEDIATE_FOLDERS="Binaries Build Intermediate DerivedDataCache"

function fatal_error {
Expand All @@ -66,6 +66,10 @@ fi
# -- Make CarlaServer ----------------------------------------------------------
# ==============================================================================

# Set default compilers for cmake
export CC=clang-3.9
export CXX=clang++-3.9

log "Making CarlaServer..."
make clean && make debug && make release

Expand All @@ -91,6 +95,35 @@ popd >/dev/null
# -- Build and launch Unreal project -------------------------------------------
# ==============================================================================

if [ "$(uname)" == "Darwin" ]; then # Mac

set +e
log "Generate Unreal project files for Mac..."
# GenerateProjectFiles.sh requires to change directory to location of UE engine Mac batch files
pushd "${UE4_ROOT}/Engine/Build/BatchFiles/Mac/" >/dev/null
./GenerateProjectFiles.sh -project="${UNREAL_PROJECT_FOLDER}/CarlaUE4.uproject" -game -engine -makefiles
popd >/dev/null
set -e

log "Build CarlaUE4 project for Mac..."
# Build.sh requires to change directory to location of UE engine root
pushd "${UE4_ROOT}" >/dev/null
./Engine/Build/BatchFiles/Mac/Build.sh UE4Editor Mac Development

if $LAUNCH_UE4_EDITOR ; then
log "Launching UE4Editor app..."
open ./Engine/Binaries/Mac/UE4Editor.app --args "${UNREAL_PROJECT_FOLDER}/CarlaUE4.uproject"
else
echo ""
echo "****************"
echo "*** Success! ***"
echo "****************"
fi

popd >/dev/null

else # Linux/Windows

pushd "$UNREAL_PROJECT_FOLDER" >/dev/null

# This command usually fails but normally we can continue anyway.
Expand All @@ -114,6 +147,8 @@ fi

popd >/dev/null

fi # end of OS select

# ==============================================================================
# -- ...and we are done --------------------------------------------------------
# ==============================================================================
Expand Down
6 changes: 3 additions & 3 deletions Setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fi
pushd boost-source >/dev/null

BOOST_TOOLSET="clang-3.9"
BOOST_CFLAGS="-fPIC -std=c++1y -stdlib=libc++ -I../llvm-install/include/c++/v1"
BOOST_CFLAGS="-fPIC -std=c++1y -stdlib=libc++ -nostdinc++ -I../llvm-install/include/c++/v1"
BOOST_LFLAGS="-stdlib=libc++ -L../llvm-install/lib"

./bootstrap.sh \
Expand Down Expand Up @@ -156,7 +156,7 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/../llvm-install/lib/"
./configure \
CC="clang-3.9" \
CXX="clang++-3.9" \
CXXFLAGS="-fPIC -stdlib=libc++ -I$PWD/../llvm-install/include/c++/v1" \
CXXFLAGS="-fPIC -stdlib=libc++ -nostdinc++ -I$PWD/../llvm-install/include/c++/v1" \
LDFLAGS="-stdlib=libc++ -L$PWD/../llvm-install/lib/" \
--prefix="$PWD/../protobuf-install" \
--disable-shared
Expand All @@ -181,7 +181,7 @@ pushd googletest-source >/dev/null

cmake -H. -B./build \
-DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \
-DCMAKE_CXX_FLAGS="-stdlib=libc++ -I$PWD/../llvm-install/include/c++/v1 -Wl,-L$PWD/../llvm-install/lib" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++ -nostdinc++ -I$PWD/../llvm-install/include/c++/v1 -Wl,-L$PWD/../llvm-install/lib" \
-DCMAKE_INSTALL_PREFIX="../googletest-install" \
-G "Ninja"

Expand Down
4 changes: 1 addition & 3 deletions Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
static constexpr auto DEPTH_MAT_PATH =
#if PLATFORM_LINUX
TEXT("Material'/Carla/PostProcessingMaterials/DepthEffectMaterial_GLSL.DepthEffectMaterial_GLSL'");
#elif PLATFORM_WINDOWS
#else // Windows/Mac
TEXT("Material'/Carla/PostProcessingMaterials/DepthEffectMaterial.DepthEffectMaterial'");
#else
# error No depth material defined for this platform
#endif

static constexpr auto SEMANTIC_SEGMENTATION_MAT_PATH =
Expand Down
51 changes: 48 additions & 3 deletions Util/cmake/CarlaServer/CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
# -- Compiler and dependencies -------------------------------------------------
# ==============================================================================

if (UNIX)
if (UNIX AND NOT APPLE)

find_package(Threads)

Expand Down Expand Up @@ -58,6 +58,51 @@ if (UNIX)
${Protobuf_Static_Libraries}
DESTINATION lib)

elseif (APPLE)

find_package(Threads)

set(CMAKE_CXX_COMPILER clang++-3.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++14 -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wno-unused-parameter -Wno-error=unused-command-line-argument")

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -D_DEBUG -O0")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG -O3")
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")

# Setup libc++.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -nostdinc++")
include_directories("${CARLA_LIBCXX_INSTALL_PATH}/include/c++/v1")
link_directories("${CARLA_LIBCXX_INSTALL_PATH}/lib")
file(GLOB LibCXX_Shared_Libraries "${CARLA_LIBCXX_INSTALL_PATH}/lib/libc++*.so*")
file(GLOB LibCXX_Static_Libraries "${CARLA_LIBCXX_INSTALL_PATH}/lib/libc++*.a")

# Setup boost.
include_directories("${CARLA_BOOST_INSTALL_PATH}/include")
set(Boost_Static_Libraries "${CARLA_BOOST_INSTALL_PATH}/lib/libboost_system.a")

# Setup protobuf.
include_directories("${CARLA_PROTOBUF_INSTALL_PATH}/include")
set(Protobuf_Static_Libraries "${CARLA_PROTOBUF_INSTALL_PATH}/lib/libprotobuf.a")

# Setup googletest.
include_directories("${CARLA_GOOGLETEST_INSTALL_PATH}/include")
set(GTest_Static_Libraries "${CARLA_GOOGLETEST_INSTALL_PATH}/lib/libgtest.a")

install(FILES
${LibCXX_Shared_Libraries}
DESTINATION shared)

install(FILES
${LibCXX_Static_Libraries}
${Boost_Static_Libraries}
${Protobuf_Static_Libraries}
DESTINATION lib)

elseif (WIN32)

# Setup boost.
Expand All @@ -81,9 +126,9 @@ elseif (WIN32)
${Protobuf_Static_Libraries}
DESTINATION lib)

else (UNIX)
else (UNIX AND NOT APPLE)
message(FATAL_ERROR "Build configuration not yet available for this platform")
endif (UNIX)
endif (UNIX AND NOT APPLE)

# ==============================================================================
# -- Project config ------------------------------------------------------------
Expand Down

0 comments on commit 78e9e19

Please sign in to comment.