Merge pull request #316 from zhaozg/fix/stdio
cmake: new option BUILD_NO_STDIO to enable MINIZ_NO_STDIO
This commit is contained in:
commit
35528ad769
@ -42,6 +42,7 @@ option(BUILD_FUZZERS "Build fuzz targets" OFF)
|
|||||||
option(AMALGAMATE_SOURCES "Amalgamate sources into miniz.h/c" OFF)
|
option(AMALGAMATE_SOURCES "Amalgamate sources into miniz.h/c" OFF)
|
||||||
option(BUILD_HEADER_ONLY "Build a header-only version" OFF)
|
option(BUILD_HEADER_ONLY "Build a header-only version" OFF)
|
||||||
option(BUILD_SHARED_LIBS "Build shared library instead of static" OFF)
|
option(BUILD_SHARED_LIBS "Build shared library instead of static" OFF)
|
||||||
|
option(BUILD_NO_STDIO" Build a without stdio version" OFF)
|
||||||
option(BUILD_TESTS "Build tests" ${MINIZ_STANDALONE_PROJECT})
|
option(BUILD_TESTS "Build tests" ${MINIZ_STANDALONE_PROJECT})
|
||||||
option(INSTALL_PROJECT "Install project" ${MINIZ_STANDALONE_PROJECT})
|
option(INSTALL_PROJECT "Install project" ${MINIZ_STANDALONE_PROJECT})
|
||||||
|
|
||||||
@ -178,6 +179,10 @@ if(NOT BUILD_HEADER_ONLY)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_NO_STDIO)
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE MINIZ_NO_STDIO)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_property(TARGET ${PROJECT_NAME} PROPERTY
|
set_property(TARGET ${PROJECT_NAME} PROPERTY
|
||||||
INTERFACE_${PROJECT_NAME}_MAJOR_VERSION ${MINIZ_API_VERSION})
|
INTERFACE_${PROJECT_NAME}_MAJOR_VERSION ${MINIZ_API_VERSION})
|
||||||
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY
|
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY
|
||||||
@ -242,8 +247,10 @@ if(BUILD_EXAMPLES)
|
|||||||
|
|
||||||
add_executable(example1 ${EXAMPLE1_SRC_LIST})
|
add_executable(example1 ${EXAMPLE1_SRC_LIST})
|
||||||
target_link_libraries(example1 miniz)
|
target_link_libraries(example1 miniz)
|
||||||
add_executable(example2 ${EXAMPLE2_SRC_LIST})
|
if(NOT BUILD_NO_STDIO)
|
||||||
target_link_libraries(example2 miniz)
|
add_executable(example2 ${EXAMPLE2_SRC_LIST})
|
||||||
|
target_link_libraries(example2 miniz)
|
||||||
|
endif()
|
||||||
add_executable(example3 ${EXAMPLE3_SRC_LIST})
|
add_executable(example3 ${EXAMPLE3_SRC_LIST})
|
||||||
target_link_libraries(example3 miniz)
|
target_link_libraries(example3 miniz)
|
||||||
add_executable(example4 ${EXAMPLE4_SRC_LIST})
|
add_executable(example4 ${EXAMPLE4_SRC_LIST})
|
||||||
@ -298,17 +305,18 @@ if(BUILD_FUZZERS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_TESTS)
|
if(BUILD_TESTS)
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
||||||
|
|
||||||
add_executable(catch_tests tests/main.cpp
|
add_executable(catch_tests tests/main.cpp tests/catch_amalgamated.cpp)
|
||||||
tests/catch_amalgamated.cpp)
|
if(BUILD_NO_STDIO)
|
||||||
target_link_libraries(catch_tests miniz)
|
target_compile_definitions(catch_tests PRIVATE -DMINIZ_NO_STDIO)
|
||||||
|
endif()
|
||||||
|
target_link_libraries(catch_tests miniz)
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
add_test(NAME catch_tests
|
add_test(NAME catch_tests COMMAND $<TARGET_FILE:catch_tests>)
|
||||||
COMMAND $<TARGET_FILE:catch_tests>)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(INCLUDE_INSTALL_DIR "include")
|
set(INCLUDE_INSTALL_DIR "include")
|
||||||
|
|||||||
@ -5,8 +5,11 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define unlink _unlink
|
#define unlink _unlink
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MINIZ_NO_STDIO
|
||||||
bool create_test_zip()
|
bool create_test_zip()
|
||||||
{
|
{
|
||||||
unlink("test.zip");
|
unlink("test.zip");
|
||||||
@ -79,6 +82,7 @@ TEST_CASE("Zip writer tests")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST_CASE("Tinfl / tdefl tests")
|
TEST_CASE("Tinfl / tdefl tests")
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user