Skip to content

Commit 864a139

Browse files
rlyerlymeta-codesync[bot]
authored andcommitted
Create a CMakeLists.txt for the interface folder
Summary: ^ Also use it in cachebench CMakeLists.txt ___ overriding_review_checks_triggers_an_audit_and_retroactive_review Oncall Short Name: cachelib Differential Revision: D100197162 fbshipit-source-id: 0d1367699ce499b47fa7626d314037c6567b095b
1 parent c902e79 commit 864a139

3 files changed

Lines changed: 76 additions & 17 deletions

File tree

cachelib/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ add_subdirectory (common)
314314
add_subdirectory (shm)
315315
add_subdirectory (navy)
316316
add_subdirectory (allocator)
317+
add_subdirectory (interface)
317318
add_subdirectory (datatype)
318319
add_subdirectory (compact_cache)
319320
add_subdirectory (benchmarks)
@@ -326,6 +327,7 @@ install(
326327
common
327328
compact_cache
328329
datatype
330+
interface
329331
navy
330332
shm
331333
DESTINATION ${INCLUDE_INSTALL_DIR}
@@ -380,6 +382,7 @@ target_link_libraries(cachelib INTERFACE
380382
cachelib_shm
381383
cachelib_navy
382384
cachelib_allocator
385+
cachelib_interface
383386
)
384387
target_include_directories(
385388
cachelib
@@ -405,6 +408,7 @@ if (BUILD_SHARED_LIBS)
405408
cachelib_cachebench
406409
cachelib_common
407410
cachelib_datatype
411+
cachelib_interface
408412
cachelib_navy
409413
cachelib_shm
410414
PROPERTIES

cachelib/cachebench/CMakeLists.txt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
# limitations under the License.
1414

1515
add_library (cachelib_cachebench
16-
../interface/CacheItem.cpp
17-
../interface/Handle.cpp
18-
../interface/Stats.cpp
19-
../interface/components/FlashCacheComponent.cpp
20-
../interface/components/RAMCacheComponent.cpp
21-
../interface/utils/CoroFiberAdapter.cpp
2216
./cache/Cache.cpp
2317
./cache/components/Components.cpp
2418
./cache/components/FlashComponent.cpp
@@ -49,19 +43,9 @@ add_library (cachelib_cachebench
4943
./workload/SimpleFlashBenchmarkGenerator.cpp
5044
)
5145

52-
# GCC 11's C++20 coroutine support has bugs that cause internal compiler errors
53-
# (segfaults) when compiling coroutine templates at -O2. Reduce optimization
54-
# for affected files to work around this.
55-
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
56-
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12")
57-
set_source_files_properties(
58-
../interface/components/FlashCacheComponent.cpp
59-
PROPERTIES COMPILE_OPTIONS "-O1"
60-
)
61-
endif()
62-
6346
add_dependencies(cachelib_cachebench thrift_generated_files)
6447
target_link_libraries(cachelib_cachebench PUBLIC
48+
cachelib_interface
6549
cachelib_datatype
6650
cachelib_allocator
6751
gflags

cachelib/interface/CMakeLists.txt

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
add_library (cachelib_interface
16+
CacheItem.cpp
17+
Handle.cpp
18+
Stats.cpp
19+
components/FlashCacheComponent.cpp
20+
components/RAMCacheComponent.cpp
21+
utils/CoroFiberAdapter.cpp
22+
)
23+
24+
# GCC 11's C++20 coroutine support has bugs that cause internal compiler errors
25+
# (segfaults) when compiling coroutine templates at -O2. Reduce optimization
26+
# for affected files to work around this.
27+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
28+
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12")
29+
set_source_files_properties(
30+
components/FlashCacheComponent.cpp
31+
PROPERTIES COMPILE_OPTIONS "-O1"
32+
)
33+
endif()
34+
35+
target_link_libraries(cachelib_interface PUBLIC
36+
cachelib_allocator
37+
)
38+
39+
install(TARGETS cachelib_interface
40+
EXPORT cachelib-exports
41+
DESTINATION ${LIB_INSTALL_DIR})
42+
43+
if (BUILD_TESTS)
44+
add_library (interface_test_support STATIC
45+
components/tests/CacheComponentFactory.cpp
46+
)
47+
target_link_libraries (interface_test_support PUBLIC
48+
cachelib_interface
49+
navy_test_support
50+
glog::glog
51+
gflags
52+
GTest::gtest
53+
GTest::gtest_main
54+
GTest::gmock
55+
)
56+
57+
function (add_source_test SOURCE_FILE)
58+
generic_add_source_test("interface-test" "${SOURCE_FILE}"
59+
interface_test_support "${ARGN}")
60+
endfunction()
61+
62+
# GCC ICE in gimplify_var_or_parm_decl with coroutine test macros
63+
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
64+
add_source_test (tests/InterfaceTest.cpp)
65+
add_source_test (components/tests/CacheComponentTest.cpp)
66+
endif()
67+
add_source_test (tests/ResultTest.cpp)
68+
add_source_test (components/tests/FlashCacheComponentTest.cpp)
69+
add_source_test (utils/tests/CoroFiberAdapterTest.cpp)
70+
add_source_test (utils/tests/ShardedSerializerTest.cpp)
71+
endif()

0 commit comments

Comments
 (0)