2019-04-16 19:15:36 +08:00
|
|
|
CARLADIR=$(CURDIR)/../..
|
|
|
|
BUILDDIR=$(CURDIR)/build
|
|
|
|
BINDIR=$(CURDIR)/bin
|
|
|
|
INSTALLDIR=$(CURDIR)/libcarla-install
|
|
|
|
TOOLCHAIN=$(CURDIR)/ToolChain.cmake
|
|
|
|
|
2019-09-06 23:04:54 +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
|
|
|
|
|
|
|
build: $(BINDIR)/cpp_client
|
|
|
|
|
|
|
|
$(BINDIR)/cpp_client: build_libcarla
|
|
|
|
$(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)
|