Skip to content

Commit

Permalink
[cmake][wip] Separate libraries and extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaZotov committed Oct 14, 2024
1 parent a7cffe0 commit b8c14b4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
cmake_minimum_required(VERSION 3.24)
set(CMAKE_CXX_STANDARD 17)
project(sc-machine VERSION "0.9.0" LANGUAGES C CXX)
message(STATUS "Current Project Version: ${CMAKE_PROJECT_VERSION}")
message(STATUS "Current project version: ${CMAKE_PROJECT_VERSION}")
site_name(www.ostis.net)
cmake_policy(SET CMP0048 NEW)

set(SC_MACHINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})

set(CMAKE_MODULE_PATH "${SC_MACHINE_ROOT}/cmake")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
message(STATUS "Libary output directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(SC_EXTENSIONS_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/extensions)
make_directory(${SC_EXTENSIONS_DIRECTORY})

message(STATUS "Binary output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
message(STATUS "Libary output directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty")

option(SC_BUILD_TESTS "Flag to build unit tests" OFF)
Expand Down Expand Up @@ -99,9 +102,9 @@ message("Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, path:
# Set up dynamic linking paths for our own libraries
# For macOS, use @loader_path instead of $ORIGIN
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib")
set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../lib;@loader_path/../lib/extensions")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib")
set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib;$ORIGIN/../lib/extensions")
endif()

# Always use full RPATH
Expand Down
2 changes: 1 addition & 1 deletion cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ install(TARGETS
)

# a target set for things we don't want to export to the consumers
install(TARGETS sc-server-lib EXPORT privateExport LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS sc-kpm-search sc-kpm-utils sc-kpm-ui sc-server-lib EXPORT privateExport LIBRARY DESTINATION lib/extensions)

install(EXPORT sc-machineExport
FILE sc-machineTargets.cmake
Expand Down
1 change: 1 addition & 0 deletions sc-kpm/sc-search/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS
add_library(sc-kpm-search SHARED ${SOURCES})
target_link_libraries(sc-kpm-search LINK_PUBLIC sc-kpm-common)
target_include_directories(sc-kpm-search PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
set_target_properties(sc-kpm-search PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY})

if(${SC_CLANG_FORMAT_CODE})
target_clangformat_setup(sc-kpm-search)
Expand Down
1 change: 1 addition & 0 deletions sc-kpm/sc-ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target_link_libraries(sc-kpm-ui
LINK_PUBLIC nlohmann_json::nlohmann_json
)
target_include_directories(sc-kpm-ui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
set_target_properties(sc-kpm-ui PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY})

if(${SC_CLANG_FORMAT_CODE})
target_clangformat_setup(sc-kpm-ui)
Expand Down
1 change: 1 addition & 0 deletions sc-kpm/sc-utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS
add_library(sc-kpm-utils SHARED ${SOURCES})
target_link_libraries(sc-kpm-utils LINK_PUBLIC sc-kpm-common)
target_include_directories(sc-kpm-utils PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
set_target_properties(sc-kpm-utils PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY})

if(${SC_CLANG_FORMAT_CODE})
target_clangformat_setup(sc-kpm-utils)
Expand Down
2 changes: 1 addition & 1 deletion sc-machine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dump_memory_statistics = false
dump_memory_statistics_period = 1800

repo_path = ./kb.bin
extensions_path = ./bin/extensions
extensions_path = ./build/lib/extensions

log_type = Console
log_file = ./sc-memory.log
Expand Down
4 changes: 4 additions & 0 deletions sc-memory/sc-memory/tests/scs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ make_tests_from_folder(${CMAKE_CURRENT_SOURCE_DIR}/units
NAME scs-tests
DEPENDS sc-memory
)

if(${SC_CLANG_FORMAT_CODE})
target_clangformat_setup(scs-tests)
endif()
1 change: 1 addition & 0 deletions sc-tools/sc-server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ target_include_directories(sc-server-lib
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
PUBLIC $<INSTALL_INTERFACE:src>
)
set_target_properties(sc-server-lib PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY})

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
Expand Down

0 comments on commit b8c14b4

Please sign in to comment.