From 0d0056a043510d70a39faa84ec0a0db8684c480b Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Tue, 10 Sep 2019 23:12:31 +0800 Subject: cmake: fix static build on Linux When building Python, many extra libraries must be included, such as expat and zlib. Signed-off-by: Sean Cross --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77745f95..67b0c18b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,13 @@ if (STATIC_BUILD) add_definitions(-DBOOST_PYTHON_STATIC_LIB) endif() else() + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so") set(link_param "-static") + if (BUILD_PYTHON) + find_package(ZLIB) + find_package(EXPAT) + find_package(Threads) + endif() endif() endif() @@ -267,6 +273,14 @@ foreach (family ${ARCH}) endif() if (BUILD_PYTHON) target_link_libraries(${target} LINK_PUBLIC ${PYTHON_LIBRARIES}) + if (STATIC_BUILD) + target_link_libraries(${target} LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES} ${EXPAT_LIBRARIES} -lutil) + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND MSVC) + else() + target_link_libraries(${target} LINK_PUBLIC -lutil) + endif() + endif() endif() endforeach (target) endforeach (family) -- cgit v1.2.3