Fixing Recast library for Windows

This commit is contained in:
bernat 2019-06-05 23:33:46 +02:00 committed by Néstor Subirón
parent 8e0ddabb70
commit 036baa1488
4 changed files with 164 additions and 1 deletions

View File

@ -206,6 +206,10 @@ if (LIBCARLA_BUILD_RELEASE)
if (WIN32) # @todo Fix PythonAPI build on Windows.
set_target_properties(carla_client PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}")
target_link_libraries(carla_client "${RECAST_LIB_PATH}/Recast.lib")
target_link_libraries(carla_client "${RECAST_LIB_PATH}/Detour.lib")
target_link_libraries(carla_client "${RECAST_LIB_PATH}/DetourCrowd.lib")
else ()
if (NOT DEFINED CMAKE_CXX_FLAGS_RELEASE_CLIENT)
set(CMAKE_CXX_FLAGS_RELEASE_CLIENT ${CMAKE_CXX_FLAGS_RELEASE})

View File

@ -71,7 +71,7 @@ def get_libcarla_extensions():
sys.version_info.major,
sys.version_info.minor)
extra_link_args = ['shlwapi.lib']
extra_link_args = ['shlwapi.lib', 'Recast.lib', 'RecastDetour.lib', 'RecastDetourCrowd.lib' ]
required_libs = [
pylib, 'libboost_filesystem',

View File

@ -139,6 +139,22 @@ if not defined install_gtest (
goto failed
)
rem ============================================================================
rem -- Download and install Recast & Detour ------------------------------------
rem ============================================================================
echo %FILE_N% Installing "Recast & Detour"...
call "%INSTALLERS_DIR%install_recast.bat"^
--build-dir "%INSTALLATION_DIR%"
if %errorlevel% neq 0 goto failed
if not defined install_recast (
echo %FILE_N% Failed while installing "Recast & Detour".
goto failed
)
rem ============================================================================
rem -- Download and install Boost ----------------------------------------------
rem ============================================================================
@ -216,6 +232,8 @@ set CMAKE_CONFIG_FILE="%INSTALLATION_DIR%CMakeLists.txt.in"
>>"%CMAKE_CONFIG_FILE%" echo set(ZLIB_LIB_PATH "%ZLIB_INSTALL_DIR%/lib")
>>"%CMAKE_CONFIG_FILE%" echo set(LIBPNG_INCLUDE_PATH "%LIBPNG_INSTALL_DIR%/include")
>>"%CMAKE_CONFIG_FILE%" echo set(LIBPNG_LIB_PATH "%LIBPNG_INSTALL_DIR%/lib")
>>"%CMAKE_CONFIG_FILE%" echo set(RECAST_INCLUDE_PATH "%RECAST_INSTALL_DIR%/include")
>>"%CMAKE_CONFIG_FILE%" echo set(RECAST_LIB_PATH "%RECAST_INSTALL_DIR%/lib")
>>"%CMAKE_CONFIG_FILE%" echo endif ()
goto success

View File

@ -0,0 +1,141 @@
@echo off
setlocal
rem BAT script that downloads and installs Recast & Detour library
rem Run it through a cmd with the x64 Visual C++ Toolset enabled.
set LOCAL_PATH=%~dp0
set "FILE_N= -[%~n0]:"
rem Print batch params (debug purpose)
echo %FILE_N% [Batch params]: %*
rem ============================================================================
rem -- Parse arguments ---------------------------------------------------------
rem ============================================================================
set BUILD_DIR=.
set DEL_SRC=false
:arg-parse
if not "%1"=="" (
if "%1"=="--build-dir" (
set BUILD_DIR=%~2
shift
)
if "%1"=="--delete-src" (
set DEL_SRC=true
)
shift
goto :arg-parse
)
set RECAST_SRC=recast-src
set RECAST_SRC_DIR=%BUILD_DIR%%RECAST_SRC%\
set RECAST_INSTALL=recast-install
set RECAST_INSTALL_DIR=%BUILD_DIR%%RECAST_INSTALL%\
set RECAST_BUILD_DIR=%RECAST_SRC_DIR%build
set RECAST_COMMIT="c40188c796f089f89a42e0b939d934178dbcfc5c"
set RECAST_BASENAME=%RECAST_SRC%
if exist "%RECAST_INSTALL_DIR%" (
goto already_build
)
if not exist "%RECAST_SRC_DIR%" (
echo %FILE_N% Cloning "Recast & Detour"
call git clone https://github.com/recastnavigation/recastnavigation.git %RECAST_SRC_DIR%
cd %RECAST_SRC_DIR%
call git reset --hard %RECAST_COMMIT%
cd ..
if %errorlevel% neq 0 goto error_git
) else (
echo %FILE_N% Not cloning "Recast & Detour" because already exists a folder called "%RECAST_SRC%".
)
if not exist "%RECAST_BUILD_DIR%" (
echo %FILE_N% Creating "%RECAST_BUILD_DIR%"
mkdir "%RECAST_BUILD_DIR%"
)
cd "%RECAST_BUILD_DIR%"
echo %FILE_N% Generating build...
cmake .. -G "Visual Studio 15 2017 Win64"^
-DCMAKE_BUILD_TYPE=Release^
-DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^
-DCMAKE_INSTALL_PREFIX=%RECAST_INSTALL_DIR%^
-DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING^
-DRECASTNAVIGATION_DEMO=False^
-DRECASTNAVIGATION_TEST=False^
%RECAST_SRC_DIR%
if %errorlevel% neq 0 goto error_cmake
echo %FILE_N% Building...
cmake --build . --config Release --target install
if errorlevel neq 0 goto error_install
rem Remove the downloaded Recast & Detour source because is no more needed
if %DEL_SRC% == true (
rd /s /q "%RECAST_SRC_DIR%"
)
goto success
rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================
:success
echo.
echo %FILE_N% "Recast & Detour" has been successfully installed in "%RECAST_INSTALL_DIR%"!
goto good_exit
:already_build
echo %FILE_N% A "Recast & Detour" installation already exists.
echo %FILE_N% Delete "%RECAST_INSTALL_DIR%" if you want to force a rebuild.
goto good_exit
:error_git
echo.
echo %FILE_N% [GIT ERROR] An error ocurred while executing the git.
echo %FILE_N% [GIT ERROR] Possible causes:
echo %FILE_N% - Make sure "git" is installed.
echo %FILE_N% - Make sure it is available on your Windows "path".
goto bad_exit
:error_cmake
echo.
echo %FILE_N% [CMAKE ERROR] An error ocurred while executing the cmake.
echo %FILE_N% [CMAKE ERROR] Possible causes:
echo %FILE_N% - Make sure "CMake" is installed.
echo %FILE_N% - Make sure it is available on your Windows "path".
goto bad_exit
:error_install
echo.
echo %FILE_N% [Visual Studio 15 2017 Win64 ERROR] An error ocurred while installing using Visual Studio 15 2017 Win64.
echo %FILE_N% [Visual Studio 15 2017 Win64 ERROR] Possible causes:
echo %FILE_N% - Make sure you have Visual Studio installed.
echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path.
echo %FILE_N% For example using the "Visual Studio x64 Native Tools Command Prompt",
echo %FILE_N% or the "vcvarsall.bat".
goto bad_exit
:good_exit
echo %FILE_N% Exiting...
endlocal
set install_recast=done
exit /b 0
:bad_exit
if exist "%RECAST_INSTALL_DIR%" rd /s /q "%RECAST_INSTALL_DIR%"
echo %FILE_N% Exiting with error...
endlocal
exit /b %errorlevel%