chore: fix limonp's path#206
Merged
yanyiwu merged 1 commit intoyanyiwu:masterfrom Jul 26, 2025
Freed-Wu:limonp
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the CMake configuration to improve dependency management for the limonp library by adding support for both system-installed and local copies of the library.
- Replaces hardcoded include directory path with dynamic detection of limonp library
- Adds fallback mechanism to use local deps directory when system package is not found
- Maintains backward compatibility with existing build setups
| PROJECT(CPPJIEBA) | ||
|
|
||
| INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/deps/limonp/include | ||
| find_package(limonp) |
There was a problem hiding this comment.
[nitpick] Consider specifying QUIET to suppress warnings when the package is not found, since you have a fallback mechanism: find_package(limonp QUIET)
Suggested change
| find_package(limonp) | |
| find_package(limonp QUIET) |
Comment on lines
+4
to
11
| find_package(limonp) | ||
| if(limonp_FOUND) | ||
| get_target_property(LIMONP_INCLUDE_DIR limonp::limonp INTERFACE_INCLUDE_DIRECTORIES) | ||
| else() | ||
| set(LIMONP_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/deps/limonp/include") | ||
| endif() | ||
| INCLUDE_DIRECTORIES("${LIMONP_INCLUDE_DIR}" | ||
| ${PROJECT_SOURCE_DIR}/include) |
There was a problem hiding this comment.
The get_target_property call may fail if the target doesn't have INTERFACE_INCLUDE_DIRECTORIES set, which would set LIMONP_INCLUDE_DIR to 'NOTFOUND'. Consider checking the result or using target_link_libraries instead of manually extracting include directories.
Suggested change
| find_package(limonp) | |
| if(limonp_FOUND) | |
| get_target_property(LIMONP_INCLUDE_DIR limonp::limonp INTERFACE_INCLUDE_DIRECTORIES) | |
| else() | |
| set(LIMONP_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/deps/limonp/include") | |
| endif() | |
| INCLUDE_DIRECTORIES("${LIMONP_INCLUDE_DIR}" | |
| ${PROJECT_SOURCE_DIR}/include) | |
| find_package(limonp REQUIRED) | |
| INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include) | |
| if(NOT TARGET cppjieba) | |
| add_library(cppjieba INTERFACE) | |
| target_include_directories(cppjieba INTERFACE | |
| ${PROJECT_SOURCE_DIR}/include | |
| ) | |
| target_link_libraries(cppjieba INTERFACE limonp::limonp) | |
| 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.