Browse Source

Fix installation rules

- Add support of the custom install paths for the add_*
  functions.
- Move installation rules to the end of the project, to make sure
  that the generated headers are included to the PUBLIC_HEADER
  set of the target.
- Add the generated headers to the target if it's specified in
  qtprotobuf_generate function call.

Fixes: #197
Alexey Edelev 3 years ago
parent
commit
6d5b1c4a11

+ 2 - 0
CMakeLists.txt

@@ -146,3 +146,5 @@ if(QT_PROTOBUF_INSTALL)
     include(packaging)
     include(packaging)
 endif()
 endif()
 include(doxygen)
 include(doxygen)
+
+qt_protobuf_internal_install_targets()

+ 4 - 1
cmake/QtProtobufGen.cmake

@@ -120,7 +120,7 @@ function(qtprotobuf_generate)
         endif()
         endif()
     endforeach()
     endforeach()
 
 
-    set_source_files_properties(${GENERATED_SOURCES_FULL} PROPERTIES
+    set_source_files_properties(${GENERATED_SOURCES_FULL};${GENERATED_HEADERS_FULL} PROPERTIES
         GENERATED TRUE
         GENERATED TRUE
         SKIP_AUTOMOC ON
         SKIP_AUTOMOC ON
         SKIP_AUTOUIC ON
         SKIP_AUTOUIC ON
@@ -148,6 +148,9 @@ function(qtprotobuf_generate)
 
 
     add_library(${GENERATED_TARGET_NAME} OBJECT ${GENERATED_SOURCES_FULL} ${MOC_SOURCES})
     add_library(${GENERATED_TARGET_NAME} OBJECT ${GENERATED_SOURCES_FULL} ${MOC_SOURCES})
     add_dependencies(${GENERATED_TARGET_NAME} ${deps_target})
     add_dependencies(${GENERATED_TARGET_NAME} ${deps_target})
+    if(qtprotobuf_generate_TARGET)
+        set_property(TARGET ${qtprotobuf_generate_TARGET} APPEND PROPERTY PUBLIC_HEADER ${GENERATED_HEADERS_FULL})
+    endif()
     set_target_properties(${GENERATED_TARGET_NAME} PROPERTIES PUBLIC_HEADER "${GENERATED_HEADERS_FULL}")
     set_target_properties(${GENERATED_TARGET_NAME} PROPERTIES PUBLIC_HEADER "${GENERATED_HEADERS_FULL}")
 
 
     #Add include directories in case if targets are found by find_project or in source tree
     #Add include directories in case if targets are found by find_project or in source tree

+ 101 - 45
cmake/QtProtobufInternalHelpers.cmake

@@ -2,9 +2,9 @@ set(_qtprotobuf_all_known_multi_args SOURCES PUBLIC_HEADER INCLUDE_DIRECTORIES L
     PUBLIC_LIBRARIES PUBLIC_INCLUDE_DIRECTORIES DEFINES PUBLIC_DEFINES)
     PUBLIC_LIBRARIES PUBLIC_INCLUDE_DIRECTORIES DEFINES PUBLIC_DEFINES)
 
 
 function(qtprotobuf_parse_arguments prefix option single multi)
 function(qtprotobuf_parse_arguments prefix option single multi)
-    cmake_parse_arguments(arg "" "" "${_qtprotobuf_all_known_multi_args}" ${ARGN})
-    foreach(_arg IN LISTS _qtprotobuf_all_known_multi_args)
-        if(${_arg} IN_LIST multi)
+    cmake_parse_arguments(arg "${option}" "${single}" "${_qtprotobuf_all_known_multi_args}" ${ARGN})
+    foreach(_arg IN ITEMS ${_qtprotobuf_all_known_multi_args};${single};${option})
+        if(${_arg} IN_LIST multi OR ${_arg} IN_LIST single OR ${_arg} IN_LIST option)
             set(${prefix}_${_arg} ${arg_${_arg}} PARENT_SCOPE)
             set(${prefix}_${_arg} ${arg_${_arg}} PARENT_SCOPE)
         else()
         else()
             list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${_arg} ${arg_${_arg}})
             list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${_arg} ${arg_${_arg}})
@@ -25,12 +25,12 @@ function(qt_protobuf_internal_add_test)
         cmake_policy(SET CMP0071 NEW)
         cmake_policy(SET CMP0071 NEW)
     endif()
     endif()
 
 
-    set(GENERATED_SOURCES_DIR ${CMAKE_CURRENT_BINARY_DIR}/${add_test_target_TARGET}_generated)
+    set(GENERATED_SOURCES_DIR "${CMAKE_CURRENT_BINARY_DIR}/${add_test_target_TARGET}_generated")
 
 
     if(DEFINED add_test_target_PROTO_FILES)
     if(DEFINED add_test_target_PROTO_FILES)
         file(GLOB PROTO_FILES ABSOLUTE ${add_test_target_PROTO_FILES})
         file(GLOB PROTO_FILES ABSOLUTE ${add_test_target_PROTO_FILES})
     else()
     else()
-        file(GLOB PROTO_FILES ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto)
+        file(GLOB PROTO_FILES ABSOLUTE "${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto")
     endif()
     endif()
 
 
     add_executable(${add_test_target_TARGET} ${add_test_target_SOURCES})
     add_executable(${add_test_target_TARGET} ${add_test_target_SOURCES})
@@ -149,16 +149,22 @@ endfunction()
 function(qt_protobuf_internal_add_library target)
 function(qt_protobuf_internal_add_library target)
     qtprotobuf_parse_arguments(arg
     qtprotobuf_parse_arguments(arg
         ""
         ""
-        ""
+        "INSTALL_LIBDIR;INSTALL_INCLUDEDIR"
         "SOURCES;PUBLIC_HEADER"
         "SOURCES;PUBLIC_HEADER"
         ${ARGN}
         ${ARGN}
     )
     )
     set(target_export "${QT_PROTOBUF_NAMESPACE}${target}Targets")
     set(target_export "${QT_PROTOBUF_NAMESPACE}${target}Targets")
     set(target_config "${QT_PROTOBUF_NAMESPACE}${target}Config")
     set(target_config "${QT_PROTOBUF_NAMESPACE}${target}Config")
 
 
-    set(target_include_dir ${CMAKE_INSTALL_INCLUDEDIR}/${prefixed_target})
-    set(target_lib_dir ${CMAKE_INSTALL_LIBDIR})
-    set(target_cmake_dir ${CMAKE_INSTALL_LIBDIR}/cmake/${QT_PROTOBUF_NAMESPACE})
+    if(arg_INSTALL_INCLUDEDIR)
+        set(target_install_includedir "${arg_INSTALL_INCLUDEDIR}")
+    else()
+        set(target_install_includedir
+            "${CMAKE_INSTALL_INCLUDEDIR}/${QT_PROTOBUF_NAMESPACE}${target}"
+        )
+    endif()
+    set(target_install_libdir "${CMAKE_INSTALL_LIBDIR}")
+    set(target_install_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake/${QT_PROTOBUF_NAMESPACE}")
 
 
     set(CMAKE_AUTOMOC ON)
     set(CMAKE_AUTOMOC ON)
     set(CMAKE_AUTORCC ON)
     set(CMAKE_AUTORCC ON)
@@ -204,7 +210,7 @@ function(qt_protobuf_internal_add_library target)
         PUBLIC
         PUBLIC
            "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
            "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
            "$<BUILD_INTERFACE:${QT_PROTOBUF_BINARY_DIR}/include/${target}>"
            "$<BUILD_INTERFACE:${QT_PROTOBUF_BINARY_DIR}/include/${target}>"
-           "$<INSTALL_INTERFACE:${target_include_dir}>"
+           "$<INSTALL_INTERFACE:${target_install_includedir}>"
     )
     )
 
 
     qt_protobuf_internal_extend_target(${target} ${arg_UNPARSED_ARGUMENTS}
     qt_protobuf_internal_extend_target(${target} ${arg_UNPARSED_ARGUMENTS}
@@ -216,32 +222,30 @@ function(qt_protobuf_internal_add_library target)
     include(CMakePackageConfigHelpers)
     include(CMakePackageConfigHelpers)
     configure_package_config_file("Qt${target}Config.cmake.in"
     configure_package_config_file("Qt${target}Config.cmake.in"
         "${QT_PROTOBUF_BINARY_DIR}/${target_config}.cmake"
         "${QT_PROTOBUF_BINARY_DIR}/${target_config}.cmake"
-        INSTALL_DESTINATION "${target_cmake_dir}"
+        INSTALL_DESTINATION "${target_install_cmakedir}"
+    )
+
+    export(TARGETS ${target}
+        NAMESPACE ${QT_PROTOBUF_NAMESPACE}::
+        FILE ${target_export}.cmake
     )
     )
 
 
     if(QT_PROTOBUF_INSTALL)
     if(QT_PROTOBUF_INSTALL)
-        install(TARGETS ${target}
-            EXPORT ${target_export} COMPONENT dev
-            ARCHIVE DESTINATION ${target_lib_dir} COMPONENT lib
-            PUBLIC_HEADER DESTINATION ${target_include_dir} COMPONENT dev
-            LIBRARY DESTINATION ${target_lib_dir} COMPONENT lib
-            RUNTIME DESTINATION ${target_cmake_dir} COMPONENT lib)
+        if(NOT arg_INSTALL_LIBDIR)
+            unset(arg_INSTALL_LIBDIR)
+        endif()
 
 
-        install(EXPORT ${target_export}
-            NAMESPACE ${QT_PROTOBUF_NAMESPACE}::
-            FILE ${target_export}.cmake
-            DESTINATION ${target_cmake_dir}
-            COMPONENT dev)
+        if(NOT arg_INSTALL_INCLUDEDIR)
+            unset(arg_INSTALL_INCLUDEDIR)
+        endif()
 
 
-        install(FILES "${QT_PROTOBUF_BINARY_DIR}/${target_config}.cmake"
-            DESTINATION "${target_cmake_dir}"
-            COMPONENT dev)
+        set_target_properties(${target} PROPERTIES
+            qt_protobuf_install_libdir "${arg_INSTALL_LIBDIR}"
+            qt_protobuf_install_includedir "${arg_INSTALL_INCLUDEDIR}"
+        )
+        set_property(GLOBAL APPEND PROPERTY qt_protobuf_install_targets ${target})
     endif()
     endif()
 
 
-    export(TARGETS ${target}
-        NAMESPACE ${QT_PROTOBUF_NAMESPACE}::
-        FILE ${target_export}.cmake)
-
     qt_protobuf_internal_add_coverage_target(TARGET ${target})
     qt_protobuf_internal_add_coverage_target(TARGET ${target})
 endfunction()
 endfunction()
 
 
@@ -310,15 +314,14 @@ endfunction()
 function(qt_protobuf_internal_add_executable target)
 function(qt_protobuf_internal_add_executable target)
     qtprotobuf_parse_arguments(arg
     qtprotobuf_parse_arguments(arg
         ""
         ""
-        ""
+        "INSTALL_BINDIR"
         "SOURCES"
         "SOURCES"
         ${ARGN}
         ${ARGN}
     )
     )
     set(target_export "${QT_PROTOBUF_NAMESPACE}${target}Targets")
     set(target_export "${QT_PROTOBUF_NAMESPACE}${target}Targets")
     set(target_config "${QT_PROTOBUF_NAMESPACE}${target}Config")
     set(target_config "${QT_PROTOBUF_NAMESPACE}${target}Config")
 
 
-    set(target_cmake_dir ${CMAKE_INSTALL_LIBDIR}/cmake/${QT_PROTOBUF_NAMESPACE})
-    set(target_bindir ${CMAKE_INSTALL_BINDIR})
+    set(target_install_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake/${QT_PROTOBUF_NAMESPACE}")
 
 
     file(GLOB sources ${arg_SOURCES})
     file(GLOB sources ${arg_SOURCES})
     add_executable(${target} ${sources})
     add_executable(${target} ${sources})
@@ -332,23 +335,76 @@ function(qt_protobuf_internal_add_executable target)
     include(CMakePackageConfigHelpers)
     include(CMakePackageConfigHelpers)
     configure_package_config_file("Qt${target}Config.cmake.in"
     configure_package_config_file("Qt${target}Config.cmake.in"
         "${QT_PROTOBUF_BINARY_DIR}/${target_config}.cmake"
         "${QT_PROTOBUF_BINARY_DIR}/${target_config}.cmake"
-        INSTALL_DESTINATION "${target_cmake_dir}"
+        INSTALL_DESTINATION "${target_install_cmakedir}"
     )
     )
 
 
+    export(TARGETS ${target} NAMESPACE ${QT_PROTOBUF_NAMESPACE}:: FILE ${target_export}.cmake)
+
     if(QT_PROTOBUF_INSTALL)
     if(QT_PROTOBUF_INSTALL)
-        install(TARGETS ${target}
-            EXPORT ${target_export} COMPONENT dev
-            RUNTIME DESTINATION ${target_bindir}
-            COMPONENT lib)
+        if(arg_INSTALL_BINDIR)
+            set_target_properties(${target} PROPERTIES
+                qt_protobuf_install_bindir "${arg_INSTALL_BINDIR}"
+            )
+        endif()
+        set_property(GLOBAL APPEND PROPERTY qt_protobuf_install_targets ${target})
+    endif()
+endfunction()
+
+function(qt_protobuf_internal_install_targets)
+    if(NOT QT_PROTOBUF_INSTALL)
+        return()
+    endif()
+    get_property(install_targets GLOBAL PROPERTY qt_protobuf_install_targets)
+
+    list(REMOVE_DUPLICATES install_targets)
+    foreach(target ${install_targets})
+        set(target_config "${QT_PROTOBUF_NAMESPACE}${target}Config")
+        set(target_export "${QT_PROTOBUF_NAMESPACE}${target}Targets")
+        set(target_install_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake/${QT_PROTOBUF_NAMESPACE}")
+
+        get_target_property(type ${target} TYPE)
+        if("${type}" STREQUAL "EXECUTABLE")
+            get_target_property(target_install_bindir ${target} qt_protobuf_install_bindir)
+            if(NOT target_install_bindir)
+                set(target_install_bindir "${CMAKE_INSTALL_BINDIR}")
+            endif()
+
+            install(TARGETS ${target}
+                EXPORT ${target_export} COMPONENT dev
+                RUNTIME DESTINATION "${target_install_bindir}" COMPONENT lib
+            )
+        else()
+            set(target_install_bindir "${CMAKE_INSTALL_BINDIR}")
+            get_target_property(target_install_includedir ${target} qt_protobuf_install_includedir)
+            if(NOT target_install_includedir)
+                set(target_install_includedir
+                    "${CMAKE_INSTALL_INCLUDEDIR}/${QT_PROTOBUF_NAMESPACE}${target}"
+                )
+            endif()
+
+            get_target_property(target_install_libdir ${target} qt_protobuf_install_libdir)
+            if(NOT target_install_libdir)
+                set(target_install_libdir "${CMAKE_INSTALL_LIBDIR}")
+            endif()
+
+            install(TARGETS ${target}
+                EXPORT ${target_export} COMPONENT dev
+                ARCHIVE DESTINATION "${target_install_libdir}" COMPONENT lib
+                PUBLIC_HEADER DESTINATION "${target_install_includedir}" COMPONENT dev
+                LIBRARY DESTINATION "${target_install_libdir}" COMPONENT lib
+                RUNTIME DESTINATION "${target_install_bindir}" COMPONENT lib
+            )
+        endif()
+
         install(EXPORT ${target_export}
         install(EXPORT ${target_export}
             NAMESPACE ${QT_PROTOBUF_NAMESPACE}::
             NAMESPACE ${QT_PROTOBUF_NAMESPACE}::
             FILE ${target_export}.cmake
             FILE ${target_export}.cmake
-            DESTINATION ${target_cmake_dir}
-            COMPONENT dev)
+            DESTINATION "${target_install_cmakedir}"
+            COMPONENT dev
+        )
         install(FILES "${QT_PROTOBUF_BINARY_DIR}/${target_config}.cmake"
         install(FILES "${QT_PROTOBUF_BINARY_DIR}/${target_config}.cmake"
-            DESTINATION "${target_cmake_dir}"
-            COMPONENT dev)
-    endif()
-
-    export(TARGETS ${target} NAMESPACE ${QT_PROTOBUF_NAMESPACE}:: FILE ${target_export}.cmake)
-endfunction()
+            DESTINATION "${target_install_cmakedir}"
+            COMPONENT dev
+        )
+    endforeach()
+endfunction()

+ 11 - 7
src/qttypes/CMakeLists.txt

@@ -1,9 +1,13 @@
+set(qttypes_install_includedir ${CMAKE_INSTALL_INCLUDEDIR}/QtProtobuf)
+
 qt_protobuf_internal_add_library(ProtobufQtTypes
 qt_protobuf_internal_add_library(ProtobufQtTypes
     SOURCES
     SOURCES
         qtprotobufqttypes.cpp
         qtprotobufqttypes.cpp
     PUBLIC_HEADER
     PUBLIC_HEADER
         qtprotobufqttypes.h
         qtprotobufqttypes.h
         qtprotobufqttypesglobal.h
         qtprotobufqttypesglobal.h
+    INSTALL_INCLUDEDIR
+        "${qttypes_install_includedir}"
     PUBLIC_INCLUDE_DIRECTORIES
     PUBLIC_INCLUDE_DIRECTORIES
         "$<BUILD_INTERFACE:${QT_PROTOBUF_BINARY_DIR}/include/QtProtobuf>"
         "$<BUILD_INTERFACE:${QT_PROTOBUF_BINARY_DIR}/include/QtProtobuf>"
         "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>"
         "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>"
@@ -14,7 +18,6 @@ qt_protobuf_internal_add_library(ProtobufQtTypes
         ${QT_PROTOBUF_NAMESPACE}::Protobuf
         ${QT_PROTOBUF_NAMESPACE}::Protobuf
 )
 )
 
 
-set(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/QtProtobuf)
 
 
 file(GLOB PROTO_FILE ${CMAKE_CURRENT_SOURCE_DIR}/QtProtobuf/Qt*.proto)
 file(GLOB PROTO_FILE ${CMAKE_CURRENT_SOURCE_DIR}/QtProtobuf/Qt*.proto)
 qtprotobuf_generate(TARGET ProtobufQtTypes
 qtprotobuf_generate(TARGET ProtobufQtTypes
@@ -26,16 +29,17 @@ target_compile_definitions(ProtobufQtTypes PRIVATE QT_BUILD_PROTOBUF_QT_TYPES_LI
 
 
 set_target_properties(ProtobufQtTypes PROPERTIES
 set_target_properties(ProtobufQtTypes PROPERTIES
     PROTO_INCLUDES
     PROTO_INCLUDES
-        "-I\"${CMAKE_CURRENT_SOURCE_DIR}\";-I\"${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDEDIR}\""
+        "-I\"${CMAKE_CURRENT_SOURCE_DIR}\";\
+-I\"${CMAKE_INSTALL_PREFIX}/${qttypes_install_includedir}\""
 )
 )
 
 
 set_property(TARGET ProtobufQtTypes APPEND PROPERTY EXPORT_PROPERTIES PROTO_INCLUDES)
 set_property(TARGET ProtobufQtTypes APPEND PROPERTY EXPORT_PROPERTIES PROTO_INCLUDES)
 
 
 if(QT_PROTOBUF_INSTALL)
 if(QT_PROTOBUF_INSTALL)
     install(FILES
     install(FILES
-                "${CMAKE_CURRENT_SOURCE_DIR}/QtProtobuf/QtCore.proto"
-                "${CMAKE_CURRENT_SOURCE_DIR}/QtProtobuf/QtGui.proto"
-            DESTINATION "${INSTALL_INCLUDEDIR}"
-            COMPONENT dev
+            "${CMAKE_CURRENT_SOURCE_DIR}/QtProtobuf/QtCore.proto"
+            "${CMAKE_CURRENT_SOURCE_DIR}/QtProtobuf/QtGui.proto"
+        DESTINATION "${qttypes_install_includedir}"
+        COMPONENT dev
     )
     )
-endif()
+endif()

+ 22 - 17
src/wellknowntypes/CMakeLists.txt

@@ -1,36 +1,41 @@
 qt_protobuf_internal_add_library(ProtobufWellKnownTypes
 qt_protobuf_internal_add_library(ProtobufWellKnownTypes
     SOURCES
     SOURCES
         dummy.cpp
         dummy.cpp
+    INSTALL_INCLUDEDIR
+         "${CMAKE_INSTALL_INCLUDEDIR}/QtProtobuf/google/protobuf"
     PUBLIC_INCLUDE_DIRECTORIES
     PUBLIC_INCLUDE_DIRECTORIES
         "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>"
         "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>"
-        "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/QtProtobuf/google/protobuf>"
     PUBLIC_LIBRARIES
     PUBLIC_LIBRARIES
         Qt5::Core
         Qt5::Core
         Qt5::Qml
         Qt5::Qml
         ${QT_PROTOBUF_NAMESPACE}::Protobuf
         ${QT_PROTOBUF_NAMESPACE}::Protobuf
 )
 )
 
 
-function(add_wellknowntype TYPENAME)
-    list(APPEND LOOKUP_DIRS ${QT_PROTOBUF_SOURCE_DIR}/3rdparty/grpc/third_party/protobuf/src)
-    list(APPEND LOOKUP_DIRS ${Protobuf_INCLUDE_DIRS})
-    foreach(INCLUDE_DIR ${LOOKUP_DIRS})
-        file(GLOB PROTO_FILE ${INCLUDE_DIR}/google/protobuf/${TYPENAME}.proto)
+function(add_wellknowntype type_name)
+    set(lookup_dirs "${QT_PROTOBUF_SOURCE_DIR}/3rdparty/grpc/third_party/protobuf/src"
+        ${Protobuf_INCLUDE_DIRS}
+    )
+    foreach(dir ${lookup_dirs})
+        file(GLOB PROTO_FILE "${dir}/google/protobuf/${type_name}.proto")
         if(NOT "${PROTO_FILE}" STREQUAL "")
         if(NOT "${PROTO_FILE}" STREQUAL "")
             message(STATUS "Add well-known type ${PROTO_FILE}")
             message(STATUS "Add well-known type ${PROTO_FILE}")
-            qtprotobuf_generate(TARGET ProtobufWellKnownTypes GENERATED_TARGET ${TYPENAME}
-                OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated
-                PROTO_FILES ${PROTO_FILE}
-                PROTO_INCLUDES "-I\"${INCLUDE_DIR}\""
-                QML FOLDER ${extra_type_libraries_options})
-            target_include_directories(${TYPENAME} PRIVATE
-                $<TARGET_PROPERTY:${QT_PROTOBUF_NAMESPACE}::ProtobufWellKnownTypes,INTERFACE_INCLUDE_DIRECTORIES>)
-            get_target_property(GENERATED_PUBLIC_HEADER_PRIVATE ${TYPENAME} PUBLIC_HEADER)
-            set(GENERATED_PUBLIC_HEADER "${GENERATED_PUBLIC_HEADER};${GENERATED_PUBLIC_HEADER_PRIVATE}" PARENT_SCOPE)
+            qtprotobuf_generate(TARGET ProtobufWellKnownTypes
+                GENERATED_TARGET ${type_name}
+                OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated"
+                PROTO_FILES "${PROTO_FILE}"
+                PROTO_INCLUDES "-I\"${dir}\""
+                QML
+                FOLDER
+                ${extra_type_libraries_options}
+            )
+            target_include_directories(${type_name} PRIVATE
+                "$<TARGET_PROPERTY:ProtobufWellKnownTypes,INTERFACE_INCLUDE_DIRECTORIES>"
+            )
             break()
             break()
         endif()
         endif()
     endforeach()
     endforeach()
-    if(NOT TARGET ${TYPENAME})
-        message(FATAL_ERROR "Unable to add well-know type ${TYPENAME}")
+    if(NOT TARGET ${type_name})
+        message(FATAL_ERROR "Unable to add well-know type ${type_name}")
     endif()
     endif()
 endfunction()
 endfunction()