Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions bolt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,21 @@ function(bolt_add_library target_name)

set(SHUFFLE_COMP_LIST "shuffle")

set(EXTENSIONS_COMP_LIST "torch" "cudf" "python")
set(BOLT_EXTENSION_COMP_LIST "cudf" "torch" "python")

if (BOLT_INTERFACE)
add_library(${target_name} INTERFACE ${ARGN})
return()
endif()
if (BOLT_OBJECT)
add_library(${target_name} OBJECT ${ARGN})
return()
endif()

if(FIRST_LEVEL_DIR IN_LIST BOLT_EXTENSION_COMP_LIST)
add_library(${target_name} ${ARGN})
return()
endif()

# OBJECT libraries are used to aggregate source files without creating a library file.
add_library(${target_name} OBJECT ${ARGN})
Expand Down Expand Up @@ -148,12 +157,6 @@ function(bolt_add_library target_name)
return()
endif()

if(FIRST_LEVEL_DIR IN_LIST EXTENSIONS_COMP_LIST)
list(APPEND EXTENSIONS_OBJECT_TARGETS $<TARGET_OBJECTS:${target_name}>)
set(EXTENSIONS_OBJECT_TARGETS ${EXTENSIONS_OBJECT_TARGETS} CACHE INTERNAL "")
return()
endif()

message(FATAL_ERROR "New component ${target_name} in ${CURRENT_RELATIVE_PATH}?")
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion bolt/connectors/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# This modified file is released under the same license.
# --------------------------------------------------------------------------

bolt_add_library(bolt_fuzzer_connector OBJECT FuzzerConnector.cpp)
bolt_add_library(bolt_fuzzer_connector FuzzerConnector.cpp)

target_link_libraries(bolt_fuzzer_connector bolt_connector bolt_vector_fuzzer)

Expand Down
2 changes: 1 addition & 1 deletion bolt/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if(${BOLT_BUILD_TESTING})
endif()

bolt_add_library(bolt_config Config.cpp Context.cpp)
target_link_libraries(bolt_config bolt_exception Folly::folly)
target_link_libraries(bolt_config Folly::folly)

bolt_add_library(
bolt_core Expressions.cpp PlanFragment.cpp PlanNode.cpp QueryConfig.cpp QueryCtx.cpp
Expand Down
2 changes: 1 addition & 1 deletion bolt/cudf/exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

add_library(bolt_cudf_exec HashAggregation.cpp InterOp.cpp OrderBy.cpp)
bolt_add_library(bolt_cudf_exec HashAggregation.cpp InterOp.cpp OrderBy.cpp)

target_include_directories(bolt_cudf_exec PRIVATE ${cudf_INCLUDE_DIRS})

Expand Down
2 changes: 1 addition & 1 deletion bolt/torch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

add_library(bolt_torch Compatibility.cpp Operator.cpp PlanNode.cpp Tensor.cpp Utils.cpp)
bolt_add_library(bolt_torch Compatibility.cpp Operator.cpp PlanNode.cpp Tensor.cpp Utils.cpp)

target_include_directories(
bolt_torch
Expand Down
23 changes: 23 additions & 0 deletions doc/do-cmake-right.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Do CMake Right

Please write CMake scripts in a modern style, and follow the best practices in [Effective Modern CMake](https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1).

## Adding a new CMake target in Bolt

### Adding a CMake target into Bolt engine,
Use the `bolt_add_library` command to add CMake target. It is a wrapper of the `add_library` command(see [here](https://github.com/bytedance/bolt/issues/139).
It will turn this target into an `OBJECT` target, and categorize and assemble it into the correct Bolt's sub-components.

Take this CMake target `bolt_config` for example:
```
# Step 1: turn bolt_config into an OBJECT target.
# Step 2: add bolt_config into bolt_engine sub-component according to its directory hierarchy.
bolt_add_library(bolt_config Config.cpp Context.cpp)

target_link_libraries(bolt_config PUBLIC Folly::folly)
```

## References
- [Effective Modern CMake](https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1)
- [Advanced Dependencies Model in Conan 2.0](https://www.youtube.com/watch?v=kKGglzm5ous)
- [CMake: Public VS Private VS Interface](https://leimao.github.io/blog/CMake-Public-Private-Interface/)