Skip to content
Snippets Groups Projects
Commit e667e7b9 authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

CHG: Put grpc- and protobuf-generated sources in static library

This makes handling linker errors on Windows related to the protobuf
sources easier to handle.
parent 8221876d
No related branches found
No related tags found
2 merge requests!61Release 0.3.0,!54Resolve "Windows: Linker errors with protobuf-generated code"
Pipeline #54923 passed with warnings
Pipeline: CaosDB Octave library

#54926

    Pipeline: caosdb-julialib

    #54925

      Pipeline: caosdb-cppinttest

      #54924

        This commit is part of merge request !54. Comments created here will be created in the context of that merge request.
        ......@@ -136,12 +136,10 @@ add_custom_command(
        # add generated files to include path
        include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
        # show generated files
        message(DEBUG "GRPC_GENERATED: ${GRPC_GENERATED}")
        ###############################################################################
        ### Set up main targets
        ### * caosdb - The main library including the protobuf and grpc generated files.
        ### * caosdb_grpc - protobuf- and grpc-generated sources
        ### * caosdb - The main C++ library
        ### * cxxcaosdbcli - A C++ test client.
        ### * ccaosdb - A C-Wrapper of the C++ caosdb library.
        ### * ccaosdbcli - A plain C test client.
        ......@@ -165,13 +163,19 @@ message(DEBUG "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
        message(DEBUG "libcaosdb_SOURCE_DIR: ${libcaosdb_SOURCE_DIR}")
        message(DEBUG "libcaosdb_BINARY_DIR: ${libcaosdb_BINARY_DIR}")
        # libcaosdb_grpc
        # --------------
        add_library(caosdb_grpc STATIC ${GRPC_GENERATED})
        target_link_libraries(caosdb_grpc
        gRPC::grpc gRPC::grpc++ protobuf::libprotobuf
        )
        # libcaosdb
        # ---------
        add_library(caosdb SHARED
        ${libcaosdb_INCL} ${libcaosdb_SRC} ${GRPC_GENERATED})
        ${libcaosdb_INCL} ${libcaosdb_SRC})
        target_link_libraries(caosdb PUBLIC
        gRPC::grpc gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES}
        caosdb_grpc gRPC::grpc gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES}
        )
        set(LIBCAOSDB caosdb)
        ......@@ -184,10 +188,9 @@ target_include_directories(caosdb PUBLIC
        # libccaosdb
        # ----------
        add_library(ccaosdb SHARED src/ccaosdb.cpp ${GRPC_GENERATED})
        add_library(ccaosdb SHARED src/ccaosdb.cpp)
        target_link_libraries(ccaosdb PUBLIC
        caosdb
        gRPC::grpc gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES}
        caosdb caosdb_grpc gRPC::grpc gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES}
        )
        target_include_directories(ccaosdb PUBLIC
        $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include>
        ......@@ -195,6 +198,7 @@ target_include_directories(ccaosdb PUBLIC
        $<INSTALL_INTERFACE:include>
        )
        #set_target_properties(ccaosdb PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/caosdb.dir/${CMAKE_BUILD_TYPE}/exports.def")
        # ccaosdbcli
        # ----------
        ......@@ -204,10 +208,9 @@ target_include_directories(ccaosdbcli PUBLIC
        $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include>
        $<INSTALL_INTERFACE:include>
        )
        target_link_libraries(ccaosdbcli PRIVATE
        caosdb_grpc ccaosdb
        gRPC::grpc protobuf::libprotobuf ${Boost_LIBRARIES}
        ccaosdb
        )
        # cxxcaosdbcli
        ......@@ -219,7 +222,7 @@ target_include_directories(cxxcaosdbcli PUBLIC
        $<INSTALL_INTERFACE:include>
        )
        target_link_libraries(cxxcaosdbcli PRIVATE
        caosdb gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES}
        caosdb caosdb_grpc gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES}
        )
        ......@@ -346,10 +349,10 @@ endif()
        ### UNIT TEST
        #######################################################
        if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
        #if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
        enable_testing()
        add_subdirectory(test)
        endif()
        #endif()
        # ###############################################
        # ############ INSTALLATION #####################
        ......@@ -361,7 +364,7 @@ set(libcaosdb_LIB_DEST "lib")
        set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local/")
        install(
        # targets to install
        TARGETS ${LIBCAOSDB} ccaosdb
        TARGETS ${LIBCAOSDB} ccaosdb caosdb_grpc
        # name of the CMake "export group" containing the targets we want to install
        EXPORT caosdbTargets
        # Dynamic, static library and include destination locations after running
        ......
        ......@@ -61,11 +61,11 @@ list(LENGTH test_cases len_test_cases)
        math(EXPR len_test_cases "${len_test_cases} - 1")
        foreach (i RANGE "${len_test_cases}")
        list(GET test_cases ${i} test_case_name)
        add_executable(${test_case_name} ${test_case_name}.cpp ${GRPC_GENERATED})
        add_executable(${test_case_name} ${test_case_name}.cpp)
        set(libcaosdb_TEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${test_case_name}.cpp
        ${libcaosdb_TEST_SRC}")
        target_link_libraries(${test_case_name}
        PRIVATE GTest::gtest_main caosdb ccaosdb gtest::gtest)
        PRIVATE GTest::gtest_main caosdb ccaosdb gtest::gtest caosdb_grpc)
        target_include_directories(${test_case_name}
        PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR})
        if(_LINTING)
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment