mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
- Split monolithic 235-line CMakeLists.txt into focused modules - Main file reduced to 78 lines with clear section organization - Created 5 specialized modules: * ZstdVersion.cmake - CMake policies and version management * ZstdOptions.cmake - Build options and platform configuration * ZstdDependencies.cmake - External dependency management * ZstdBuild.cmake - Build targets and validation * ZstdPackage.cmake - Package configuration generation Benefits: - Improved readability and maintainability - Better separation of concerns - Easier debugging and modification - Preserved 100% backward compatibility - All existing build options and targets unchanged The refactored build system passes all tests and maintains identical functionality while being much easier to understand and maintain.
43 lines
1.3 KiB
CMake
43 lines
1.3 KiB
CMake
# ################################################################
|
|
# ZSTD Build Targets Configuration
|
|
# ################################################################
|
|
|
|
# Always build the library first (this defines ZSTD_BUILD_STATIC/SHARED options)
|
|
add_subdirectory(lib)
|
|
|
|
# Validate build configuration after lib options are defined
|
|
if(ZSTD_BUILD_PROGRAMS)
|
|
if(NOT ZSTD_BUILD_STATIC AND NOT ZSTD_PROGRAMS_LINK_SHARED)
|
|
message(SEND_ERROR "Static library required to build zstd CLI programs")
|
|
elseif(NOT ZSTD_BUILD_SHARED AND ZSTD_PROGRAMS_LINK_SHARED)
|
|
message(SEND_ERROR "Shared library required to build zstd CLI programs")
|
|
endif()
|
|
endif()
|
|
|
|
if(ZSTD_BUILD_TESTS AND NOT ZSTD_BUILD_STATIC)
|
|
message(SEND_ERROR "Static library required to build test suite")
|
|
endif()
|
|
|
|
# Add programs if requested
|
|
if(ZSTD_BUILD_PROGRAMS)
|
|
add_subdirectory(programs)
|
|
endif()
|
|
|
|
# Add tests if requested
|
|
if(ZSTD_BUILD_TESTS)
|
|
enable_testing()
|
|
add_subdirectory(tests)
|
|
endif()
|
|
|
|
# Add contrib utilities if requested
|
|
if(ZSTD_BUILD_CONTRIB)
|
|
add_subdirectory(contrib)
|
|
endif()
|
|
|
|
# Clean-all target for thorough cleanup
|
|
add_custom_target(clean-all
|
|
COMMAND ${CMAKE_BUILD_TOOL} clean
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/
|
|
COMMENT "Performing complete clean including build directory"
|
|
)
|