61 lines
1.5 KiB
Makefile
61 lines
1.5 KiB
Makefile
|
CARLADIR=$(CURDIR)/../..
|
||
|
BUILDDIR=$(CURDIR)/build
|
||
|
BINDIR=$(CURDIR)/bin
|
||
|
INSTALLDIR=$(CURDIR)/libcarla-install
|
||
|
TOOLCHAIN=$(CURDIR)/ToolChain.cmake
|
||
|
|
||
|
CC=/usr/bin/clang-6.0
|
||
|
CXX=/usr/bin/clang++-6.0
|
||
|
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...)
|
||
|
@$(BINDIR)/cpp_client
|
||
|
|
||
|
build: $(BINDIR)/cpp_client
|
||
|
|
||
|
$(BINDIR)/cpp_client: build_libcarla
|
||
|
$(call log,Compiling C++ Client...)
|
||
|
@mkdir -p $(BINDIR)
|
||
|
@$(CXX) $(CXXFLAGS) -I$(INSTALLDIR)/include -L$(INSTALLDIR)/lib \
|
||
|
-o $(BINDIR)/cpp_client main.cpp \
|
||
|
-Wl,-Bstatic -lcarla_client -lrpc -lboost_filesystem -Wl,-Bdynamic \
|
||
|
-lpng -ltiff -ljpeg
|
||
|
|
||
|
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)
|