Forráskód Böngészése

Few improvements for non-system build support

- Add forced config search for Protobuf and Grpc
- Add include directory for protobuf headers
- Make explicit find_package by CONFIG in prio for Protobuf
Alexey Edelev 5 éve
szülő
commit
0bd4015c7e

+ 1 - 1
CMakeLists.txt

@@ -5,7 +5,7 @@ project(QtProtobufProject VERSION ${QTPROTOBUF_PROJECT_VERSION} LANGUAGES CXX)
 set(QTPROTOBUF_COMMON_NAMESPACE QtProtobufProject)
 
 include(GNUInstallDirs)
-find_package(Protobuf)
+find_package(Protobuf REQUIRED CONFIG)
 
 # FIXME: what is the reason to set these variables in root CMake?
 

+ 4 - 0
src/generator/CMakeLists.txt

@@ -40,6 +40,10 @@ if(WIN32)
     link_directories(${PROTOBUF_LIBRARIES_PATH} ${GRPC_LIBRARIES})
 endif()
 
+if(DEFINED Protobuf_INCLUDE_DIRS)
+    target_include_directories(${TARGET} PUBLIC ${Protobuf_INCLUDE_DIRS})
+endif()
+
 target_link_libraries(${TARGET} ${Protobuf_LIBRARIES} ${Protobuf_PROTOC_LIBRARY})
 
 install(TARGETS ${TARGET}

+ 2 - 2
src/grpc/QtGrpcConfig.cmake.in

@@ -1,6 +1,6 @@
 include(CMakeFindDependencyMacro)
-find_dependency(Protobuf REQUIRED)
-find_dependency(QtProtobuf REQUIRED)
+find_dependency(Protobuf REQUIRED CONFIG)
+find_dependency(QtProtobuf REQUIRED CONFIG)
 
 include("${CMAKE_CURRENT_LIST_DIR}/@TARGET_EXPORT@.cmake")
 

+ 2 - 2
src/grpc/QtGrpcConfigTree.cmake.in

@@ -1,6 +1,6 @@
 include(CMakeFindDependencyMacro)
-find_dependency(Protobuf REQUIRED)
-find_dependency(QtProtobuf REQUIRED)
+find_dependency(Protobuf REQUIRED CONFIG)
+find_dependency(QtProtobuf REQUIRED CONFIG)
 
 @PACKAGE_INIT@
 

+ 1 - 1
src/protobuf/QtProtobufConfig.cmake.in

@@ -1,5 +1,5 @@
 include(CMakeFindDependencyMacro)
-find_dependency(Protobuf REQUIRED)
+find_dependency(Protobuf REQUIRED CONFIG)
 
 include("${CMAKE_CURRENT_LIST_DIR}/@TARGET_EXPORT@.cmake")
 

+ 1 - 1
src/protobuf/QtProtobufConfigTree.cmake.in

@@ -1,5 +1,5 @@
 include(CMakeFindDependencyMacro)
-find_dependency(Protobuf REQUIRED)
+find_dependency(Protobuf REQUIRED CONFIG)
 
 @PACKAGE_INIT@
 

+ 0 - 2
src/protobuf/QtProtobufGen.cmake.in

@@ -10,7 +10,6 @@ function(generate_qtprotobuf)
     set(GEN_TARGET ${generate_qtprotobuf_TARGET}_qtprotobuf_generate)
 
     add_custom_target(${GEN_TARGET})
-    message(STATUS "add_custom_target ${GEN_TARGET} ${Protobuf_PROTOC_EXECUTABLE}")
 
     if(NOT DEFINED QTPROTOBUF_EXECUTABLE)
         set(QTPROTOBUF_EXECUTABLE @QTPROTOBUF_EXECUTABLE_INSTALL@)
@@ -52,7 +51,6 @@ function(generate_qtprotobuf)
 
     qt5_wrap_cpp(MOC_SOURCES ${QTPROTOBUF_GENERATED_HEADERS})
     list(APPEND GENERATED_SOURCES ${MOC_SOURCES})
-    message(STATUS "GENERATED_SOURCES: ${GENERATED_SOURCES}")
     set_source_files_properties(${QTPROTOBUF_GENERATED_SOURCES} PROPERTIES GENERATED TRUE)
     add_library(${QtProtobuf_GENERATED} ${QTPROTOBUF_GENERATED_SOURCES} ${MOC_SOURCES})
     add_dependencies(${QtProtobuf_GENERATED} ${GEN_TARGET})