2017-11-27 20:48:33 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(zip)
|
2019-03-27 02:45:20 +00:00
|
|
|
enable_language(C)
|
|
|
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
2017-11-27 20:48:33 +00:00
|
|
|
|
|
|
|
if (MSVC)
|
2019-03-27 02:45:20 +00:00
|
|
|
# Use secure functions by defaualt and suppress warnings about "deprecated" functions
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_NONSTDC_NO_WARNINGS=1 /D _CRT_SECURE_NO_WARNINGS=1")
|
|
|
|
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
|
|
|
|
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
|
|
|
|
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra -Werror -pedantic")
|
2017-11-27 20:48:33 +00:00
|
|
|
endif (MSVC)
|
|
|
|
|
|
|
|
# zip
|
|
|
|
set(SRC src/miniz.h src/zip.h src/zip.c)
|
2019-03-27 02:45:20 +00:00
|
|
|
add_library(${PROJECT_NAME} ${SRC})
|
|
|
|
target_include_directories(${PROJECT_NAME} INTERFACE src)
|
2017-11-27 20:48:33 +00:00
|
|
|
|
|
|
|
# test
|
2019-03-27 02:45:20 +00:00
|
|
|
if (NOT CMAKE_DISABLE_TESTING)
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(test)
|
|
|
|
find_package(Sanitizers)
|
|
|
|
add_sanitizers(${PROJECT_NAME} test.exe)
|
|
|
|
add_sanitizers(${PROJECT_NAME} test_miniz.exe)
|
|
|
|
endif()
|
2017-11-27 20:48:33 +00:00
|
|
|
|
2019-03-27 02:45:20 +00:00
|
|
|
install(TARGETS ${PROJECT_NAME}
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
COMPONENT library)
|
|
|
|
install(FILES ${PROJECT_SOURCE_DIR}/src/zip.h DESTINATION include)
|
|
|
|
|
|
|
|
# uninstall target (https://gitlab.kitware.com/cmake/community/wikis/FAQ#can-i-do-make-uninstall-with-cmake)
|
|
|
|
if(NOT TARGET uninstall)
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
|
|
add_custom_target(uninstall
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake)
|
|
|
|
endif()
|