Commit d42f3510 authored by Qihe Bian's avatar Qihe Bian Committed by Jiashun Zhu

Fix cmake build issue when use this project as a submodule. (#428)

* Fix cmake build issue when use this project as a submodule.
* Add ignore.
parent bda7a546
......@@ -32,3 +32,4 @@ cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
/cmake-build-debug/
This diff is collapsed.
......@@ -6,8 +6,8 @@ include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.0
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
SOURCE_DIR "${PROJECT_BINARY_DIR}/googletest-src"
BINARY_DIR "${PROJECT_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
......
# Setup googletest
configure_file("${CMAKE_SOURCE_DIR}/cmake/CMakeLists.download_gtest.in" ${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt)
configure_file("${PROJECT_SOURCE_DIR}/cmake/CMakeLists.download_gtest.in" ${PROJECT_BINARY_DIR}/googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/googletest-download
)
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
......@@ -11,7 +11,7 @@ endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/googletest-download
)
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
......@@ -19,6 +19,6 @@ endif()
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build
add_subdirectory(${PROJECT_BINARY_DIR}/googletest-src
${PROJECT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
......@@ -4,7 +4,7 @@ project(asynchronous_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(backup_request_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(cancel_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(cascade_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(dynamic_partition_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......@@ -132,5 +132,5 @@ add_executable(dynamic_partition_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEA
target_link_libraries(dynamic_partition_echo_client ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
target_link_libraries(dynamic_partition_echo_server ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
file(COPY ${CMAKE_SOURCE_DIR}/server_list
file(COPY ${PROJECT_SOURCE_DIR}/server_list
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
......@@ -4,7 +4,7 @@ project(echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(echo_c++_hulu_pbrpc C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(echo_c++_sofa_pbrpc C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(echo_c++_ubrpc_compack C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......@@ -122,7 +122,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()
execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${CMAKE_SOURCE_DIR} --plugin=protoc-gen-mcpack=${OUTPUT_PATH}/bin/protoc-gen-mcpack --mcpack_out=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/echo.proto
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${PROJECT_SOURCE_DIR} --plugin=protoc-gen-mcpack=${OUTPUT_PATH}/bin/protoc-gen-mcpack --mcpack_out=${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/echo.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
......
......@@ -4,7 +4,7 @@ project(http_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......@@ -135,7 +135,7 @@ target_link_libraries(http_server ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRAR
target_link_libraries(http_client ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
target_link_libraries(benchmark_http ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
file(COPY ${CMAKE_SOURCE_DIR}/key.pem
file(COPY ${PROJECT_SOURCE_DIR}/key.pem
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_SOURCE_DIR}/cert.pem
file(COPY ${PROJECT_SOURCE_DIR}/cert.pem
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
......@@ -4,7 +4,7 @@ project(memcache_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(multi_threaded_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(multi_threaded_echo_fns_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(multi_threaded_mcpack_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......@@ -127,7 +127,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()
execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${CMAKE_SOURCE_DIR} --plugin=protoc-gen-mcpack=${OUTPUT_PATH}/bin/protoc-gen-mcpack --mcpack_out=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/echo.proto
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${PROJECT_SOURCE_DIR} --plugin=protoc-gen-mcpack=${OUTPUT_PATH}/bin/protoc-gen-mcpack --mcpack_out=${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/echo.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
......
......@@ -4,7 +4,7 @@ project(nshead_extension_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(nshead_pb_extension_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(parallel_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(partition_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......@@ -132,5 +132,5 @@ add_executable(server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(client ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
target_link_libraries(server ${BRPC_LIB} ${DYNAMIC_LIB} ${GPERFTOOLS_LIBRARIES})
file(COPY ${CMAKE_SOURCE_DIR}/server_list
file(COPY ${PROJECT_SOURCE_DIR}/server_list
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
......@@ -12,7 +12,7 @@ project(redis_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(selective_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(session_data_and_thread_local C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(streaming_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -7,7 +7,7 @@ elseif(NOT DEBUG)
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/src)
add_library(BUTIL_LIB OBJECT ${BUTIL_SOURCES})
add_library(OBJ_LIB OBJECT ${SOURCES})
......@@ -38,10 +38,10 @@ SET_TARGET_PROPERTIES(brpc-static PROPERTIES OUTPUT_NAME brpc CLEAN_DIRECT_OUTPU
SET_TARGET_PROPERTIES(brpc-shared PROPERTIES OUTPUT_NAME brpc CLEAN_DIRECT_OUTPUT 1)
# for protoc-gen-mcpack
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/output/bin)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/output/bin)
set(protoc_gen_mcpack_SOURCES
${CMAKE_SOURCE_DIR}/src/mcpack2pb/generator.cpp
${PROJECT_SOURCE_DIR}/src/mcpack2pb/generator.cpp
)
add_executable(protoc-gen-mcpack ${protoc_gen_mcpack_SOURCES})
target_link_libraries(protoc-gen-mcpack brpc-shared)
......
......@@ -333,7 +333,8 @@ static void GlobalInitializeOrDieImpl() {
#endif
NamingServiceExtension()->RegisterOrDie("file", &g_ext->fns);
NamingServiceExtension()->RegisterOrDie("list", &g_ext->lns);
NamingServiceExtension()->RegisterOrDie("http", &g_ext->dns);
NamingServiceExtension()->RegisterOrDie("http", &g_ext->dns);
NamingServiceExtension()->RegisterOrDie("redis", &g_ext->dns);
NamingServiceExtension()->RegisterOrDie("remotefile", &g_ext->rfns);
NamingServiceExtension()->RegisterOrDie("consul", &g_ext->cns);
......
This diff is collapsed.
set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -D__STRICT_ANSI__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
use_cxx11()
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/output/bin)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/output/bin)
add_subdirectory(parallel_http)
add_subdirectory(rpc_press)
......
file(GLOB SOURCES "${CMAKE_SOURCE_DIR}/tools/rpc_press/*.cpp")
file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/tools/rpc_press/*.cpp")
add_executable(rpc_press ${SOURCES})
target_link_libraries(rpc_press brpc-static ${DYNAMIC_LIB})
file(GLOB SOURCES "${CMAKE_SOURCE_DIR}/tools/rpc_replay/*.cpp")
file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/tools/rpc_replay/*.cpp")
add_executable(rpc_replay ${SOURCES})
target_link_libraries(rpc_replay brpc-static ${DYNAMIC_LIB})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment