diff options
author | nusu-github <29514220+nusu-github@users.noreply.github.com> | 2023-03-24 05:16:48 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-23 21:16:48 +0100 |
commit | ad072fc5ad6f6905a7224ff6ea07c0644aa075b1 (patch) | |
tree | 8522f5edcc606dfb84716531cfaae9ac05913697 /CMakeLists.txt | |
parent | ea10d3ded2994106596ddf8e4ed02741b3e053e6 (diff) |
Generate library with CMake (#430)
* Generate library with CMake
BUILD_SHARED_LIBS to allow llama library to be generated.
* Turn ON PIC when BUILD_SHARED_LIBS is ON
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d952afb..51af97c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,6 +218,9 @@ add_library(utils OBJECT target_include_directories(utils PUBLIC .) target_compile_features(utils PUBLIC cxx_std_11) # don't bump target_link_libraries(utils PRIVATE ${LLAMA_EXTRA_LIBS}) +if (BUILD_SHARED_LIBS) + set_target_properties(utils PROPERTIES POSITION_INDEPENDENT_CODE ON) +endif() add_library(ggml OBJECT ggml.c @@ -226,6 +229,9 @@ add_library(ggml OBJECT target_include_directories(ggml PUBLIC .) target_compile_features(ggml PUBLIC c_std_11) # don't bump target_link_libraries(ggml PRIVATE Threads::Threads ${LLAMA_EXTRA_LIBS}) +if (BUILD_SHARED_LIBS) + set_target_properties(ggml PROPERTIES POSITION_INDEPENDENT_CODE ON) +endif() add_library(llama llama.cpp @@ -234,6 +240,10 @@ add_library(llama target_include_directories(llama PUBLIC .) target_compile_features(llama PUBLIC cxx_std_11) # don't bump target_link_libraries(llama PRIVATE utils ggml ${LLAMA_EXTRA_LIBS}) +if (BUILD_SHARED_LIBS) + set_target_properties(llama PROPERTIES POSITION_INDEPENDENT_CODE ON) + target_compile_definitions(llama PRIVATE LLAMA_SHARED LLAMA_BUILD) +endif() # # Executables |