Skip to content

Commit eb6ee49

Browse files
authored
CMake fixes (#2966)
* cc_binaries should not be tests This will keep more involved benchmarks from extending test time unreasonably. * Fix target_link_libraries conformance with CMP0023 Avoid mixing keyword and non-keyword forms of target_link_libraries. * Set target_include_directories to PRIVATE for cc_binary and cc_test * Set add_sources to private Fixes a warning about policy CMP0076, which wants to make sources relative if they're public. * Enable @rpath by default This silences warnings about policy CMP0042, which we don't care much about since we don't have install targets. * Disable griping about undeclared byproducts ... when using the Ninja generator. In our case the undeclared outputs come from dependencies and we'd need to fix them before we can adopt the new policy here.
1 parent b6f4236 commit eb6ee49

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,30 @@
1616

1717
cmake_minimum_required(VERSION 2.8.11)
1818

19+
# Disallow mixing keyword and non-keyword forms of target_link_libraries
20+
if(POLICY CMP0023)
21+
cmake_policy(SET CMP0023 NEW)
22+
endif()
23+
1924
# Report AppleClang separately from Clang. Their version numbers are different.
2025
# https://cmake.org/cmake/help/v3.0/policy/CMP0025.html
2126
if(POLICY CMP0025)
2227
cmake_policy(SET CMP0025 NEW)
2328
endif()
2429

30+
# Enable rpath by default
31+
if(POLICY CMP0042)
32+
cmake_policy(SET CMP0042 NEW)
33+
endif()
34+
35+
# Generate Ninja phony rules for unknown dependencies in the build tree and
36+
# don't complain about doing so. Our dependencies aren't good about declaring
37+
# BYPRODUCTS and we mix them all into a single uber build so we can't enable
38+
# this policy until all dependencies are capable of doing so.
39+
if(POLICY CMP0058)
40+
cmake_policy(SET CMP0058 OLD)
41+
endif()
42+
2543
# Defer enabling any languages.
2644
project(firebase NONE)
2745

Firestore/core/test/firebase/firestore/objc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cc_test(
2323

2424
if(APPLE)
2525
target_sources(
26-
firebase_firestore_objc_test PUBLIC
26+
firebase_firestore_objc_test PRIVATE
2727
objc_class_test.cc
2828
objc_class_test_helper.h
2929
objc_class_test_helper.mm

cmake/cc_rules.cmake

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ function(cc_binary name)
128128
maybe_remove_objc_sources(sources ${ccb_SOURCES})
129129
add_executable(${name} ${sources})
130130
add_objc_flags(${name} ${ccb_SOURCES})
131-
add_test(${name} ${name})
132131

133-
target_include_directories(${name} PUBLIC ${FIREBASE_SOURCE_DIR})
134-
target_link_libraries(${name} ${ccb_DEPENDS})
132+
target_include_directories(${name} PRIVATE ${FIREBASE_SOURCE_DIR})
133+
target_link_libraries(${name} PRIVATE ${ccb_DEPENDS})
135134

136135
if(ccb_EXCLUDE_FROM_ALL)
137136
set_property(
@@ -160,8 +159,8 @@ function(cc_test name)
160159
add_objc_flags(${name} ${cct_SOURCES})
161160
add_test(${name} ${name})
162161

163-
target_include_directories(${name} PUBLIC ${FIREBASE_SOURCE_DIR})
164-
target_link_libraries(${name} ${cct_DEPENDS})
162+
target_include_directories(${name} PRIVATE ${FIREBASE_SOURCE_DIR})
163+
target_link_libraries(${name} PRIVATE ${cct_DEPENDS})
165164
endfunction()
166165

167166
# cc_fuzz_test(

0 commit comments

Comments
 (0)