Skip to content

Commit

Permalink
Add first CMakeLists.txt, lib7zip builds on msys2 win64
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Nov 20, 2017
1 parent 5bc54ca commit c353aae
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8)

project(lib7zip)

add_subdirectory(Lib7Zip)
add_subdirectory(Test7Zip)

12 changes: 12 additions & 0 deletions Lib7Zip/001_avoid_duplicate_guids.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -Naur upstream-7zip/CPP/Windows/FileIO.h upstream-7zip-patched/CPP/Windows/FileIO.h
--- upstream-7zip/CPP/Windows/FileIO.h 2015-08-02 13:42:34.000000000 +0200
+++ upstream-7zip-patched/CPP/Windows/FileIO.h 2017-11-20 11:21:37.699451700 +0100
@@ -6,7 +6,7 @@
#include "../Common/MyWindows.h"

#if defined(_WIN32) && !defined(UNDER_CE)
-#include <winioctl.h>
+// #include <winioctl.h>
#endif

#include "../Common/MyString.h"
58 changes: 58 additions & 0 deletions Lib7Zip/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 2.8)

project(lib7zip)

set (SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

# ==> 7-zip source download start

set(UPSTREAM_SRC_URL http://www.7-zip.org/a/7z1604-src.7z)
set(UPSTREAM_DIR ${PROJECT_BINARY_DIR}/upstream-7zip)
include(ExternalProject)
ExternalProject_Add(
upstream
URL ${UPSTREAM_SRC_URL}
SOURCE_DIR ${UPSTREAM_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
PATCH_COMMAND dos2unix ${CMAKE_CURRENT_SOURCE_DIR}/001_avoid_duplicate_guids.patch COMMAND patch --ignore-whitespace --strip 1 < ${CMAKE_CURRENT_SOURCE_DIR}/001_avoid_duplicate_guids.patch COMMAND unix2dos ${UPSTREAM_DIR}/CPP/Windows/FileIO.h
)

set(UPSTREAM_INCLUDE_DIR ${UPSTREAM_DIR})

# <== 7-zip source download end

include_directories(
${UPSTREAM_INCLUDE_DIR}
${UPSTREAM_INCLUDE_DIR}/CPP
)

# TODO: includes

set (lib7zip_SOURCES
7ZipArchive.cpp
7ZipArchiveItem.cpp
7zipLibrary.cpp
HelperFuncs.cpp
7ZipArchiveOpenCallback.cpp
7ZipCodecInfo.cpp
7ZipCompressCodecsInfo.cpp
7ZipDllHandler.cpp
7ZipFormatInfo.cpp
7ZipObjectPtrArray.cpp
7ZipOpenArchive.cpp
OSFunctions_UnixLike.cpp
OSFunctions_Win32.cpp
7ZipInStreamWrapper.cpp
)

add_library(7zip STATIC ${lib7zip_SOURCES})
add_dependencies(7zip upstream)

target_compile_options(7zip PRIVATE -std=c++11)

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(7zip -lole32 -loleaut32 -luuid)
target_compile_options(7zip PRIVATE -DUNICODE -D_UNICODE)
endif() # Windows
4 changes: 4 additions & 0 deletions Test7Zip/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 2.8)

project(test7zip)

0 comments on commit c353aae

Please sign in to comment.