-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake option to build/install only static library #359
Comments
Currently I delete all ExternalProject_Add_Step(external_z remove_shared_lib
DEPENDEES install
COMMAND bash -c "rm /tmp/test-cmake-external-projects/installed/${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}z${CMAKE_SHARED_LIBRARY_SUFFIX}*"
) |
I have not found an eloquent way of handling this either. It's kinda annoying. |
I did this back in November: Sadly, it looks like the owner is missing. |
His Wikipedia page says he is still alive. |
The development branch is active |
Maybe this patch could help? diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0fe939d..8d2f5f1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ set(VERSION "1.2.11")
option(ASM686 "Enable building i686 assembly implementation")
option(AMD64 "Enable building amd64 assembly implementation")
+option(SKIP_BUILD_EXAMPLES "Skip build of the examples" OFF)
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
@@ -211,7 +212,15 @@ elseif(BUILD_SHARED_LIBS AND WIN32)
endif()
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
- install(TARGETS zlib zlibstatic
+ if (BUILD_SHARED_LIBS)
+ set(ZLIB_TARGETS zlib)
+ set_target_properties(zlibstatic PROPERTIES EXCLUDE_FROM_ALL ON)
+ else()
+ set(ZLIB_TARGETS zlibstatic)
+ set_target_properties(zlib PROPERTIES EXCLUDE_FROM_ALL ON)
+ endif()
+
+ install(TARGETS ${ZLIB_TARGETS}
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
@@ -230,6 +239,7 @@ endif()
# Example binaries
#============================================================================
+if (NOT SKIP_BUILD_EXAMPLES)
add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example)
@@ -247,3 +257,4 @@ if(HAVE_OFF64_T)
target_link_libraries(minigzip64 zlib)
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
endif()
+endif() |
Again, I did this over a year ago in #315. |
Hope this gets committed one day. Just stumbled over this and this is really extremely annoying, because zlib is used in so many projects and you always need a workaround/patch because static zlib isn't picked up causing linker errors in a static build. |
Any progress regarding this? Just getting the static zlib is so hard, and I don't want to have to patch CMakeLists.txt to do it. |
I also just hit this same issue, would love to get |
I suggest using https://github.com/zlib-ng/ - it is better maintained. |
zlib/CMakeLists.txt
Lines 186 to 187 in cacf7f1
I use zlib as cmake external project
I would like an arg
-DBUILD_SHARED_LIB=OFF
The text was updated successfully, but these errors were encountered: