-
Notifications
You must be signed in to change notification settings - Fork 22
Getting started
This guide will help you getting started with 11Zip !
First of all, you should create a project with the following structure
│ CMakeLists.txt
│
├───extlibs
└───src
main.cpp
In the CMakeLists.txt
, put the following content :
cmake_minimum_required(VERSION 3.6)
project(myproject)
add_subdirectory(extlibs/elzip)
file(GLOB MYPROJECT_HEADERS include/*.hpp)
file(GLOB MYPROJECT_SOURCES src/*.cpp)
add_executable(myproject ${MYPROJECT_HEADERS} ${MYPROJECT_SOURCES})
target_link_libraries(myproject elzip)
target_include_directories(myproject
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_EXTENSIONS OFF)
Edit the src/main.cpp
and add this :
#include <elzip/elzip.hpp>
int main()
{
elz::extractZip("test.zip", "test");
return 0;
}
Once you have edited all the files above, do a cd extlibs
in your favorite terminal and then type the following command : git clone https://github.com/Sygmei/11zip
.
Before running CMake, create a build
folder inside the project so the structure looks like this :
│ CMakeLists.txt
│
├───build
├───extlibs
│ └───elzip
│ │ CMakeLists.txt
│ │
│ ├───extlibs
│ │ └───minizip
| | ...
│ │
│ ├───include
│ │ └───elzip
│ │ elzip.hpp
│ │ fswrapper.hpp
│ │ unzipper.hpp
│ │ zipper.hpp
│ │
│ └───src
│ elzip.cpp
│ elzip_fs_fallback.cpp
│ unzipper.cpp
│ zipper.cpp
│
└───src
main.cpp
If everything looks correct, go to the build folder with cd build
and run cmake ..
No error should occur and the build
folder should now be filled with build files.
You can compile the project directly in the terminal using the following command : cmake --build .
If there is no error, there should be an executable somewhere in the build
directory (sometimes in subdirectories).
Copy the executable in the build
directory, create an empty test
folder, get a sample test.zip
of your choice somewhere and place it in the build
directory. Once you are done, run the executable and check if the zip was properly unzipped in the test
directory.