Make it compile in Windows
This commit is contained in:
parent
124dd06d40
commit
8a2680428e
18
Makefile
18
Makefile
|
@ -1,15 +1,17 @@
|
|||
INSTALL_FOLDER=$(PWD)/Util/Install
|
||||
PYTHON_CLIENT_FOLDER=$(PWD)/Util/PythonClient
|
||||
BASE_BUILD_FOLDER=$(PWD)/Util/Build/carlaserver-build
|
||||
MY_CMAKE_FOLDER=$(PWD)/Util/cmake
|
||||
INSTALL_FOLDER=$(CURDIR)/Util/Install
|
||||
PYTHON_CLIENT_FOLDER=$(CURDIR)/Util/PythonClient
|
||||
BASE_BUILD_FOLDER=$(CURDIR)/Util/Build/carlaserver-build
|
||||
MY_CMAKE_FOLDER=$(CURDIR)/Util/cmake
|
||||
MY_CMAKE_FLAGS=-B"$(BUILD_FOLDER)" -DCMAKE_INSTALL_PREFIX="$(INSTALL_FOLDER)"
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
BUILD_RULE=build_windows
|
||||
PROTOC_CALL=echo "Error!"
|
||||
PROTOC_COMPILE=cmd.exe /k "cd Util & call Protoc.bat & exit"
|
||||
PROTOC_CLEAN=cmd.exe /k "cd Util & call Protoc.bat --clean & exit"
|
||||
else
|
||||
BUILD_RULE=build_linux
|
||||
PROTOC_CALL=./Util/Protoc.sh
|
||||
PROTOC_COMPILE=./Util/Protoc.sh
|
||||
PROTOC_CLEAN=./Util/Protoc.sh --clean
|
||||
endif
|
||||
|
||||
default: release
|
||||
|
@ -42,7 +44,7 @@ call_cmake: protobuf
|
|||
cd $(BUILD_FOLDER) && cmake $(MY_CMAKE_FLAGS) "$(MY_CMAKE_FOLDER)"
|
||||
|
||||
protobuf:
|
||||
$(PROTOC_CALL)
|
||||
$(PROTOC_COMPILE)
|
||||
|
||||
### Docs #######################################################################
|
||||
|
||||
|
@ -54,7 +56,7 @@ docs:
|
|||
|
||||
clean:
|
||||
rm -Rf $(BASE_BUILD_FOLDER) $(INSTALL_FOLDER) Doxygen
|
||||
$(PROTOC_CALL) --clean
|
||||
$(PROTOC_CLEAN)
|
||||
|
||||
### Test #######################################################################
|
||||
|
||||
|
|
|
@ -98,10 +98,21 @@ public class Carla : ModuleRules
|
|||
};
|
||||
|
||||
// Link dependencies.
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("c++abi")));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("boost_system")));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("protobuf")));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName(CarlaServerLib)));
|
||||
if (IsWindows(Target))
|
||||
{
|
||||
// Auto-links boost libraries in folder.
|
||||
PublicLibraryPaths.Add(Path.Combine(CarlaServerInstallPath, "lib"));
|
||||
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("libprotobuf")));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName(CarlaServerLib)));
|
||||
}
|
||||
else
|
||||
{
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("c++abi")));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("boost_system")));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("protobuf")));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName(CarlaServerLib)));
|
||||
}
|
||||
|
||||
// Include path.
|
||||
string CarlaServerIncludePath = Path.Combine(CarlaServerInstallPath, "include");
|
||||
|
|
|
@ -124,7 +124,7 @@ CarlaServer::ErrorCode CarlaServer::SendSceneDescription(
|
|||
const int32 NumberOfStartSpots = AvailableStartSpots.Num();
|
||||
auto StartSpots = MakeUnique<carla_transform[]>(NumberOfStartSpots);
|
||||
|
||||
for (auto i = 0u; i < NumberOfStartSpots; ++i) {
|
||||
for (auto i = 0; i < NumberOfStartSpots; ++i) {
|
||||
Set(StartSpots[i], AvailableStartSpots[i]->GetActorTransform());
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ CarlaServer::ErrorCode CarlaServer::SendMeasurements(
|
|||
TUniquePtr<carla_image[]> images;
|
||||
if (NumberOfImages > 0) {
|
||||
images = MakeUnique<carla_image[]>(NumberOfImages);
|
||||
for (auto i = 0u; i < NumberOfImages; ++i) {
|
||||
for (auto i = 0; i < NumberOfImages; ++i) {
|
||||
Set(images[i], PlayerState.GetImages()[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
@echo off
|
||||
|
||||
set PROTOBUF_SRC_DIR=Proto
|
||||
set PROTOBUF_CPP_OUT_DIR=CarlaServer/source/carla/server
|
||||
set PROTOBUF_PY_OUT_DIR=PythonClient
|
||||
set PROTO_BASENAME=carla_server
|
||||
|
||||
if "%1" == "--clean" (
|
||||
rem Delete existing ones.
|
||||
rm -f %PROTOBUF_CPP_OUT_DIR%/*.pb.h %PROTOBUF_CPP_OUT_DIR%/*.pb.cc
|
||||
rm -f %PROTOBUF_PY_OUT_DIR%/*_pb2.py
|
||||
goto end
|
||||
)
|
||||
|
||||
set PROTOC=Build\protobuf-install\bin\protoc.exe
|
||||
|
||||
if exist %PROTOC% (
|
||||
|
||||
echo Compiling %PROTO_BASENAME%.proto...
|
||||
|
||||
%PROTOC% ^
|
||||
-I=%PROTOBUF_SRC_DIR% ^
|
||||
--cpp_out=%PROTOBUF_CPP_OUT_DIR% ^
|
||||
--python_out=%PROTOBUF_PY_OUT_DIR% ^
|
||||
%PROTOBUF_SRC_DIR%/%PROTO_BASENAME%.proto
|
||||
|
||||
echo done.
|
||||
|
||||
) else (
|
||||
|
||||
echo ERROR: Missing protobuf compiler: %PROTOC%
|
||||
exit /b
|
||||
|
||||
)
|
||||
|
||||
:end
|
|
@ -8,4 +8,27 @@ set(CARLA_BOOST_INSTALL_PATH "${CARLA_UTIL_PATH}/Build/boost-install")
|
|||
set(CARLA_PROTOBUF_INSTALL_PATH "${CARLA_UTIL_PATH}/Build/protobuf-install")
|
||||
set(CARLA_GOOGLETEST_INSTALL_PATH "${CARLA_UTIL_PATH}/Build/googletest-install")
|
||||
|
||||
# Suppress windows warning, http://stackoverflow.com/a/40217291
|
||||
if (WIN32)
|
||||
macro(get_WIN32_WINNT version)
|
||||
if (CMAKE_SYSTEM_VERSION)
|
||||
set(ver ${CMAKE_SYSTEM_VERSION})
|
||||
string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver})
|
||||
string(REGEX MATCH "^([0-9]+)" verMajor ${ver})
|
||||
# Check for Windows 10, b/c we'll need to convert to hex 'A'.
|
||||
if ("${verMajor}" MATCHES "10")
|
||||
set(verMajor "A")
|
||||
string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver})
|
||||
endif ("${verMajor}" MATCHES "10")
|
||||
# Remove all remaining '.' characters.
|
||||
string(REPLACE "." "" ver ${ver})
|
||||
# Prepend each digit with a zero.
|
||||
string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver})
|
||||
set(${version} "0x${ver}")
|
||||
endif(CMAKE_SYSTEM_VERSION)
|
||||
endmacro(get_WIN32_WINNT)
|
||||
get_WIN32_WINNT(ver)
|
||||
add_definitions(-D_WIN32_WINNT=${ver})
|
||||
endif(WIN32)
|
||||
|
||||
add_subdirectory("CarlaServer")
|
||||
|
|
|
@ -34,17 +34,14 @@ if (UNIX)
|
|||
include_directories("${CARLA_LIBCXX_INSTALL_PATH}/include/c++/v1")
|
||||
link_directories("${CARLA_LIBCXX_INSTALL_PATH}/lib")
|
||||
file(GLOB LibCXX_Static_Libraries "${CARLA_LIBCXX_INSTALL_PATH}/lib/libc++*.a")
|
||||
file(GLOB LibCXX_Shared_Libraries "${CARLA_LIBCXX_INSTALL_PATH}/lib/libc++*.so")
|
||||
|
||||
# Setup boost.
|
||||
include_directories("${CARLA_BOOST_INSTALL_PATH}/include")
|
||||
set(Boost_Static_Libraries "${CARLA_BOOST_INSTALL_PATH}/lib/libboost_system.a")
|
||||
file(GLOB Boost_Shared_Libraries "${CARLA_BOOST_INSTALL_PATH}/lib/libboost_system.so*")
|
||||
|
||||
# Setup protobuf.
|
||||
include_directories("${CARLA_PROTOBUF_INSTALL_PATH}/include")
|
||||
set(Protobuf_Static_Libraries "${CARLA_PROTOBUF_INSTALL_PATH}/lib/libprotobuf.a")
|
||||
file(GLOB Protobuf_Shared_Libraries "${CARLA_PROTOBUF_INSTALL_PATH}/lib/libprotobuf.so*")
|
||||
|
||||
# Setup googletest.
|
||||
include_directories("${CARLA_GOOGLETEST_INSTALL_PATH}/include")
|
||||
|
@ -56,6 +53,29 @@ if (UNIX)
|
|||
${Protobuf_Static_Libraries}
|
||||
DESTINATION lib)
|
||||
|
||||
elseif (WIN32)
|
||||
|
||||
# Setup boost.
|
||||
include_directories("${CARLA_BOOST_INSTALL_PATH}")
|
||||
file(GLOB Boost_System_Static_Libraries "${CARLA_BOOST_INSTALL_PATH}/stage/lib/libboost_system*.lib")
|
||||
file(GLOB Boost_DateTime_Static_Libraries "${CARLA_BOOST_INSTALL_PATH}/stage/lib/libboost_date_time*.lib")
|
||||
set(Boost_Static_Libraries
|
||||
"${Boost_System_Static_Libraries}"
|
||||
"${Boost_DateTime_Static_Libraries}")
|
||||
|
||||
# Setup protobuf.
|
||||
include_directories("${CARLA_PROTOBUF_INSTALL_PATH}/include")
|
||||
set(Protobuf_Static_Libraries "${CARLA_PROTOBUF_INSTALL_PATH}/lib/libprotobuf.lib")
|
||||
|
||||
# Setup googletest.
|
||||
include_directories("${CARLA_GOOGLETEST_INSTALL_PATH}/include")
|
||||
set(GTest_Static_Libraries "${CARLA_GOOGLETEST_INSTALL_PATH}/lib/gtest.lib")
|
||||
|
||||
install(FILES
|
||||
${Boost_Static_Libraries}
|
||||
${Protobuf_Static_Libraries}
|
||||
DESTINATION lib)
|
||||
|
||||
else (UNIX)
|
||||
message(FATAL_ERROR "Build configuration not yet available for this platform")
|
||||
endif (UNIX)
|
||||
|
@ -97,6 +117,8 @@ set(CarlaServer_Static_LIBRARIES
|
|||
${Boost_Static_Libraries}
|
||||
${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
add_executable(${CarlaServer_Test_Target} ${test_carlaserver_SRC})
|
||||
target_link_libraries(${CarlaServer_Test_Target} ${CarlaServer_Static_LIBRARIES})
|
||||
install(TARGETS ${CarlaServer_Test_Target} DESTINATION bin)
|
||||
if (UNIX)
|
||||
add_executable(${CarlaServer_Test_Target} ${test_carlaserver_SRC})
|
||||
target_link_libraries(${CarlaServer_Test_Target} ${CarlaServer_Static_LIBRARIES})
|
||||
install(TARGETS ${CarlaServer_Test_Target} DESTINATION bin)
|
||||
endif (UNIX)
|
||||
|
|
Loading…
Reference in New Issue