From 7bdcd93dfbdffbb0657d4e3dd9b04dbdc55bf189 Mon Sep 17 00:00:00 2001 From: Gil Date: Mon, 13 Aug 2018 12:57:23 -0700 Subject: [PATCH] Fix benchmark builds on non-Apple platforms (#1677) --- Firestore/Example/Benchmarks/CMakeLists.txt | 20 +++++++++++--------- cmake/cc_rules.cmake | 12 +++++++++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Firestore/Example/Benchmarks/CMakeLists.txt b/Firestore/Example/Benchmarks/CMakeLists.txt index bfd54733ad..589212a513 100644 --- a/Firestore/Example/Benchmarks/CMakeLists.txt +++ b/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() diff --git a/cmake/cc_rules.cmake b/cmake/cc_rules.cmake index 1663297f24..11713217c2 100644 --- a/cmake/cc_rules.cmake +++ b/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(