update cmake file

This commit is contained in:
wzlsuccess
2021-06-22 23:03:48 +08:00
parent f1f4c340a4
commit 48635daf07
13 changed files with 140 additions and 90 deletions

View File

@@ -25,16 +25,13 @@ endif ()
set(TUTORIAL_LIST
tutorial-00-helloworld
tutorial-01-wget
tutorial-02-redis_cli
tutorial-03-wget_to_redis
tutorial-04-http_echo_server
tutorial-05-http_proxy
tutorial-06-parallel_wget
tutorial-09-http_file_server
tutorial-07-sort_task
tutorial-08-matrix_multiply
tutorial-09-http_file_server
tutorial-11-graph_task
tutorial-12-mysql_cli
)
if (APPLE)
@@ -50,6 +47,31 @@ foreach(src ${TUTORIAL_LIST})
target_link_libraries(${bin_name} ${WORKFLOW_LIB})
endforeach()
if (REDIS STREQUAL "y")
set(TUTORIAL_LIST
tutorial-02-redis_cli
tutorial-03-wget_to_redis
)
foreach(src ${TUTORIAL_LIST})
string(REPLACE "-" ";" arr ${src})
list(GET arr -1 bin_name)
add_executable(${bin_name} ${src}.cc)
target_link_libraries(${bin_name} ${WORKFLOW_LIB})
endforeach()
endif()
if (MYSQL STREQUAL "y")
set(TUTORIAL_LIST
tutorial-12-mysql_cli
)
foreach(src ${TUTORIAL_LIST})
string(REPLACE "-" ";" arr ${src})
list(GET arr -1 bin_name)
add_executable(${bin_name} ${src}.cc)
target_link_libraries(${bin_name} ${WORKFLOW_LIB})
endforeach()
endif()
if (KAFKA STREQUAL "y")
add_executable("kafka_cli" "tutorial-13-kafka_cli.cc")
target_link_libraries("kafka_cli" wfkafka workflow z snappy lz4 zstd rt)

View File

@@ -6,21 +6,20 @@ DEFAULT_BUILD_DIR := build
BUILD_DIR := $(shell if [ -f $(MAKE_FILE) ]; then echo "."; else echo $(DEFAULT_BUILD_DIR); fi)
CMAKE3 := $(shell if which cmake3>/dev/null ; then echo cmake3; else echo cmake; fi;)
KAFKA ?= n
MYSQL ?= y
REDIS ?= y
UPSTREAM ?= y
.PHONY: $(ALL_TARGETS)
all:
mkdir -p $(BUILD_DIR)
ifeq ($(KAFKA),y)
KAFKA=y
else
KAFKA=n
endif
ifeq ($(DEBUG),y)
cd $(BUILD_DIR) && $(CMAKE3) -D CMAKE_BUILD_TYPE=Debug -D KAFKA=$(KAFKA) $(ROOT_DIR)
cd $(BUILD_DIR) && $(CMAKE3) -D CMAKE_BUILD_TYPE=Debug -D KAFKA=$(KAFKA) -D MYSQL=$(MYSQL) -D REDIS=$(REDIS) -D UPSTREAM=$(UPSTREAM) $(ROOT_DIR)
else
cd $(BUILD_DIR) && $(CMAKE3) -D KAFKA=$(KAFKA) $(ROOT_DIR)
cd $(BUILD_DIR) && $(CMAKE3) -D KAFKA=$(KAFKA) -D MYSQL=$(MYSQL) -D REDIS=$(REDIS) -D UPSTREAM=$(UPSTREAM) $(ROOT_DIR)
endif
make -C $(BUILD_DIR) -f Makefile
@@ -31,4 +30,3 @@ else ifeq (build, $(wildcard build))
-make -C build clean
endif
rm -rf build