cmake: fix building out of the tree
authorPetr Štetiar <ynezz@true.cz>
Tue, 8 Dec 2020 09:06:29 +0000 (10:06 +0100)
committerPetr Štetiar <ynezz@true.cz>
Tue, 8 Dec 2020 11:37:27 +0000 (12:37 +0100)
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

index 072afef92479b2f626a875d810801871afe2e26c..841bc0f8f17cce66c4303b6a3fb6895ae49e39c1 100644 (file)
@@ -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)