-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
54 lines (47 loc) · 2.42 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
cmake_minimum_required(VERSION 3.14)
project("undreamai" C CXX)
add_subdirectory("llama.cpp")
if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set_property(DIRECTORY llama.cpp PROPERTY CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif()
if (NOT WIN32)
set(STATIC_FLAGS "-fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STATIC_FLAGS}")
set_target_properties(common PROPERTIES COMPILE_FLAGS ${STATIC_FLAGS})
set_target_properties(ggml PROPERTIES COMPILE_FLAGS ${STATIC_FLAGS})
set_target_properties(llama PROPERTIES COMPILE_FLAGS ${STATIC_FLAGS})
target_compile_options(ggml PRIVATE -Wno-return-type -Wno-sometimes-uninitialized)
endif()
set(LIBRARY undreamai)
add_library(${LIBRARY} SHARED stringwrapper.cpp utils_callback.hpp undreamai.cpp)
install(TARGETS ${LIBRARY} LIBRARY)
target_include_directories(${LIBRARY} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} llama.cpp/examples/server)
target_link_libraries(${LIBRARY} PRIVATE common ${CMAKE_THREAD_LIBS_INIT})
target_compile_features(${LIBRARY} PRIVATE cxx_std_11)
add_compile_definitions(${LIBRARY} PRIVATE UNDREAMAI_EXPORTS)
if (LLAMA_SERVER_SSL)
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL REQUIRED)
target_link_libraries(${LIBRARY} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
target_compile_definitions(${LIBRARY} PRIVATE CPPHTTPLIB_OPENSSL_SUPPORT)
endif()
set(TEST undreamai_test)
add_executable(${TEST} undreamai_test.cpp stringwrapper.cpp)
install(TARGETS ${TEST} RUNTIME)
target_include_directories(${TEST} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} llama.cpp/examples/server)
target_link_libraries(${TEST} PRIVATE ${LIBRARY} common ${CMAKE_THREAD_LIBS_INIT})
target_compile_features(${TEST} PRIVATE cxx_std_11)
add_compile_definitions(${TEST} PRIVATE UNDREAMAI_EXPORTS)
if (BUILD_UNDREAMAI_SERVER)
set(SERVER undreamai_server)
add_executable(${SERVER} undreamai_server.cpp stringwrapper.cpp)
install(TARGETS ${SERVER} RUNTIME)
target_include_directories(${SERVER} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} llama.cpp/examples/server)
target_link_libraries(${SERVER} PRIVATE ${LIBRARY} common ${CMAKE_THREAD_LIBS_INIT})
target_compile_features(${SERVER} PRIVATE cxx_std_11)
add_compile_definitions(${SERVER} PRIVATE UNDREAMAI_EXPORTS)
if (LLAMA_SERVER_SSL)
target_link_libraries(${SERVER} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
target_compile_definitions(${SERVER} PRIVATE CPPHTTPLIB_OPENSSL_SUPPORT)
endif()
endif()