-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Home
Nathan Moinvaziri edited this page Jan 19, 2024
·
3 revisions
cmake -S . -B build -D CMAKE_EXE_LINKER_FLAGS=-static -D CMAKE_SHARED_LINKER_FLAGS=-static
Use CMake's CMAKE_MSVC_RUNTIME_LIBRARY option:
cmake -S . -B build -D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
export LDFLAGS=-static
./configure
If you are building from zlib sources with CMake:
project(myproject)
add_subdirectory(zlib zlib EXCLUDE_FROM_ALL)
# Use EXCLUDE_FROM_ALL to prevent all targets from being added to the solution
add_executable(myproject myproject.c)
target_link_libraries(myproject PRIVATE zlibstatic) # Or "zlib" depending on whether or not you want the shared/static library
If you are using system libraries:
project(myproject)
find_package(ZLIB REQUIRED)
add_executable(myproject myproject.c)
target_link_libraries(myproject PRIVATE ZLIB::ZLIB)