Skip to content

Commit

Permalink
build: Split core into spearate library (#15)
Browse files Browse the repository at this point in the history
Separate core into separate library for better build performance and dependencies management.
  • Loading branch information
sitaowang1998 authored Oct 31, 2024
1 parent 1b0c0a9 commit 9b858c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ project(
VERSION 0.1.0
)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Enable exporting compile commands
set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
Expand Down
23 changes: 11 additions & 12 deletions src/spider/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ set(SPIDER_CORE_SOURCES
CACHE INTERNAL
"spider core source files"
)

if(SPIDER_USE_STATIC_LIBS)
add_library(spider_core STATIC)
else()
add_library(spider_core SHARED)
endif()
target_sources(spider_core PRIVATE ${SPIDER_CORE_SOURCES})
target_link_libraries(spider_core PUBLIC Boost::boost PRIVATE absl::flat_hash_map)

set(SPIDER_WORKER_SOURCES worker/worker.cpp CACHE INTERNAL "spider worker source files")

add_executable(spider_worker)
target_compile_features(spider_worker PRIVATE cxx_std_20)
target_sources(
spider_worker
PRIVATE
${SPIDER_CORE_SOURCES}
${SPIDER_WORKER_SOURCES}
)
target_link_libraries(
spider_worker
Boost::boost
absl::flat_hash_map
)
target_sources(spider_worker PRIVATE ${SPIDER_WORKER_SOURCES})
target_link_libraries(spider_worker PRIVATE spider_core)
add_executable(spider::worker ALIAS spider_worker)

0 comments on commit 9b858c9

Please sign in to comment.