diff mbox series

[uclient,01/12] cmake: fix building out of the tree

Message ID 20201210154759.1114-2-ynezz@true.cz
State Accepted
Delegated to: Petr Štetiar
Headers show
Series fixes, improvements and CI | expand

Commit Message

Petr Štetiar Dec. 10, 2020, 3:47 p.m. UTC
When building out of the tree, linker is unable to find the ubox library
so fix it by using find_library CMake command.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 CMakeLists.txt | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 072afef92479..841bc0f8f17c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,8 +10,14 @@  SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 FIND_PATH(ubox_include_dir libubox/ustream-ssl.h)
 INCLUDE_DIRECTORIES(${ubox_include_dir})
 
+IF(BUILD_STATIC)
+  FIND_LIBRARY(ubox_library NAMES ubox.a)
+ELSE(BUILD_STATIC)
+  FIND_LIBRARY(ubox_library NAMES ubox)
+ENDIF(BUILD_STATIC)
+
 ADD_LIBRARY(uclient SHARED uclient.c uclient-http.c uclient-utils.c)
-TARGET_LINK_LIBRARIES(uclient ubox dl)
+TARGET_LINK_LIBRARIES(uclient ${ubox_library} dl)
 
 ADD_EXECUTABLE(uclient-fetch uclient-fetch.c progress.c)
 TARGET_LINK_LIBRARIES(uclient-fetch uclient)