diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/CMakeLists.txt | 4 | ||||
-rw-r--r-- | cmake/examples.cmake | 3 | ||||
-rw-r--r-- | cmake/protobuf-config-version.cmake.in | 28 | ||||
-rw-r--r-- | cmake/protobuf-module.cmake.in | 33 |
4 files changed, 32 insertions, 36 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 7e1b385e..07b176d9 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -20,7 +20,9 @@ else (BUILD_SHARED_LIBS) set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF) endif (BUILD_SHARED_LIBS) option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT}) -option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) +include(CMakeDependentOption) +cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON + "NOT protobuf_BUILD_SHARED_LIBS" OFF) if (MSVC) set(protobuf_WITH_ZLIB_DEFAULT OFF) else (MSVC) diff --git a/cmake/examples.cmake b/cmake/examples.cmake index 5a2538e4..5c6a1afd 100644 --- a/cmake/examples.cmake +++ b/cmake/examples.cmake @@ -18,8 +18,7 @@ function(add_examples_build NAME) STAMP_DIR ${NAME}/logs
INSTALL_COMMAND "" #Skip
LOG_CONFIGURE 1
- CMAKE_CACHE_ARGS "-Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=${protobuf_MSVC_STATIC_RUNTIME}"
- "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
+ CMAKE_CACHE_ARGS "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
"-Dprotobuf_VERBOSE:BOOL=${protobuf_VERBOSE}"
${ARGN}
)
diff --git a/cmake/protobuf-config-version.cmake.in b/cmake/protobuf-config-version.cmake.in index 5481022d..96650552 100644 --- a/cmake/protobuf-config-version.cmake.in +++ b/cmake/protobuf-config-version.cmake.in @@ -27,16 +27,26 @@ else() endif() endif() -# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: -if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") - return() -endif() +# Check and save build options used to create this package +macro(_check_and_save_build_option OPTION VALUE) + if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND + NOT ${PACKAGE_FIND_NAME}_${OPTION} EQUAL VALUE) + set(PACKAGE_VERSION_UNSUITABLE TRUE) + endif() + set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE}) +endmacro() +_check_and_save_build_option(WITH_ZLIB @protobuf_WITH_ZLIB@) +_check_and_save_build_option(MSVC_STATIC_RUNTIME @protobuf_MSVC_STATIC_RUNTIME@) +_check_and_save_build_option(BUILD_SHARED_LIBS @protobuf_BUILD_SHARED_LIBS@) -# check that the installed version has the same 32/64bit-ness as the one which is currently searching: -if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@") - math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") - set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") - set(PACKAGE_VERSION_UNSUITABLE TRUE) +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "" AND NOT "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") + # check that the installed version has the same 32/64bit-ness as the one which is currently searching: + if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) + endif() endif() set(${PACKAGE_FIND_NAME}_VERSION_PRERELEASE "@protobuf_VERSION_PRERELEASE@" PARENT_SCOPE) diff --git a/cmake/protobuf-module.cmake.in b/cmake/protobuf-module.cmake.in index 7ced934a..6e0bcf90 100644 --- a/cmake/protobuf-module.cmake.in +++ b/cmake/protobuf-module.cmake.in @@ -143,15 +143,10 @@ function(_protobuf_find_libraries name filename) # Honor cache entry used by CMake 3.5 and lower. set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE) else() - get_target_property(_aliased protobuf::lib${filename} ALIASED_TARGET) - if(_aliased) - set(${name}_LIBRARY_RELEASE $<TARGET_FILE:protobuf::lib${filename}>) - set(${name}_LIBRARY_DEBUG $<TARGET_FILE:protobuf::lib${filename}>) - else() - get_target_property(${name}_LIBRARY_RELEASE protobuf::lib${filename} - LOCATION_RELEASE) - get_target_property(${name}_LIBRARY_DEBUG protobuf::lib${filename} - LOCATION_DEBUG) + get_target_property(${name}_LIBRARY_RELEASE protobuf::lib${filename} + LOCATION_RELEASE) + get_target_property(${name}_LIBRARY_DEBUG protobuf::lib${filename} + LOCATION_DEBUG) endif() select_library_configurations(${name}) @@ -198,21 +193,11 @@ get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) # Set the protoc Executable -get_target_property(_aliased protobuf::protoc ALIASED_TARGET) -if(_aliased) - if(POLICY CMP0026) - set(Protobuf_PROTOC_EXECUTABLE $<TARGET_FILE:protobuf::protoc>) - else() - get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc - LOCATION) - endif() -else() +get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc + IMPORTED_LOCATION_RELEASE) +if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc - IMPORTED_LOCATION_RELEASE) - if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") - get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc - IMPORTED_LOCATION_DEBUG) - endif() + IMPORTED_LOCATION_DEBUG) endif() # Version info variable @@ -220,7 +205,7 @@ set(Protobuf_VERSION "@protobuf_VERSION@") include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf - REQUIRED_VARS Protobuf_LIBRARIES Protobuf_INCLUDE_DIRS + REQUIRED_VARS Protobuf_PROTOC_EXECUTABLE Protobuf_LIBRARIES Protobuf_INCLUDE_DIRS VERSION_VAR Protobuf_VERSION ) |