2019-04-16 19:15:36 +08:00
|
|
|
CARLADIR=$(CURDIR)/../..
|
|
|
|
BUILDDIR=$(CURDIR)/build
|
|
|
|
BINDIR=$(CURDIR)/bin
|
|
|
|
INSTALLDIR=$(CURDIR)/libcarla-install
|
|
|
|
TOOLCHAIN=$(CURDIR)/ToolChain.cmake
|
|
|
|
|
2022-04-19 23:06:38 +08:00
|
|
|
CC=/usr/bin/gcc-7
|
|
|
|
CXX=/usr/bin/g++-7
|
2019-04-16 19:15:36 +08:00
|
|
|
CXXFLAGS=-std=c++14 -pthread -fPIC -O3 -DNDEBUG -Werror -Wall -Wextra
|
|
|
|
|
|
|
|
define log
|
|
|
|
@echo "\033[1;35m$(1)\033[0m"
|
|
|
|
endef
|
|
|
|
|
|
|
|
default: build
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@rm -rf $(BUILDDIR) $(INSTALLDIR)
|
|
|
|
@rm -f ToolChain.cmake
|
|
|
|
|
|
|
|
run: build
|
|
|
|
$(call log,Running C++ Client...)
|
2019-04-16 20:09:55 +08:00
|
|
|
@$(BINDIR)/cpp_client $(ARGS)
|
2019-04-16 19:15:36 +08:00
|
|
|
|
2020-03-05 20:16:18 +08:00
|
|
|
run.only:
|
|
|
|
$(call log,Running C++ Client...)
|
|
|
|
@$(BINDIR)/cpp_client $(ARGS)
|
|
|
|
|
2019-04-16 19:15:36 +08:00
|
|
|
build: $(BINDIR)/cpp_client
|
|
|
|
|
2020-03-05 20:16:18 +08:00
|
|
|
$(BINDIR)/cpp_client: | build_libcarla
|
2019-04-16 19:15:36 +08:00
|
|
|
$(call log,Compiling C++ Client...)
|
|
|
|
@mkdir -p $(BINDIR)
|
2019-04-23 18:04:56 +08:00
|
|
|
@$(CXX) $(CXXFLAGS) -I$(INSTALLDIR)/include -isystem $(INSTALLDIR)/include/system -L$(INSTALLDIR)/lib \
|
2019-04-16 19:15:36 +08:00
|
|
|
-o $(BINDIR)/cpp_client main.cpp \
|
|
|
|
-Wl,-Bstatic -lcarla_client -lrpc -lboost_filesystem -Wl,-Bdynamic \
|
2019-06-18 00:24:47 +08:00
|
|
|
-lpng -ltiff -ljpeg -lRecast -lDetour -lDetourCrowd
|
2019-04-16 19:15:36 +08:00
|
|
|
|
|
|
|
build_libcarla: $(TOOLCHAIN)
|
|
|
|
@cd $(CARLADIR); make setup
|
|
|
|
@mkdir -p $(BUILDDIR)
|
|
|
|
$(call log,Compiling LibCarla.client...)
|
|
|
|
@{ \
|
|
|
|
cd $(BUILDDIR); \
|
|
|
|
if [ ! -f "build.ninja" ]; then \
|
|
|
|
cmake \
|
|
|
|
-G "Ninja" \
|
|
|
|
-DCMAKE_BUILD_TYPE=Client \
|
|
|
|
-DLIBCARLA_BUILD_RELEASE=ON \
|
|
|
|
-DLIBCARLA_BUILD_DEBUG=OFF \
|
|
|
|
-DLIBCARLA_BUILD_TEST=OFF \
|
|
|
|
-DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN) \
|
|
|
|
-DCMAKE_INSTALL_PREFIX=$(INSTALLDIR) \
|
|
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
|
|
|
|
$(CARLADIR); \
|
|
|
|
fi; \
|
|
|
|
ninja; \
|
|
|
|
ninja install | grep -v "Up-to-date:"; \
|
|
|
|
}
|
|
|
|
|
|
|
|
$(TOOLCHAIN):
|
|
|
|
@echo "set(CMAKE_C_COMPILER $(CC))" > $(TOOLCHAIN)
|
|
|
|
@echo "set(CMAKE_CXX_COMPILER $(CXX))" >> $(TOOLCHAIN)
|
|
|
|
@echo "set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(CXXFLAGS)\" CACHE STRING \"\" FORCE)" >> $(TOOLCHAIN)
|