-
-
Notifications
You must be signed in to change notification settings - Fork 121
Installing the library
The library can be installed as a dependency of your project in a number of different ways:
You can directly integrate the library into your CMake project:
- Either download bit7z's sources to a sub-directory of your project (e.g.,
third_party
), or add this repository as a git submodule of yours. - Then, use the command
add_subdirectory()
in yourCMakeLists.txt
to include bit7z. - Finally, link the
bit7z
library using thetarget_link_libraries()
command.
For example:
add_subdirectory(${CMAKE_SOURCE_DIR}/third_party/bit7z) # Path to bit7z's repository
# Here you can enable/disable bit7z's build options, e.g.:
# set(BIT7Z_USE_NATIVE_STRING ON CACHE BOOL "enable using native OS strings" FORCE)
target_link_libraries(${YOUR_TARGET} PRIVATE bit7z)
Using CPM.cmake
CPMAddPackage("gh:rikyoz/bit7z@<version>") # Replace <version> with the desired one.
# Here you can enable/disable bit7z's build options, e.g.:
# set(BIT7Z_AUTO_FORMAT ON CACHE BOOL "enable auto format support" FORCE)
target_link_libraries(${YOUR_TARGET} PRIVATE bit7z)
Using vcpkg
First, you need to install the library:
vcpkg install bit7z
Then, you add bit7z as a dependency in your project's CMakeLists.txt:
find_package(unofficial-bit7z CONFIG REQUIRED)
target_link_libraries(${YOUR_TARGET} PRIVATE unofficial::bit7z::bit7z64)
If you have built the library manually, you can copy the output library file and bit7z's include
folder into the desired subfolders of your project, and then manually link the library and its link-time dependencies into your application, i.e. if your project uses CMake:
target_include_directories(${YOUR_TARGET} PRIVATE "<path-to-bit7z-include-folder>")
find_library(BIT7Z_LIB bit7z HINTS "<path-to-bit7z-lib-folder>")
target_link_libraries(${YOUR_TARGET} PRIVATE ${BIT7Z_LIB}
$<$<PLATFORM_ID:WIN32>:oleaut32> # Dependency of bit7z on Windows.
$<$<PLATFORM_ID:MINGW>:uuid> # Dependency of bit7z when using MinGW.
$<$<PLATFORM_ID:UNIX>:dl>) # Dependency of bit7z on Unix.
Note
As noted in the list of build options, some options modify the public API provided by the library.
If you change any of these options and build and link the library manually, you'll also need to define the option either as a preprocessor flag (e.g., target_compile_definitions(${YOUR_TARGET} PRIVATE BIT7Z_<OPTION_NAME>)
in CMake) or by uncommenting the corresponding #define
in the include/bit7z/bitdefines.hpp
header).
Important
When manually linking bit7z, ensure that your program links with its platform-specific dependencies:
-
Windows: link your program with
oleaut32
(e.g.,-lbit7z -loleaut32
).-
MinGW: link your program also with
libuuid
(e.g.-lbit7z -loleaut32 -luuid
).
-
MinGW: link your program also with
-
Linux and macOS: link your program with
dl
(e.g.,-lbit7z -ldl
).
When using CMake's add_subdirectory
, CPM.cmake, or vcpkg, these dependencies are automatically linked to your target.
Copyright © 2014 - 2024 Riccardo Ostani (@rikyoz)
- Bit7zLibrary
- BitArchiveEditor
- BitArchiveReader
- BitArchiveWriter
- BitException
- BitFileCompressor
- BitFileExtractor
- BitMemCompressor
- BitMemExtractor
- BitStreamCompressor
- BitStreamExtractor
- BitInFormat