summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/release/dev/FindProtobuf-targets.rst5
-rw-r--r--Modules/FindProtobuf.cmake81
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/Checks/cm_cxx_features.cmake29
-rw-r--r--Source/cmComputeTargetDepends.cxx18
-rw-r--r--Source/cmComputeTargetDepends.h1
-rw-r--r--Tests/CMakeCommands/target_link_libraries/empty.cpp4
-rw-r--r--Tests/CMakeLists.txt4
-rw-r--r--Tests/ExportImport/Export/testLibNoSONAME.c2
-rw-r--r--Tests/FindProtobuf/CMakeLists.txt10
-rw-r--r--Tests/FindProtobuf/Test/CMakeLists.txt32
-rw-r--r--Tests/FindProtobuf/Test/main-protoc.cxx8
-rw-r--r--Tests/FindProtobuf/Test/main.cxx8
-rw-r--r--Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt4
-rw-r--r--Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake2
-rw-r--r--Tests/Wrapping/fakefluid.cxx4
-rw-r--r--Utilities/cmliblzma/CMakeLists.txt4
17 files changed, 185 insertions, 33 deletions
diff --git a/Help/release/dev/FindProtobuf-targets.rst b/Help/release/dev/FindProtobuf-targets.rst
new file mode 100644
index 0000000..e38303d
--- /dev/null
+++ b/Help/release/dev/FindProtobuf-targets.rst
@@ -0,0 +1,5 @@
+FindProtobuf-targets
+--------------------
+
+* The :module:`FindProtobuf` module now provides imported targets
+ when the libraries are found.
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 102ed42..6dc0444 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -40,6 +40,15 @@
# ``Protobuf_LITE_LIBRARIES``
# The protobuf-lite libraries
#
+# The following :prop_tgt:`IMPORTED` targets are also defined:
+#
+# ``Protobuf::protobuf``
+# The protobuf library.
+# ``Protobuf::protobuf-lite``
+# The protobuf lite library.
+# ``Protobuf::protoc``
+# The protoc library.
+#
# The following cache variables are also available to set or use:
#
# ``Protobuf_LIBRARY``
@@ -409,6 +418,78 @@ if(Protobuf_INCLUDE_DIR)
message(WARNING "Protobuf compiler version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}"
" doesn't match library version ${Protobuf_VERSION}")
endif()
+
+ if(Protobuf_LIBRARY)
+ if(NOT TARGET Protobuf::protobuf)
+ add_library(Protobuf::protobuf UNKNOWN IMPORTED)
+ set_target_properties(Protobuf::protobuf PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}")
+ if(EXISTS "${Protobuf_LIBRARY}")
+ set_target_properties(Protobuf::protobuf PROPERTIES
+ IMPORTED_LOCATION "${Protobuf_LIBRARY}")
+ endif()
+ if(EXISTS "${Protobuf_LIBRARY_RELEASE}")
+ set_property(TARGET Protobuf::protobuf APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(Protobuf::protobuf PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${Protobuf_LIBRARY_RELEASE}")
+ endif()
+ if(EXISTS "${Protobuf_LIBRARY_DEBUG}")
+ set_property(TARGET Protobuf::protobuf APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(Protobuf::protobuf PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${Protobuf_LIBRARY_DEBUG}")
+ endif()
+ endif()
+ endif()
+
+ if(Protobuf_LITE_LIBRARY)
+ if(NOT TARGET Protobuf::protobuf-lite)
+ add_library(Protobuf::protobuf-lite UNKNOWN IMPORTED)
+ set_target_properties(Protobuf::protobuf-lite PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}")
+ if(EXISTS "${Protobuf_LITE_LIBRARY}")
+ set_target_properties(Protobuf::protobuf-lite PROPERTIES
+ IMPORTED_LOCATION "${Protobuf_LITE_LIBRARY}")
+ endif()
+ if(EXISTS "${Protobuf_LITE_LIBRARY_RELEASE}")
+ set_property(TARGET Protobuf::protobuf-lite APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(Protobuf::protobuf-lite PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${Protobuf_LITE_LIBRARY_RELEASE}")
+ endif()
+ if(EXISTS "${Protobuf_LITE_LIBRARY_DEBUG}")
+ set_property(TARGET Protobuf::protobuf-lite APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(Protobuf::protobuf-lite PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${Protobuf_LITE_LIBRARY_DEBUG}")
+ endif()
+ endif()
+ endif()
+
+ if(Protobuf_PROTOC_LIBRARY)
+ if(NOT TARGET Protobuf::protoc)
+ add_library(Protobuf::protoc UNKNOWN IMPORTED)
+ set_target_properties(Protobuf::protoc PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}")
+ if(EXISTS "${Protobuf_PROTOC_LIBRARY}")
+ set_target_properties(Protobuf::protoc PROPERTIES
+ IMPORTED_LOCATION "${Protobuf_PROTOC_LIBRARY}")
+ endif()
+ if(EXISTS "${Protobuf_PROTOC_LIBRARY_RELEASE}")
+ set_property(TARGET Protobuf::protoc APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(Protobuf::protoc PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${Protobuf_PROTOC_LIBRARY_RELEASE}")
+ endif()
+ if(EXISTS "${Protobuf_PROTOC_LIBRARY_DEBUG}")
+ set_property(TARGET Protobuf::protoc APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(Protobuf::protoc PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${Protobuf_PROTOC_LIBRARY_DEBUG}")
+ endif()
+ endif()
+ endif()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 2ac81fa..c7015ed 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 8)
-set(CMake_VERSION_PATCH 20170518)
+set(CMake_VERSION_PATCH 20170522)
#set(CMake_VERSION_RC 1)
diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake
index cd58539..458901e 100644
--- a/Source/Checks/cm_cxx_features.cmake
+++ b/Source/Checks/cm_cxx_features.cmake
@@ -3,10 +3,15 @@ function(cm_check_cxx_feature name)
string(TOUPPER ${name} FEATURE)
if(NOT DEFINED CMake_HAVE_CXX_${FEATURE})
message(STATUS "Checking if compiler supports C++ ${name}")
+ if(CMAKE_CXX_STANDARD)
+ set(maybe_cxx_standard -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD})
+ else()
+ set(maybe_cxx_standard "")
+ endif()
try_compile(CMake_HAVE_CXX_${FEATURE}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_LIST_DIR}/cm_cxx_${name}.cxx
- CMAKE_FLAGS -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
+ CMAKE_FLAGS ${maybe_cxx_standard}
OUTPUT_VARIABLE OUTPUT
)
# If using the feature causes warnings, treat it as broken/unavailable.
@@ -31,16 +36,14 @@ function(cm_check_cxx_feature name)
endif()
endfunction()
-if(CMAKE_CXX_STANDARD)
- cm_check_cxx_feature(auto_ptr)
- cm_check_cxx_feature(eq_delete)
- cm_check_cxx_feature(make_unique)
- if(CMake_HAVE_CXX_MAKE_UNIQUE)
- set(CMake_HAVE_CXX_UNIQUE_PTR 1)
- endif()
- cm_check_cxx_feature(nullptr)
- cm_check_cxx_feature(override)
- cm_check_cxx_feature(unique_ptr)
- cm_check_cxx_feature(unordered_map)
- cm_check_cxx_feature(unordered_set)
+cm_check_cxx_feature(auto_ptr)
+cm_check_cxx_feature(eq_delete)
+cm_check_cxx_feature(make_unique)
+if(CMake_HAVE_CXX_MAKE_UNIQUE)
+ set(CMake_HAVE_CXX_UNIQUE_PTR 1)
endif()
+cm_check_cxx_feature(nullptr)
+cm_check_cxx_feature(override)
+cm_check_cxx_feature(unique_ptr)
+cm_check_cxx_feature(unordered_map)
+cm_check_cxx_feature(unordered_set)
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index cfebda2..ff19eac 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -238,7 +238,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// Don't emit the same library twice for this target.
if (emitted.insert(*lib).second) {
this->AddTargetDepend(depender_index, *lib, true);
- this->AddInterfaceDepends(depender_index, *lib, emitted);
+ this->AddInterfaceDepends(depender_index, *lib, *it, emitted);
}
}
}
@@ -273,7 +273,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(
// Don't emit the same library twice for this target.
if (emitted.insert(*lib).second) {
this->AddTargetDepend(depender_index, *lib, true);
- this->AddInterfaceDepends(depender_index, *lib, emitted);
+ this->AddInterfaceDepends(depender_index, *lib, config, emitted);
}
}
}
@@ -281,7 +281,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(
void cmComputeTargetDepends::AddInterfaceDepends(
int depender_index, cmLinkItem const& dependee_name,
- std::set<std::string>& emitted)
+ const std::string& config, std::set<std::string>& emitted)
{
cmGeneratorTarget const* depender = this->Targets[depender_index];
cmGeneratorTarget const* dependee = dependee_name.Target;
@@ -294,15 +294,9 @@ void cmComputeTargetDepends::AddInterfaceDepends(
}
if (dependee) {
- this->AddInterfaceDepends(depender_index, dependee, "", emitted);
- std::vector<std::string> configs;
- depender->Makefile->GetConfigurations(configs);
- for (std::vector<std::string>::const_iterator it = configs.begin();
- it != configs.end(); ++it) {
- // A target should not depend on itself.
- emitted.insert(depender->GetName());
- this->AddInterfaceDepends(depender_index, dependee, *it, emitted);
- }
+ // A target should not depend on itself.
+ emitted.insert(depender->GetName());
+ this->AddInterfaceDepends(depender_index, dependee, config, emitted);
}
}
diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h
index ccf99de..e93e376 100644
--- a/Source/cmComputeTargetDepends.h
+++ b/Source/cmComputeTargetDepends.h
@@ -50,6 +50,7 @@ private:
bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name,
+ const std::string& config,
std::set<std::string>& emitted);
void AddInterfaceDepends(int depender_index,
cmGeneratorTarget const* dependee,
diff --git a/Tests/CMakeCommands/target_link_libraries/empty.cpp b/Tests/CMakeCommands/target_link_libraries/empty.cpp
index ab32cf6..a6ecef8 100644
--- a/Tests/CMakeCommands/target_link_libraries/empty.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/empty.cpp
@@ -1 +1,3 @@
-// No content
+// Solaris needs non-empty content so ensure
+// we have at least one symbol
+int Solaris_requires_a_symbol_here = 0;
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index acd014a..4b335bd 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1438,6 +1438,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
add_subdirectory(FindPNG)
endif()
+ if(CMake_TEST_FindProtobuf)
+ add_subdirectory(FindProtobuf)
+ endif()
+
if(CMake_TEST_FindTIFF)
add_subdirectory(FindTIFF)
endif()
diff --git a/Tests/ExportImport/Export/testLibNoSONAME.c b/Tests/ExportImport/Export/testLibNoSONAME.c
index 30acc83..4d98562 100644
--- a/Tests/ExportImport/Export/testLibNoSONAME.c
+++ b/Tests/ExportImport/Export/testLibNoSONAME.c
@@ -4,7 +4,7 @@
#define testLibNoSONAME_EXPORT
#endif
-testLibNoSONAME_EXPORT int testLibNoSONAME(void)
+testLibNoSONAME_EXPORT int testLibNoSoName(void)
{
return 0;
}
diff --git a/Tests/FindProtobuf/CMakeLists.txt b/Tests/FindProtobuf/CMakeLists.txt
new file mode 100644
index 0000000..1cdb2ae
--- /dev/null
+++ b/Tests/FindProtobuf/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindProtobuf.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindProtobuf/Test"
+ "${CMake_BINARY_DIR}/Tests/FindProtobuf/Test"
+ ${build_generator_args}
+ --build-project TestFindProtobuf
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindProtobuf/Test/CMakeLists.txt b/Tests/FindProtobuf/Test/CMakeLists.txt
new file mode 100644
index 0000000..d7a5081
--- /dev/null
+++ b/Tests/FindProtobuf/Test/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindProtobuf CXX)
+include(CTest)
+
+find_package(Protobuf REQUIRED)
+
+add_executable(test_tgt main.cxx)
+target_link_libraries(test_tgt Protobuf::protobuf)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.cxx)
+target_include_directories(test_var PRIVATE ${Protobuf_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${Protobuf_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
+
+add_executable(test_tgt_lite main.cxx)
+target_link_libraries(test_tgt_lite Protobuf::protobuf-lite)
+add_test(NAME test_tgt_lite COMMAND test_tgt_lite)
+
+add_executable(test_var_lite main.cxx)
+target_include_directories(test_var_lite PRIVATE ${Protobuf_INCLUDE_DIRS})
+target_link_libraries(test_var_lite PRIVATE ${Protobuf_LITE_LIBRARIES})
+add_test(NAME test_var_lite COMMAND test_var_lite)
+
+add_executable(test_tgt_protoc main-protoc.cxx)
+target_link_libraries(test_tgt_protoc Protobuf::protoc)
+add_test(NAME test_tgt_protoc COMMAND test_tgt_protoc)
+
+add_executable(test_var_protoc main-protoc.cxx)
+target_include_directories(test_var_protoc PRIVATE ${Protobuf_INCLUDE_DIRS})
+target_link_libraries(test_var_protoc PRIVATE ${Protobuf_PROTOC_LIBRARIES})
+add_test(NAME test_var_protoc COMMAND test_var_protoc)
diff --git a/Tests/FindProtobuf/Test/main-protoc.cxx b/Tests/FindProtobuf/Test/main-protoc.cxx
new file mode 100644
index 0000000..64e5ada
--- /dev/null
+++ b/Tests/FindProtobuf/Test/main-protoc.cxx
@@ -0,0 +1,8 @@
+#include <google/protobuf/compiler/command_line_interface.h>
+
+int main()
+{
+ google::protobuf::compiler::CommandLineInterface();
+
+ return 0;
+}
diff --git a/Tests/FindProtobuf/Test/main.cxx b/Tests/FindProtobuf/Test/main.cxx
new file mode 100644
index 0000000..87d5c12
--- /dev/null
+++ b/Tests/FindProtobuf/Test/main.cxx
@@ -0,0 +1,8 @@
+#include <google/protobuf/stubs/common.h>
+
+int main()
+{
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ return 0;
+}
diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt
index f672285..5d39214 100644
--- a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt
+++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt
@@ -4,13 +4,13 @@ CMake Warning \(dev\) in CMakeLists.txt:
cmake_policy command to set the policy and suppress this warning.
Target "bar" has an INTERFACE_LINK_LIBRARIES property which differs from
- its LINK_INTERFACE_LIBRARIES properties.
+ its LINK_INTERFACE_LIBRARIES(_DEBUG)? properties.
INTERFACE_LINK_LIBRARIES:
foo
- LINK_INTERFACE_LIBRARIES:
+ LINK_INTERFACE_LIBRARIES(_DEBUG)?:
bat
diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake
index 11b4e22..03223e8 100644
--- a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake
+++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake
@@ -5,7 +5,9 @@ add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)
add_library(bat SHARED empty_vs6_3.cpp)
target_link_libraries(bar LINK_PUBLIC foo)
+# Replace the compatibility values set by target_link_libraries
set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES bat)
+set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES_DEBUG bat)
add_library(user SHARED empty.cpp)
target_link_libraries(user bar)
diff --git a/Tests/Wrapping/fakefluid.cxx b/Tests/Wrapping/fakefluid.cxx
index 02c0c52..a118bbd 100644
--- a/Tests/Wrapping/fakefluid.cxx
+++ b/Tests/Wrapping/fakefluid.cxx
@@ -6,7 +6,9 @@ int main(int ac, char** av)
if (strcmp(av[i], "-o") == 0 || strcmp(av[i], "-h") == 0) {
fprintf(stdout, "fakefluid is creating file \"%s\"\n", av[i + 1]);
FILE* file = fopen(av[i + 1], "w");
- fprintf(file, "// hello\n");
+ fprintf(file, "// Solaris needs non-empty content so ensure\n"
+ "// we have at least one symbol\n"
+ "int Solaris_requires_a_symbol_here = 0;\n");
fclose(file);
}
}
diff --git a/Utilities/cmliblzma/CMakeLists.txt b/Utilities/cmliblzma/CMakeLists.txt
index e806680..bb3b8a7 100644
--- a/Utilities/cmliblzma/CMakeLists.txt
+++ b/Utilities/cmliblzma/CMakeLists.txt
@@ -15,11 +15,11 @@ CHECK_C_SOURCE_COMPILES(
HAVE___RESTRICT)
CHECK_C_SOURCE_COMPILES(
- "inline int test (void) {return 0;}\nint main (void) {return test();}"
+ "static inline int test (void) {return 0;}\nint main (void) {return test();}"
HAVE_INLINE)
CHECK_C_SOURCE_COMPILES (
- "__inline int test (void) {return 0;}\nint main (void) {return test();}"
+ "static __inline int test (void) {return 0;}\nint main (void) {return test();}"
HAVE___INLINE)
CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)