-
Notifications
You must be signed in to change notification settings - Fork 26
Various CMake modernizations #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
413d38e
Update to version 3.0.0
aaf7ac3
Authors
4e7f20f
Require C++14 to fix build errors (tested on Ubuntu 24 + GCC 13 x86) …
Mq-b 087c681
Update README.md: Replace C++11 to C++14
Lecrapouille d779ccd
CI: add Ubuntu + CMake
5f482e3
Disable temporary a test for Windows #30
237c8f2
Include zipper from CMake #31
7afe417
Fix English
7fa84fa
Update CI: CMakeHelloWorld #31
Lecrapouille 8d6da92
Update to version 3.0.1
Lecrapouille 6c423cc
Update Makefile #33
Lecrapouille 07b4903
Update licenses #38
Lecrapouille 3938d0a
Update minizip
Lecrapouille f859409
Add support for using packaged GTest (#37)
LecrisUT f5f85e1
Update minizip #35
Lecrapouille 157bb70
CMake: fetch minizip and zlib #34
Lecrapouille 0f0bce3
Missing update version in CMake #36
Lecrapouille e1f9805
Set tags to third parties
Lecrapouille 34323b0
Misc changes Makefile
Lecrapouille 11b0a2d
Export build-tree targets
LecrisUT 2821036
Simplify the Config.cmake export
LecrisUT 17ebaec
Move and rewrite third-party dependencies
LecrisUT 1bffa4f
Use namepsaced options
LecrisUT e3c0289
Use a more modern design for the project
LecrisUT 247b888
Need to bump minimum CMake for CMP0079
LecrisUT 05a443c
Fix minizip include path
LecrisUT db578ad
Merge branch 'master' into cmake/modern
Lecrapouille File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Support for FetchContent/find_package integration using CMake 3.24 | ||
| set(fetch_content_extra_args) | ||
| if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) | ||
| list(APPEND fetch_content_extra_args | ||
| FIND_PACKAGE_ARGS CONFIG | ||
| ) | ||
| endif() | ||
|
|
||
| # Declare the dependencies | ||
| # Some default options are overwritten to better support bundled buildings | ||
| option(WITH_GTEST "zipper: Override" OFF) | ||
| option(WITH_FUZZERS "zipper: Override" OFF) | ||
| option(WITH_BENCHMARKS "zipper: Override" OFF) | ||
| # TODO: Do without the ZLIB_COMPAT | ||
| option(ZLIB_COMPAT "zipper: Override" ON) | ||
| option(ZLIB_ENABLE_TESTS "zipper: Override" OFF) | ||
| option(SKIP_INSTALL_ALL "zipper: Override" ON) | ||
| FetchContent_Declare(zlib-ng | ||
| GIT_REPOSITORY https://github.com/zlib-ng/zlib-ng.git | ||
| GIT_TAG 2.2.4 | ||
| ${fetch_content_extra_args} | ||
| ) | ||
|
|
||
| option(USE_AES "zipper: Override" ON) | ||
| FetchContent_Declare(minizip | ||
| GIT_REPOSITORY https://github.com/Lecrapouille/minizip.git | ||
| GIT_TAG v1.2 | ||
| ${fetch_content_extra_args} | ||
| ) | ||
|
|
||
| # If we are asked to use submodules, override the paths to point to | ||
| # the submodule destination | ||
| if(ZIPPER_USE_LOCAL_SUBMODULES) | ||
| set(FETCHCONTENT_SOURCE_DIR_MINIZIP ${CMAKE_CURRENT_SOURCE_DIR}/minizip CACHE PATH | ||
| "zipper: Override (USE_LOCAL_SUBMODULES)" | ||
| ) | ||
| set(FETCHCONTENT_SOURCE_DIR_ZLIB-NG ${CMAKE_CURRENT_SOURCE_DIR}/zlib-ng CACHE PATH | ||
| "zipper: Override (USE_LOCAL_SUBMODULES)" | ||
| ) | ||
| endif() | ||
|
|
||
| # Make all dependencies build as static libraries | ||
| # TODO: This can be scoped for each dependency, but requires | ||
| # reorganization of the folder structure or CMake 3.25 | ||
| set(BUILD_SHARED_LIBS OFF) | ||
|
|
||
| # Do the actual add_subdirectory/find_package calls | ||
| FetchContent_MakeAvailable(minizip zlib-ng) | ||
|
|
||
| # Additional compatibility support because the dependencies do not properly support | ||
| # FetchContent (gated by <PROJECT_NAME>_SOURCE_DIR) or find_package is not compatible | ||
| if(minizip_SOURCE_DIR) | ||
| # Ugly hack to make sure #include <minizip/*> works | ||
| execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/include) | ||
| execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink | ||
| ${minizip_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/include/minizip | ||
| ) | ||
| target_include_directories(minizip PUBLIC | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> | ||
| ) | ||
| add_library(MINIZIP::minizip ALIAS minizip) | ||
| endif() | ||
|
|
||
| if(zlib-ng_SOURCE_DIR) | ||
| # TODO: after ZLIB_COMPAT is off, switch to zlib-ng | ||
| add_library(ZLIB::zlib ALIAS zlib) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| install(DIRECTORY Zipper/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Zipper) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| target_sources(zipper PRIVATE | ||
| Zipper.cpp | ||
| Unzipper.cpp | ||
| ) | ||
| add_subdirectory(utils) | ||
|
|
||
| # Export symbols for Windows and DLLs. | ||
| if(WIN32 AND ZIPPER_SHARED_LIB) | ||
| set(CMAKE_CXX_VISIBILITY_PRESET hidden) | ||
| set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) | ||
|
|
||
| # Include and setup for exporting symbols | ||
| include(GenerateExportHeader) | ||
|
|
||
| # Generate export header for shared library symbols | ||
| generate_export_header(zipper | ||
| BASE_NAME zipper | ||
| EXPORT_MACRO_NAME ZIPPER_EXPORT | ||
| EXPORT_FILE_NAME zipper_export.h | ||
| ) | ||
| target_compile_definitions(zipper PRIVATE zipper_EXPORTS) | ||
| target_compile_definitions(zipper PUBLIC ZIPPER_EXPORT_DEFINED) | ||
|
|
||
| install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zipper_export.h | ||
| DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
| ) | ||
| else() | ||
| # For all other cases, undefine the macro | ||
| target_compile_options(zipper PRIVATE -UZIPPER_EXPORT_DEFINED) | ||
| endif() | ||
|
|
||
| # Include directories configuration | ||
| target_include_directories(zipper PRIVATE | ||
| ${CMAKE_CURRENT_SOURCE_DIR} | ||
| ) | ||
|
|
||
| # Public include directories | ||
| target_include_directories(zipper PUBLIC | ||
| $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
| # for the zipper_export.h file. Is it needed though? | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
| ) | ||
|
|
||
| # Library dependencies | ||
| target_link_libraries(zipper PRIVATE | ||
| MINIZIP::minizip | ||
| # TODO: Use the non-compat version | ||
| ZLIB::zlib | ||
| ) | ||
|
|
||
| install(TARGETS zipper | ||
| EXPORT zipperTargets | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| target_sources(zipper PRIVATE | ||
| Path.cpp | ||
| Timestamp.cpp | ||
| glob.cpp | ||
| ) | ||
|
|
||
| # Add platform-specific dependencies | ||
| if(WIN32) | ||
| target_sources(zipper PRIVATE | ||
| dirent.c | ||
| ) | ||
| target_compile_definitions(zipper PRIVATE | ||
| # Prevent Windows' min/max macros from conflicting with std::min/max | ||
| NOMINMAX=ON | ||
| ) | ||
| endif() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, potatoes. Can you fix the Makefile part to account for this change? This change would be needed to support using system packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an issue for me with Makefile: it's just fixing a -I piece of cake. I find sad that the hard part is always coming from CMake. On the original project 99% of issues come from CMake that is why I used my Makefile system. I'm not even able to compile with your changes. The nightmare is coming back again ;(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- The following OPTIONAL packages have not been found:
-- Configuring done (10.5s)
CMake Error: install(EXPORT "zipperTargets" ...) includes target "zipper" which requires target "zlib" that is not in any export set.
CMake Error in CMakeLists.txt:
export called with target "zipper" which requires target "minizip" that is
not in any export set.
CMake Error in CMakeLists.txt:
export called with target "zipper" which requires target "zlib" that is not
in any export set.
-- Generating done (0.0s)
CMake Generate step failed. Build files cannot be regenerated correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are not optional packages. They either comes from initially with
make download-external-libsthen I added git submodules for Red-HatThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a complex issue about static libraries requiring to have all dependencies installed. Iirc, that is an existing issue.
I can look into that afterwards, but for now, try building with
-DZIPPER_SHARED_LIBS=ONThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LecrisUT why not letting people doing git clone ... --recurse then either our CMakeLists includes directly the CMake inside the external/minizip/CMakeLists.txt our we compile the C++ files directly ? I can modify headers for you now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LecrisUT I have commited the includes. I'm not sure to switch "" to <> because, if I remember well the compiler will search for OS files first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that is desired. You are signalling that this is a third-party library. The
-Iflags will make sure that the system dependency is picked up.The reason for this change is to make way to allow building against a system
minizipwhich exports it as#include <minizip/*>. This will make it easier to pull inminizip-ng-compat-develmake it compatible with that, and move the bundledminizipto the upstream version.