Explorar o código

Fix benchmark builds on non-Apple platforms (#1677)

Gil %!s(int64=7) %!d(string=hai) anos
pai
achega
7bdcd93dfb
Modificáronse 2 ficheiros con 22 adicións e 10 borrados
  1. 11 9
      Firestore/Example/Benchmarks/CMakeLists.txt
  2. 11 1
      cmake/cc_rules.cmake

+ 11 - 9
Firestore/Example/Benchmarks/CMakeLists.txt

@@ -12,12 +12,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-cc_binary(
-  firebase_firestore_util_string_apple_benchmark
-  SOURCES
-    string_apple_benchmark.mm
-  DEPENDS
-    benchmark
-    benchmark_main
-    firebase_firestore_util_base_apple
-)
+if(APPLE)
+  cc_binary(
+    firebase_firestore_util_string_apple_benchmark
+    SOURCES
+      string_apple_benchmark.mm
+    DEPENDS
+      benchmark
+      benchmark_main
+      firebase_firestore_util_base_apple
+  )
+endif()

+ 11 - 1
cmake/cc_rules.cmake

@@ -18,6 +18,7 @@ include(CMakeParseArguments)
 #   target
 #   SOURCES sources...
 #   DEPENDS libraries...
+#   [EXCLUDE_FROM_ALL]
 # )
 #
 # Defines a new library target with the given target name, sources, and
@@ -93,13 +94,15 @@ endfunction()
 #   target
 #   SOURCES sources...
 #   DEPENDS libraries...
+#   [EXCLUDE_FROM_ALL]
 # )
 #
 # Defines a new executable target with the given target name, sources, and
 # dependencies.
 function(cc_binary name)
+  set(flag EXCLUDE_FROM_ALL)
   set(multi DEPENDS SOURCES)
-  cmake_parse_arguments(ccb "" "" "${multi}" ${ARGN})
+  cmake_parse_arguments(ccb "${flag}" "" "${multi}" ${ARGN})
 
   maybe_remove_objc_sources(sources ${ccb_SOURCES})
   add_executable(${name} ${sources})
@@ -108,6 +111,13 @@ function(cc_binary name)
 
   target_include_directories(${name} PUBLIC ${FIREBASE_SOURCE_DIR})
   target_link_libraries(${name} ${ccb_DEPENDS})
+
+  if(ccb_EXCLUDE_FROM_ALL)
+    set_property(
+      TARGET ${name}
+      PROPERTY EXCLUDE_FROM_ALL ON
+    )
+  endif()
 endfunction()
 
 # cc_test(