Merge pull request #553 from mrjoel/mrjoel/cmake-optional-lz4c

Add CMake option to not build legacy lz4c program
This commit is contained in:
Yann Collet 2018-08-09 14:07:45 -07:00 committed by GitHub
commit c4dbc37b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,8 @@
set(LZ4_TOP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..") set(LZ4_TOP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
option(LZ4_BUILD_LEGACY_LZ4C "Build lz4c progam with legacy argument support" ON)
# Parse version information # Parse version information
file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MAJOR REGEX "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$") file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MAJOR REGEX "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$")
string(REGEX REPLACE "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$" "\\1" LZ4_VERSION_MAJOR "${LZ4_VERSION_MAJOR}") string(REGEX REPLACE "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$" "\\1" LZ4_VERSION_MAJOR "${LZ4_VERSION_MAJOR}")
@ -122,14 +124,18 @@ else()
endif() endif()
# lz4 # lz4
set(LZ4_PROGRAMS_BUILT lz4cli)
add_executable(lz4cli ${LZ4_CLI_SOURCES}) add_executable(lz4cli ${LZ4_CLI_SOURCES})
set_target_properties(lz4cli PROPERTIES OUTPUT_NAME lz4) set_target_properties(lz4cli PROPERTIES OUTPUT_NAME lz4)
target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY}) target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY})
# lz4c # lz4c
add_executable(lz4c ${LZ4_CLI_SOURCES}) if (LZ4_BUILD_LEGACY_LZ4C)
set_target_properties(lz4c PROPERTIES COMPILE_DEFINITIONS "ENABLE_LZ4C_LEGACY_OPTIONS") list(APPEND LZ4_PROGRAMS_BUILT lz4c)
target_link_libraries(lz4c ${LZ4_LINK_LIBRARY}) add_executable(lz4c ${LZ4_CLI_SOURCES})
set_target_properties(lz4c PROPERTIES COMPILE_DEFINITIONS "ENABLE_LZ4C_LEGACY_OPTIONS")
target_link_libraries(lz4c ${LZ4_LINK_LIBRARY})
endif()
# Extra warning flags # Extra warning flags
include (CheckCCompilerFlag) include (CheckCCompilerFlag)
@ -165,7 +171,7 @@ endforeach (flag)
if(NOT LZ4_BUNDLED_MODE) if(NOT LZ4_BUNDLED_MODE)
include(GNUInstallDirs) include(GNUInstallDirs)
install(TARGETS lz4cli lz4c install(TARGETS ${LZ4_PROGRAMS_BUILT}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS ${LZ4_LIBRARIES_BUILT} install(TARGETS ${LZ4_LIBRARIES_BUILT}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"