-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
87 lines (69 loc) · 2.84 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
cmake_minimum_required(VERSION 3.10)
project(chromadb VERSION 1.0.3)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if (MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
endif()
include_directories(include)
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
set(SOURCES
src/ChromaDB/Client/ChromaApiClient.cpp
src/ChromaDB/Client/Client.cpp
src/ChromaDB/Resources/Collection.cpp
src/ChromaDB/Embeddings/EmbeddingFunction.cpp
src/ChromaDB/Embeddings/JinaEmbeddingFunction.cpp
src/ChromaDB/Embeddings/OpenAIEmbeddingFunction.cpp
src/ChromaDB/Embeddings/CohereEmbeddingFunction.cpp
src/ChromaDB/Embeddings/VoyageAIEmbeddingFunction.cpp
src/ChromaDB/Embeddings/TogetherAIEmbeddingFunction.cpp
src/ChromaDB/Exceptions/ChromaException.cpp
)
add_library(chromadb SHARED ${SOURCES})
target_link_libraries(chromadb PRIVATE OpenSSL::SSL OpenSSL::Crypto)
set_target_properties(chromadb PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PUBLIC_HEADER "include/ChromaDB/ChromaDB.h"
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)
install(TARGETS chromadb
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/ChromaDB
)
install(DIRECTORY include/ChromaDB/Embeddings DESTINATION include/ChromaDB)
install(DIRECTORY include/ChromaDB/Exceptions DESTINATION include/ChromaDB)
install(DIRECTORY include/ChromaDB/Resources DESTINATION include/ChromaDB)
install(DIRECTORY include/ChromaDB/Utils DESTINATION include/ChromaDB)
install(DIRECTORY include/ChromaDB/Client DESTINATION include/ChromaDB)
install(DIRECTORY include/Http/ DESTINATION include/Http)
install(DIRECTORY include/Json/ DESTINATION include/Json)
# Add Google Test
add_subdirectory(tests/googletest)
# Enable testing
enable_testing()
# Add the test executable
add_executable(runTests tests/test_main.cpp tests/test_client.cpp)
# Ensure Google Test uses the same runtime library
if (MSVC)
set_target_properties(gtest PROPERTIES COMPILE_FLAGS "/MD")
set_target_properties(gtest_main PROPERTIES COMPILE_FLAGS "/MD")
endif()
# Link the test executable against Google Test and the project library
target_link_libraries(runTests gtest gtest_main chromadb OpenSSL::SSL OpenSSL::Crypto)
set_target_properties(runTests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
# Add a post-build step to copy the DLL to the output directory
add_custom_command(TARGET chromadb POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:chromadb> ${CMAKE_BINARY_DIR}/bin
)
# Add tests to CTest
add_test(NAME ClientTest COMMAND runTests)