-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
bzip2: modernize more #13703
Closed
Closed
bzip2: modernize more #13703
Changes from all commits
Commits
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 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 |
---|---|---|
@@ -1,44 +1,36 @@ | ||
cmake_minimum_required(VERSION 3.4) | ||
project(bzip2 C) | ||
project(bzip2 LANGUAGES C) | ||
|
||
include(GNUInstallDirs) | ||
|
||
if(MSVC OR MSVC90 OR MSVC10) | ||
set(MSVC ON) | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
endif() | ||
|
||
set(SOURCE_SUBFOLDER ${CMAKE_CURRENT_SOURCE_DIR}/src) | ||
set(BZ2_LIBRARY bz2) | ||
|
||
option(BZ2_BUILD_EXE ON) | ||
|
||
set(BZ2_TARGETS ${BZ2_LIBRARY}) | ||
|
||
add_library(${BZ2_LIBRARY} ${SOURCE_SUBFOLDER}/blocksort.c | ||
${SOURCE_SUBFOLDER}/bzlib.c | ||
${SOURCE_SUBFOLDER}/compress.c | ||
${SOURCE_SUBFOLDER}/crctable.c | ||
${SOURCE_SUBFOLDER}/decompress.c | ||
${SOURCE_SUBFOLDER}/huffman.c | ||
${SOURCE_SUBFOLDER}/randtable.c | ||
${SOURCE_SUBFOLDER}/bzlib.h | ||
${SOURCE_SUBFOLDER}/bzlib_private.h) | ||
target_include_directories(${BZ2_LIBRARY} PRIVATE ${SOURCE_SUBFOLDER}) | ||
option(BZ2_BUILD_EXE "Build bzip2 utility" ON) | ||
|
||
add_library(bz2 | ||
${BZ2_SRC_DIR}/blocksort.c | ||
${BZ2_SRC_DIR}/bzlib.c | ||
${BZ2_SRC_DIR}/compress.c | ||
${BZ2_SRC_DIR}/crctable.c | ||
${BZ2_SRC_DIR}/decompress.c | ||
${BZ2_SRC_DIR}/huffman.c | ||
${BZ2_SRC_DIR}/randtable.c | ||
) | ||
target_include_directories(bz2 PUBLIC ${BZ2_SRC_DIR}) | ||
set_target_properties(bz2 PROPERTIES | ||
VERSION ${BZ2_VERSION_STRING} | ||
SOVERSION ${BZ2_VERSION_MAJOR} | ||
WINDOWS_EXPORT_ALL_SYMBOLS ON | ||
) | ||
|
||
install( | ||
TARGETS bz2 | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
install(FILES ${BZ2_SRC_DIR}/bzlib.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
if(BZ2_BUILD_EXE) | ||
add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_SUBFOLDER}/bzip2.c) | ||
target_link_libraries(${CMAKE_PROJECT_NAME} ${BZ2_LIBRARY}) | ||
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${SOURCE_SUBFOLDER}) | ||
list(APPEND BZ2_TARGETS ${CMAKE_PROJECT_NAME}) | ||
add_executable(bzip2 ${BZ2_SRC_DIR}/bzip2.c) | ||
target_link_libraries(bzip2 PRIVATE bz2) | ||
install(TARGETS bzip2 DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
endif() | ||
|
||
set_target_properties(${BZ2_LIBRARY} PROPERTIES VERSION ${BZ2_VERSION_STRING} SOVERSION ${BZ2_VERSION_MAJOR}) | ||
|
||
install(TARGETS ${BZ2_TARGETS} | ||
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
|
||
install(FILES ${SOURCE_SUBFOLDER}/bzlib.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
This file contains 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 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 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 |
---|---|---|
@@ -1,25 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import cross_building | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import CMake, cmake_layout | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
test_type = "explicit" | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not cross_building(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains 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 |
---|---|---|
@@ -1,16 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package LANGUAGES C) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(BZip2 REQUIRED) | ||
message("BZIP2_FOUND: ${BZIP2_FOUND}") | ||
message("BZIP2_NEED_PREFIX: ${BZIP2_NEED_PREFIX}") | ||
message("BZIP2_INCLUDE_DIRS: ${BZIP2_INCLUDE_DIRS}") | ||
message("BZIP2_INCLUDE_DIR: ${BZIP2_INCLUDE_DIR}") | ||
message("BZIP2_LIBRARIES: ${BZIP2_LIBRARIES}") | ||
message("BZIP2_VERSION_STRING: ${BZIP2_VERSION_STRING}") | ||
|
||
add_executable(test_package ../test_package/test_package.c) | ||
target_link_libraries(test_package PRIVATE BZip2::BZip2) | ||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package) |
This file contains 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
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.
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.
@jwillikers @toge Since you are also helping to opening/reviewing PRs -- please mark sure this is not being used ❤️
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.
Why? It's a better way than tones of TODO to track conan v1 stuff which are unused in conan v2 client. Code is better than comments.
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.
Conan 2.0 is still beta, which means, not totally stable. It will accept env_info soon, so it should work for both versions. Also, adding an
if
adds more complexity, okay a recipe is small, but still, a new condition for something that should work is too much.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.
@uilianries can we avoid conditional code to check for v1/v2 from the recipe code? IMO, it should be possible to write recipe compatible with both v1 and v2 simultaneously, using only some common sub-set of v1/v2 features. if it's problematic, may v2 provide some dummy/stub objects to make migration process easier?
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.
@SSE4 Yes, it's possible to avoid conditional code. We have added new issues for Conan v2, keeping compatibility, or at least some stub. env_info is one case, which will be supported on beta-5, but without any practical effect, only to keep Conan v1 working with v2.
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.
@prince-chrismc What about its use in the
header-only
template? https://github.com/conan-io/conan-center-index/blob/master/docs/package_templates/header_only/all/conanfile.pyThere 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.
#13754
Removing it . Thanks for pointing it out