diff --git a/CMakeLists.txt b/CMakeLists.txt index 766d82ae73187262ea32df882e68d16aabd8fad5..5663ac49c8d8ba3115cb392e37abc44059eb2277 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,9 @@ add_custom_command( ${PROTO_FILES} DEPENDS ${PROTO_FILES}) +# show generated files +message(DEBUG "GRPC_GENERATED: ${GRPC_GENERATED}") + ############################################################################### ### Set up main targets ### * [caosdb_grpc] - only in Debug builds. Otherwise this library is compiled @@ -157,51 +160,66 @@ add_custom_command( ### * ccaosdbcli - A plain C test client. ############################################################################### -find_package(gRPC) -find_package(protobuf) -find_package(Boost) -find_package(GTest) +find_package(gRPC CONFIG REQUIRED) +find_package(Protobuf CONFIG REQUIRED) +find_package(Boost REQUIRED) +find_package(GTest REQUIRED) + +# print include directories for debugging +message(DEBUG "CMAKE_INCLUDE_PATH: ${CMAKE_INCLUDE_PATH}") +message(DEBUG "PROTOBUF_INCLUDE_DIRS: ${PROTOBUF_INCLUDE_DIRS}") +message(DEBUG "gRPC_INCLUDE_DIRS: ${gRPC_INCLUDE_DIRS}") + # libcaosdb +# --------- + +# In Debug, build separate libraries for grpc-generated code and caosdb if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") - add_library(caosdb_grpc SHARED ${GRPC_GENERATED}) - add_library(caosdb SHARED ${libcaosdb_INCL} ${libcaosdb_SRC}) - target_link_libraries(caosdb caosdb_grpc - grpc::grpc protobuf::protobuf boost::boost gtest::gtest) - set(LIBCAOSDB caosdb caosdb_grpc) - - target_include_directories(caosdb_grpc PUBLIC - $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> - $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> + + add_library(caosdb_grpc SHARED ${GRPC_GENERATED}) + target_link_libraries(caosdb_grpc + grpc::grpc protobuf::protobuf boost::boost + ) + target_include_directories(caosdb_grpc PUBLIC + $<BUILD_INTERFACE:${PROJECT_INCLUDE_DIR}> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> - ) - target_include_directories(caosdb_grpc SYSTEM PUBLIC - ${CONAN_INCLUDE_DIRS} - ) + ) + + add_library(caosdb SHARED ${libcaosdb_INCL} ${libcaosdb_SRC}) + + target_link_libraries(caosdb + caosdb_grpc grpc::grpc protobuf::protobuf boost::boost + ) + + set(LIBCAOSDB caosdb caosdb_grpc) else() - add_library(caosdb - SHARED ${libcaosdb_INCL} ${libcaosdb_SRC} ${GRPC_GENERATED}) - set(LIBCAOSDB caosdb) + add_library(caosdb + SHARED ${libcaosdb_INCL} ${libcaosdb_SRC} ${GRPC_GENERATED}) + target_link_libraries(caosdb + grpc::grpc protobuf::protobuf boost::boost + stdc++fs + ) + set(LIBCAOSDB caosdb) endif() -target_link_libraries(caosdb - grpc::grpc protobuf::protobuf boost::boost gtest::gtest - stdc++fs -) + target_include_directories(caosdb PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/src> $<INSTALL_INTERFACE:include> ) -target_include_directories(caosdb SYSTEM PUBLIC - ${CONAN_INCLUDE_DIRS} -) + + + # libccaosdb +# ---------- add_library(ccaosdb SHARED src/ccaosdb.cpp) target_link_libraries(ccaosdb - grpc::grpc protobuf::protobuf boost::boost gtest::gtest + grpc::grpc protobuf::protobuf boost::boost ${LIBCAOSDB} stdc++fs ) @@ -224,11 +242,13 @@ target_include_directories(ccaosdbcli SYSTEM PUBLIC ) target_link_libraries(ccaosdbcli - grpc::grpc protobuf::protobuf boost::boost gtest::gtest + grpc::grpc protobuf::protobuf boost::boost ${LIBCAOSDB} ccaosdb ) +# cxxcaosdbcli +# ------------ add_executable(cxxcaosdbcli EXCLUDE_FROM_ALL src/cxxcaosdbcli.cpp) target_include_directories(cxxcaosdbcli PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> @@ -240,7 +260,7 @@ target_include_directories(cxxcaosdbcli SYSTEM PUBLIC ) target_link_libraries(cxxcaosdbcli ${LIBCAOSDB} - grpc::grpc protobuf::protobuf boost::boost gtest::gtest + grpc::grpc protobuf::protobuf boost::boost )