From 78e9e1919d30f7be84a3e47bc6cf053eca664a68 Mon Sep 17 00:00:00 2001 From: edufford Date: Sat, 14 Jul 2018 14:09:38 -1000 Subject: [PATCH] Enable command line setup/builds for Mac - 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) --- Rebuild.sh | 37 +++++++++++++- Setup.sh | 6 +-- .../Carla/Sensor/SceneCaptureCamera.cpp | 4 +- Util/cmake/CarlaServer/CMakeLists.txt | 51 +++++++++++++++++-- 4 files changed, 88 insertions(+), 10 deletions(-) mode change 100644 => 100755 Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp mode change 100644 => 100755 Util/cmake/CarlaServer/CMakeLists.txt diff --git a/Rebuild.sh b/Rebuild.sh index 879e79483a3..4890174cd1e 100755 --- a/Rebuild.sh +++ b/Rebuild.sh @@ -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 { @@ -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 @@ -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. @@ -114,6 +147,8 @@ fi popd >/dev/null +fi # end of OS select + # ============================================================================== # -- ...and we are done -------------------------------------------------------- # ============================================================================== diff --git a/Setup.sh b/Setup.sh index 9a6a29e0de4..036a9f50f16 100755 --- a/Setup.sh +++ b/Setup.sh @@ -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 \ @@ -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 @@ -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" diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp old mode 100644 new mode 100755 index 712cc5164cc..ecc9ff66829 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureCamera.cpp @@ -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 = diff --git a/Util/cmake/CarlaServer/CMakeLists.txt b/Util/cmake/CarlaServer/CMakeLists.txt old mode 100644 new mode 100755 index 5189595fb8e..e7a766207d2 --- a/Util/cmake/CarlaServer/CMakeLists.txt +++ b/Util/cmake/CarlaServer/CMakeLists.txt @@ -13,7 +13,7 @@ endif (CMAKE_BUILD_TYPE STREQUAL "Debug") # -- Compiler and dependencies ------------------------------------------------- # ============================================================================== -if (UNIX) +if (UNIX AND NOT APPLE) find_package(Threads) @@ -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. @@ -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 ------------------------------------------------------------