Skip to content

Commit

Permalink
fix static linking for tests and extras, remove unneeded -static flag (
Browse files Browse the repository at this point in the history
…#98)

* fix static linking for tests and extras, remove unneeded -static flag

* Update extras/CMakeLists.txt for proper formating

Co-authored-by: Alex <saharNooby@users.noreply.github.com>

* revert last format commit

* fix indentation once more

---------

Co-authored-by: Alex <saharNooby@users.noreply.github.com>
  • Loading branch information
schamane and saharNooby committed Jun 14, 2023
1 parent 15b7c7b commit 5316068
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions extras/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ function(rwkv_add_extra source)
get_filename_component(EXTRA_TARGET ${source} NAME_WE)
add_executable(rwkv_${EXTRA_TARGET} ${source})
target_link_libraries(rwkv_${EXTRA_TARGET} PRIVATE ggml rwkv)
if (RWKV_STATIC)
get_target_property(target_LINK_OPTIONS rwkv_${EXTRA_TARGET} LINK_OPTIONS)
list(REMOVE_ITEM target_LINK_OPTIONS "-static")
set_target_properties(rwkv_${EXTRA_TARGET} PROPERTIES LINK_OPTIONS "${target_LINK_OPTIONS}")
endif()
endfunction()

file(GLOB extras *.c)
Expand Down
5 changes: 5 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ function(rwkv_add_test source)
endif()
target_link_libraries(${TEST_TARGET} PRIVATE ggml rwkv)
add_test(NAME ${TEST_TARGET} COMMAND $<TARGET_FILE:${TEST_TARGET}> ${ARGN})
if (RWKV_STATIC)
get_target_property(target_LINK_OPTIONS ${TEST_TARGET} LINK_OPTIONS)
list(REMOVE_ITEM target_LINK_OPTIONS "-static")
set_target_properties(${TEST_TARGET} PROPERTIES LINK_OPTIONS "${target_LINK_OPTIONS}")
endif()
endfunction()

file(COPY tiny-rwkv-660K-FP32.bin DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
Expand Down

0 comments on commit 5316068

Please sign in to comment.