summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/FindProtobuf/Test/CMakeLists.txt18
-rw-r--r--Tests/FindProtobuf/Test/main-desc.cxx57
-rw-r--r--Tests/FindProtobuf/Test/main-generate.cxx8
-rw-r--r--Tests/FindProtobuf/Test/msgs/example.proto6
-rw-r--r--Tests/FindProtobuf/Test/msgs/example_desc.proto10
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt4
-rw-r--r--Tests/GeneratorExpression/echo.c3
-rw-r--r--Tests/GeneratorExpression/srcgenex.c12
-rw-r--r--Tests/LoadCommand/CMakeLists.txt7
-rw-r--r--Tests/LoadCommandOneConfig/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt4
-rw-r--r--Tests/RunCMake/Framework/ios.cmake12
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeBundles.cmake6
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-install-check.cmake6
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake6
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake6
17 files changed, 148 insertions, 26 deletions
diff --git a/Tests/FindProtobuf/Test/CMakeLists.txt b/Tests/FindProtobuf/Test/CMakeLists.txt
index 10ce976..bc89190 100644
--- a/Tests/FindProtobuf/Test/CMakeLists.txt
+++ b/Tests/FindProtobuf/Test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.4)
+cmake_minimum_required(VERSION 3.8)
project(TestFindProtobuf CXX)
include(CTest)
@@ -32,3 +32,19 @@ target_link_libraries(test_var_protoc PRIVATE ${Protobuf_PROTOC_LIBRARIES})
add_test(NAME test_var_protoc COMMAND test_var_protoc)
add_test(NAME test_tgt_protoc_version COMMAND protobuf::protoc --version)
+
+set(Protobuf_IMPORT_DIRS ${Protobuf_INCLUDE_DIRS})
+PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER msgs/example.proto)
+PROTOBUF_GENERATE_CPP(DESC_PROTO_SRC DESC_PROTO_HEADER DESCRIPTORS DESC_PROTO_DESC msgs/example_desc.proto)
+add_library(msgs ${PROTO_SRC} ${PROTO_HEADER})
+
+add_executable(test_generate main-generate.cxx ${PROTO_SRC})
+target_include_directories(test_generate PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(test_generate msgs ${Protobuf_LIBRARIES})
+add_test(NAME test_generate COMMAND test_generate)
+
+add_executable(test_desc main-desc.cxx ${DESC_PROTO_SRC})
+target_compile_features(test_desc PRIVATE cxx_std_11)
+target_include_directories(test_desc PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(test_desc msgs ${Protobuf_LIBRARIES})
+add_test(NAME test_desc COMMAND test_desc ${DESC_PROTO_DESC})
diff --git a/Tests/FindProtobuf/Test/main-desc.cxx b/Tests/FindProtobuf/Test/main-desc.cxx
new file mode 100644
index 0000000..a26e562
--- /dev/null
+++ b/Tests/FindProtobuf/Test/main-desc.cxx
@@ -0,0 +1,57 @@
+#include <fstream>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/dynamic_message.h>
+#include <google/protobuf/text_format.h>
+#include <iostream>
+#include <string>
+
+int main(int argc, char* argv[])
+{
+ std::ifstream fs;
+ fs.open(argv[1], std::ifstream::in);
+ google::protobuf::FileDescriptorSet file_descriptor_set;
+ file_descriptor_set.ParseFromIstream(&fs);
+
+ const google::protobuf::DescriptorPool* compiled_pool =
+ google::protobuf::DescriptorPool::generated_pool();
+
+ if (compiled_pool == NULL) {
+ std::cerr << "compiled pool is NULL." << std::endl;
+ return 1;
+ }
+
+ google::protobuf::DescriptorPool pool(compiled_pool);
+ google::protobuf::DynamicMessageFactory dynamic_message_factory(&pool);
+
+ for (const google::protobuf::FileDescriptorProto& file_descriptor_proto :
+ file_descriptor_set.file()) {
+ const google::protobuf::FileDescriptor* file_descriptor =
+ pool.BuildFile(file_descriptor_proto);
+ if (file_descriptor == NULL) {
+ continue;
+ }
+
+ const google::protobuf::Descriptor* descriptor =
+ pool.FindMessageTypeByName("example.msgs.ExampleDesc");
+
+ if (descriptor == NULL) {
+ continue;
+ }
+
+ google::protobuf::Message* msg =
+ dynamic_message_factory.GetPrototype(descriptor)->New();
+ std::string data = "data: 1";
+ bool success = google::protobuf::TextFormat::ParseFromString(data, msg);
+
+ if (success) {
+ return 0;
+ } else {
+ std::cerr << "Failed to parse message." << std::endl;
+ return 2;
+ }
+ }
+
+ std::cerr << "No matching message found." << std::endl;
+ return 3;
+}
diff --git a/Tests/FindProtobuf/Test/main-generate.cxx b/Tests/FindProtobuf/Test/main-generate.cxx
new file mode 100644
index 0000000..ca33a68
--- /dev/null
+++ b/Tests/FindProtobuf/Test/main-generate.cxx
@@ -0,0 +1,8 @@
+#include <example.pb.h>
+
+int main()
+{
+ example::msgs::Example msg;
+
+ return 0;
+}
diff --git a/Tests/FindProtobuf/Test/msgs/example.proto b/Tests/FindProtobuf/Test/msgs/example.proto
new file mode 100644
index 0000000..d27262e
--- /dev/null
+++ b/Tests/FindProtobuf/Test/msgs/example.proto
@@ -0,0 +1,6 @@
+syntax = "proto2";
+package example.msgs;
+
+message Example {
+ required int32 data = 1;
+}
diff --git a/Tests/FindProtobuf/Test/msgs/example_desc.proto b/Tests/FindProtobuf/Test/msgs/example_desc.proto
new file mode 100644
index 0000000..4454473
--- /dev/null
+++ b/Tests/FindProtobuf/Test/msgs/example_desc.proto
@@ -0,0 +1,10 @@
+syntax = "proto2";
+package example.msgs;
+
+import "google/protobuf/descriptor.proto";
+
+message ExampleDesc {
+ required int32 data = 1;
+
+ optional google.protobuf.FileDescriptorSet desc = 2;
+}
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 8ac3419..83fd11d 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -258,11 +258,13 @@ add_custom_target(check-part4 ALL
VERBATIM
)
+add_executable(srcgenex srcgenex.c)
+set_property(SOURCE srcgenex.c PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>")
+
#-----------------------------------------------------------------------------
# Cover test properties with generator expressions.
add_executable(echo echo.c)
add_executable(pwd pwd.c)
-set_property(SOURCE echo.c PROPERTY COMPILE_FLAGS $<1:-DSRC_GENEX_WORKS>)
add_test(NAME echo-configuration COMMAND echo $<CONFIGURATION>)
set_property(TEST echo-configuration PROPERTY
diff --git a/Tests/GeneratorExpression/echo.c b/Tests/GeneratorExpression/echo.c
index 41596a2..06b0844 100644
--- a/Tests/GeneratorExpression/echo.c
+++ b/Tests/GeneratorExpression/echo.c
@@ -3,9 +3,6 @@
int main(int argc, char* argv[])
{
-#ifndef SRC_GENEX_WORKS
-#error SRC_GENEX_WORKS not defined
-#endif
printf("%s\n", argv[1]);
return EXIT_SUCCESS;
}
diff --git a/Tests/GeneratorExpression/srcgenex.c b/Tests/GeneratorExpression/srcgenex.c
new file mode 100644
index 0000000..56d3c3f
--- /dev/null
+++ b/Tests/GeneratorExpression/srcgenex.c
@@ -0,0 +1,12 @@
+int srcgenex(void)
+{
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+#ifndef NAME
+#error NAME not defined
+#endif
+ return NAME();
+}
diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt
index 03a3b49..cfaebad 100644
--- a/Tests/LoadCommand/CMakeLists.txt
+++ b/Tests/LoadCommand/CMakeLists.txt
@@ -22,13 +22,6 @@ else()
${LoadCommand_SOURCE_DIR}/CMakeCommands
CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
OUTPUT_VARIABLE OUTPUT )
-# do another TRY_COMPILE to get around make
-# problem on hp
- try_compile(COMPILE_OK
- ${LoadCommand_BINARY_DIR}/CMakeCommands
- ${LoadCommand_SOURCE_DIR}/CMakeCommands
- CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
- OUTPUT_VARIABLE OUTPUT )
endif()
message("Output from try compile: ${OUTPUT}")
diff --git a/Tests/LoadCommandOneConfig/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeLists.txt
index 6affd34..65de042 100644
--- a/Tests/LoadCommandOneConfig/CMakeLists.txt
+++ b/Tests/LoadCommandOneConfig/CMakeLists.txt
@@ -28,13 +28,6 @@ else()
${LoadCommand_SOURCE_DIR}/CMakeCommands
CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
OUTPUT_VARIABLE OUTPUT )
-# do another TRY_COMPILE to get around make
-# problem on hp
- try_compile(COMPILE_OK
- ${LoadCommand_BINARY_DIR}/CMakeCommands
- ${LoadCommand_SOURCE_DIR}/CMakeCommands
- CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
- OUTPUT_VARIABLE OUTPUT )
endif()
message("Output from try compile: ${OUTPUT}")
diff --git a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
index 532cfed..4b5f761 100644
--- a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
+++ b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
@@ -1,2 +1,2 @@
-.*/Framework:( Mach-O universal binary with [^
-]*)? current ar archive random library.*
+/Framework: (Mach-O universal binary with [^
+]*)?current ar archive random library
diff --git a/Tests/RunCMake/Framework/ios.cmake b/Tests/RunCMake/Framework/ios.cmake
index 209a50d..446e914 100644
--- a/Tests/RunCMake/Framework/ios.cmake
+++ b/Tests/RunCMake/Framework/ios.cmake
@@ -20,6 +20,16 @@ execute_process(
OUTPUT_VARIABLE IOS_SDK_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(
+ COMMAND ${XCRUN_EXECUTABLE} --sdk iphoneos --show-sdk-version
+ OUTPUT_VARIABLE IOS_SDK_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(IOS_SDK_VERSION VERSION_GREATER_EQUAL 11.0)
+ set(IOS_ARCH arm64)
+else()
+ set(IOS_ARCH armv7)
+endif()
+
set(CMAKE_OSX_SYSROOT ${IOS_SDK_PATH} CACHE PATH "Sysroot used for iOS support")
-set(CMAKE_OSX_ARCHITECTURES "armv7" CACHE STRING "Architectures to build for")
+set(CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE STRING "Architectures to build for")
set(CMAKE_FIND_ROOT_PATH ${IOS_SDK_PATH} CACHE PATH "Find search path root")
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index 5f4bdc3..554aa2f 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -129,7 +129,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6)
unset(RunCMake_TEST_BINARY_DIR)
unset(RunCMake_TEST_NO_CLEAN)
unset(RunCMake_TEST_OPTIONS)
+endif()
+if(XCODE_VERSION VERSION_GREATER_EQUAL 6 AND XCODE_VERSION VERSION_LESS 9)
# XcodeIOSInstallCombinedPrune
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedPrune-build)
set(RunCMake_TEST_NO_CLEAN 1)
diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
index 0b854d8..cee71fa 100644
--- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
@@ -5,7 +5,11 @@ enable_language(C)
if(TEST_IOS)
set(CMAKE_OSX_SYSROOT iphoneos)
- set(CMAKE_OSX_ARCHITECTURES "armv7")
+ if(XCODE_VERSION VERSION_GREATER_EQUAL 9)
+ set(CMAKE_OSX_ARCHITECTURES "arm64")
+ else()
+ set(CMAKE_OSX_ARCHITECTURES "armv7")
+ endif()
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
endif(TEST_IOS)
diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-install-check.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-install-check.cmake
index a1c0671..cd71205 100644
--- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-install-check.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined-install-check.cmake
@@ -13,7 +13,11 @@ function(verify_architectures file)
string(REPLACE "architecture " "" actual "${architectures}")
list(SORT actual)
- set(expected arm64 armv7 i386 x86_64)
+ if(XCODE_VERSION VERSION_GREATER_EQUAL 9)
+ set(expected arm64 x86_64)
+ else()
+ set(expected arm64 armv7 i386 x86_64)
+ endif()
if(NOT actual STREQUAL expected)
message(SEND_ERROR
diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake
index fc830b1..6abba49 100644
--- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake
@@ -7,7 +7,11 @@ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
-set(CMAKE_OSX_ARCHITECTURES "armv7;arm64;i386;x86_64")
+if(XCODE_VERSION VERSION_GREATER_EQUAL 9)
+ set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
+else()
+ set(CMAKE_OSX_ARCHITECTURES "armv7;arm64;i386;x86_64")
+endif()
add_executable(foo_app MACOSX_BUNDLE main.cpp)
install(TARGETS foo_app BUNDLE DESTINATION bin)
diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake
index a797410..f629f2e 100644
--- a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake
@@ -6,7 +6,11 @@ set(CMAKE_OSX_SYSROOT iphoneos)
set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
-set(CMAKE_OSX_ARCHITECTURES "armv7;i386")
+if(XCODE_VERSION VERSION_GREATER_EQUAL 9)
+ set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
+else()
+ set(CMAKE_OSX_ARCHITECTURES "armv7;i386")
+endif()
add_library(foo STATIC foo.cpp)
install(TARGETS foo ARCHIVE DESTINATION lib)