Skip to content

Commit 6e9cfd9

Browse files
committed
Reduce add_library()
Fix #298 Reduce `add_library()`s to the following 2 `add_library()`s: ```cmake add_library(nimble) add_library(nimble_test) ``` `nimble` is for Nimble features. `nimble_test` is for test. All non test files are sources of `nimble`. `nimble_test` depends on `nimble` and test related dependencies such as `gtest_main`. Each test links to `nimble_test`. Each test doesn't need to link to `gtest_main` and so on. This PR doesn't install `nimble`. I'll work on it in a separated PR.
1 parent 482efe7 commit 6e9cfd9

File tree

13 files changed

+112
-263
lines changed

13 files changed

+112
-263
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ include_directories(SYSTEM velox/velox/external/xxhash)
147147
include_directories(SYSTEM ${CMAKE_BINARY_DIR}/_deps/xsimd-src/include/)
148148

149149
add_subdirectory(velox)
150+
151+
add_library(nimble)
152+
set_target_properties(nimble PROPERTIES POSITION_INDEPENDENT_CODE ON)
153+
add_library(nimble_test)
154+
target_link_libraries(
155+
nimble_test
156+
PUBLIC nimble gmock gtest
157+
INTERFACE gtest_main Folly::folly
158+
)
159+
150160
add_subdirectory(dwio/nimble/common)
151161
add_subdirectory(dwio/nimble/tablet)
152162
add_subdirectory(dwio/nimble/tools)

dwio/nimble/common/CMakeLists.txt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
# limitations under the License.
1414
add_subdirectory(tests)
1515

16-
add_library(
17-
nimble_common
18-
Bits.cpp
19-
Checksum.cpp
20-
Exceptions.cpp
21-
FixedBitArray.cpp
22-
MetricsLogger.cpp
23-
NimbleException.cpp
24-
Types.cpp
25-
Varint.cpp
16+
target_sources(
17+
nimble
18+
PRIVATE
19+
Bits.cpp
20+
Checksum.cpp
21+
Exceptions.cpp
22+
FixedBitArray.cpp
23+
MetricsLogger.cpp
24+
NimbleException.cpp
25+
Types.cpp
26+
Varint.cpp
2627
)
2728

28-
target_link_libraries(nimble_common velox_memory velox_exception Folly::folly)
29+
target_link_libraries(nimble PRIVATE velox_memory velox_exception Folly::folly)

dwio/nimble/common/tests/CMakeLists.txt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
add_library(nimble_common_file_writer NimbleFileWriter.cpp)
14+
target_sources(nimble_test PRIVATE NimbleFileWriter.cpp)
1515

16-
target_link_libraries(
17-
nimble_common_file_writer
18-
nimble_common
19-
nimble_velox_writer
20-
velox_vector
21-
)
16+
target_link_libraries(nimble_test PUBLIC velox_vector)
2217

2318
add_executable(
2419
nimble_common_tests
@@ -32,11 +27,4 @@ add_executable(
3227

3328
add_test(nimble_common_tests nimble_common_tests)
3429

35-
target_link_libraries(
36-
nimble_common_tests
37-
nimble_common
38-
gtest
39-
gtest_main
40-
glog::glog
41-
Folly::folly
42-
)
30+
target_link_libraries(nimble_common_tests PRIVATE nimble_test glog::glog)

dwio/nimble/encodings/CMakeLists.txt

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@
1313
# limitations under the License.
1414
add_subdirectory(tests)
1515

16-
add_library(
17-
nimble_encodings
18-
Compression.cpp
19-
Encoding.cpp
20-
EncodingFactory.cpp
21-
EncodingLayout.cpp
22-
EncodingLayoutCapture.cpp
23-
RleEncoding.cpp
24-
SparseBoolEncoding.cpp
25-
Statistics.cpp
26-
TrivialEncoding.cpp
27-
ZstdCompressor.cpp
16+
target_sources(
17+
nimble
18+
PRIVATE
19+
Compression.cpp
20+
Encoding.cpp
21+
EncodingFactory.cpp
22+
EncodingLayout.cpp
23+
EncodingLayoutCapture.cpp
24+
RleEncoding.cpp
25+
SparseBoolEncoding.cpp
26+
Statistics.cpp
27+
TrivialEncoding.cpp
28+
ZstdCompressor.cpp
2829
)
2930

3031
target_link_libraries(
31-
nimble_encodings
32-
Folly::folly
33-
absl::flat_hash_map
34-
protobuf::libprotobuf
32+
nimble
33+
PRIVATE Folly::folly absl::flat_hash_map protobuf::libprotobuf
3534
)

dwio/nimble/encodings/tests/CMakeLists.txt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
add_library(nimble_encodings_tests_utils TestUtils.cpp)
15-
target_link_libraries(nimble_encodings_tests_utils nimble_encodings)
14+
target_sources(nimble_test PRIVATE TestUtils.cpp)
1615

1716
add_executable(
1817
nimble_encodings_tests
@@ -29,13 +28,4 @@ add_executable(
2928

3029
add_test(nimble_encodings_tests nimble_encodings_tests)
3130

32-
target_link_libraries(
33-
nimble_encodings_tests
34-
nimble_encodings_tests_utils
35-
nimble_encodings
36-
nimble_common
37-
nimble_tools_common
38-
gtest
39-
gtest_main
40-
Folly::folly
41-
)
31+
target_link_libraries(nimble_encodings_tests nimble_test)

dwio/nimble/stats/CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,5 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
add_library(nimble_column_stats_utils ColumnStatsUtils.cpp)
15-
target_link_libraries(
16-
nimble_column_stats_utils
17-
nimble_velox_schema
18-
nimble_velox_schema_builder
19-
raw_size_utils
20-
velox_dwio_common
21-
velox_vector
22-
)
14+
target_sources(nimble PRIVATE ColumnStatsUtils.cpp)
15+
target_link_libraries(nimble PRIVATE velox_dwio_common velox_vector)

dwio/nimble/tablet/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,5 @@ target_include_directories(
2929
)
3030
add_dependencies(nimble_footer_fb nimble_footer_schema_fb)
3131

32-
add_library(nimble_tablet_common Compression.cpp)
33-
target_link_libraries(nimble_tablet_common nimble_footer_fb Folly::folly)
34-
35-
add_library(nimble_tablet_reader TabletReader.cpp)
36-
target_link_libraries(nimble_tablet_reader nimble_tablet_common)
37-
38-
add_library(nimble_tablet_writer TabletWriter.cpp)
39-
target_link_libraries(nimble_tablet_writer nimble_tablet_common)
32+
target_sources(nimble PRIVATE Compression.cpp TabletReader.cpp TabletWriter.cpp)
33+
target_link_libraries(nimble PRIVATE nimble_footer_fb Folly::folly)

dwio/nimble/tablet/tests/CMakeLists.txt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,11 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
add_executable(nimble_tabletReader_tests TabletTests.cpp)
14+
add_executable(nimble_tablet_reader_tests TabletTests.cpp)
1515

16-
add_test(nimble_tabletReader_tests nimble_tabletReader_tests)
16+
add_test(nimble_tablet_reader_tests nimble_tablet_reader_tests)
1717

1818
target_link_libraries(
19-
nimble_tabletReader_tests
20-
nimble_tablet_reader
21-
nimble_tablet_writer
22-
nimble_common
23-
velox_dwio_common
24-
velox_memory
25-
velox_file
26-
gtest
27-
gtest_main
28-
glog::glog
29-
Folly::folly
19+
nimble_tablet_reader_tests
20+
PRIVATE nimble_test velox_dwio_common velox_memory velox_file glog::glog
3021
)

dwio/nimble/tools/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
add_library(nimble_tools_common EncodingUtilities.cpp)
15-
16-
target_link_libraries(nimble_tools_common nimble_common)
14+
target_sources(nimble PRIVATE EncodingUtilities.cpp)

dwio/nimble/velox/CMakeLists.txt

Lines changed: 33 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,25 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
add_library(nimble_velox_common SchemaUtils.cpp)
15-
target_link_libraries(nimble_velox_common nimble_common velox_type)
1614

17-
add_library(nimble_velox_schema SchemaTypes.cpp)
18-
target_link_libraries(nimble_velox_schema nimble_common Folly::folly)
19-
20-
add_library(nimble_velox_schema_reader SchemaReader.cpp)
21-
target_link_libraries(
22-
nimble_velox_schema_reader
23-
nimble_velox_schema
24-
nimble_common
25-
Folly::folly
26-
)
27-
28-
add_library(nimble_velox_schema_builder SchemaBuilder.cpp)
29-
target_link_libraries(
30-
nimble_velox_schema_builder
31-
nimble_velox_schema_reader
32-
nimble_velox_schema
33-
nimble_common
34-
Folly::folly
35-
)
36-
37-
add_library(nimble_velox_stream_data StreamData.cpp)
38-
target_link_libraries(
39-
nimble_velox_stream_data
40-
nimble_velox_schema_builder
41-
nimble_common
15+
target_sources(
16+
nimble
17+
PRIVATE
18+
SchemaUtils.cpp
19+
SchemaTypes.cpp
20+
SchemaReader.cpp
21+
SchemaBuilder.cpp
22+
StreamData.cpp
23+
FieldReader.cpp
24+
LayoutPlanner.cpp
25+
BufferGrowthPolicy.cpp
26+
DeduplicationUtils.cpp
27+
FieldWriter.cpp
4228
)
4329

44-
add_library(nimble_velox_field_reader FieldReader.cpp)
4530
target_link_libraries(
46-
nimble_velox_field_reader
47-
nimble_velox_schema_reader
48-
nimble_common
49-
Folly::folly
50-
absl::flat_hash_map
51-
protobuf::libprotobuf
52-
)
53-
54-
add_library(nimble_velox_layout_planner LayoutPlanner.cpp)
55-
target_link_libraries(nimble_velox_layout_planner nimble_velox_schema_reader)
56-
57-
add_library(
58-
nimble_velox_field_writer
59-
BufferGrowthPolicy.cpp
60-
DeduplicationUtils.cpp
61-
FieldWriter.cpp
62-
)
63-
target_link_libraries(
64-
nimble_velox_field_writer
65-
nimble_velox_schema
66-
nimble_velox_stream_data
67-
nimble_velox_schema_builder
68-
Folly::folly
31+
nimble
32+
PRIVATE velox_type Folly::folly absl::flat_hash_map protobuf::libprotobuf
6933
)
7034

7135
build_flatbuffers(
@@ -116,63 +80,27 @@ target_include_directories(
11680
)
11781
add_dependencies(nimble_velox_stats_fb nimble_velox_stats_schema_fb)
11882

119-
add_library(nimble_velox_schema_serialization SchemaSerialization.cpp)
12083
target_link_libraries(
121-
nimble_velox_schema_serialization
122-
nimble_velox_schema_reader
123-
nimble_velox_schema_builder
124-
nimble_velox_schema_fb
84+
nimble
85+
PRIVATE nimble_velox_schema_fb nimble_velox_metadata_fb nimble_velox_stats_fb
12586
)
12687

127-
add_library(
128-
nimble_velox_reader
129-
ChunkedStream.cpp
130-
ChunkedStreamDecoder.cpp
131-
StreamLabels.cpp
132-
VeloxReader.cpp
133-
)
134-
target_link_libraries(
135-
nimble_velox_reader
136-
nimble_velox_schema
137-
nimble_velox_schema_serialization
138-
nimble_velox_schema_fb
139-
nimble_velox_metadata_fb
140-
nimble_velox_field_reader
141-
nimble_tablet_reader
142-
nimble_common
143-
Folly::folly
144-
)
145-
146-
add_library(raw_size_utils RawSizeUtils.cpp DecodedVectorManager.cpp)
147-
target_link_libraries(
148-
raw_size_utils
149-
nimble_common
150-
velox_vector
151-
velox_dwio_common
152-
)
153-
154-
add_library(
155-
nimble_velox_writer
156-
EncodingLayoutTree.cpp
157-
FlushPolicy.cpp
158-
VeloxWriter.cpp
159-
ChunkedStreamWriter.cpp
160-
VeloxWriterDefaultMetadataOSS.cpp
161-
StreamChunker.cpp
162-
)
163-
target_link_libraries(
164-
nimble_velox_writer
165-
nimble_encodings
166-
nimble_common
167-
nimble_column_stats_utils
168-
nimble_tablet_writer
169-
nimble_velox_field_writer
170-
nimble_velox_layout_planner
171-
nimble_velox_metadata_fb
172-
nimble_velox_stats_fb
173-
raw_size_utils
174-
velox_dwio_common
175-
Folly::folly
88+
target_sources(
89+
nimble
90+
PRIVATE
91+
ChunkedStream.cpp
92+
ChunkedStreamDecoder.cpp
93+
SchemaSerialization.cpp
94+
StreamLabels.cpp
95+
VeloxReader.cpp
96+
RawSizeUtils.cpp
97+
DecodedVectorManager.cpp
98+
EncodingLayoutTree.cpp
99+
FlushPolicy.cpp
100+
VeloxWriter.cpp
101+
ChunkedStreamWriter.cpp
102+
VeloxWriterDefaultMetadataOSS.cpp
103+
StreamChunker.cpp
176104
)
177105

178106
add_subdirectory(selective)

0 commit comments

Comments
 (0)