-
Notifications
You must be signed in to change notification settings - Fork 589
feat(cmake): make BUILD_SEPARATE_LIBS work with BUILD_MERGED_PLUGINS #260
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
Conversation
@hchunhui Please have a look. |
@lotem I can't reproduce the issue in Linux (CMake 3.13.4). So I think it is a macOS specific issue. Maybe we should keep the workaround. |
@hchunhui That's true. I also tested in Linux, different results. Another difference is: in Linux there's no need to because of this, I have to repeat |
install(TARGETS rime-dict DESTINATION ${LIB_INSTALL_DIR}) | ||
|
||
add_library(rime-gears ${rime_gears_src}) | ||
target_link_libraries(rime-gears |
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.
target_link_libraries(rime-gears | |
target_link_libraries(rime-gears ${rime_gears_deps}) |
There is no need to link ${rime_library}
, ${rime_gears_deps}
, ${rime_dict_library}
.
I have tested it in Linux, and it should work in macOS.
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.
No this doesn't work for the macOS build.
Errors were cannot find symbol in rime libraries it depends on.
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.
Maybe the solution is
target_link_libraries(rime-gears ${rime_gears_deps})
IF(APPLE)
SET_TARGET_PROPERTIES(rime-gears PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
ENDIF(APPLE)
References:
[1] https://stackoverflow.com/questions/42722759/portable-plugins-with-cmake
[2] https://stackoverflow.com/questions/36662920/xcode-clang-link-build-dynamic-framework-or-dylib-not-embed-dependencies
src/CMakeLists.txt
Outdated
${rime_gears_deps} | ||
${rime_library} | ||
${rime_dict_library}) | ||
add_dependencies(rime-gears |
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 line can be removed.
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. I'm testing. Seems to work without add_dependencies()
. As all folks say.
if(XCODE_VERSION) | ||
set_target_properties(rime-gears PROPERTIES INSTALL_NAME_DIR "@rpath") | ||
endif() | ||
install(TARGETS rime-gears DESTINATION ${LIB_INSTALL_DIR}) | ||
|
||
add_library(rime-levers ${rime_levers_src}) | ||
target_link_libraries(rime-levers |
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.
Same as above.
add_library(rime-plugins | ||
${rime_plugins_src} | ||
${rime_plugins_objs}) | ||
target_link_libraries(rime-plugins |
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.
Same. Just link ${rime_plugins_deps}
|
||
set(rime_patch_src "rime_patch.cc") | ||
add_executable(rime_patch ${rime_patch_src}) | ||
target_link_libraries(rime_patch ${rime_library} ${rime_gears_library}) | ||
add_dependencies(rime_patch ${rime_library} ${rime_gears_library}) | ||
target_link_libraries(rime_patch |
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.
My test shows rime_patch depends on ${rime_dict_library}
I see. The reason is that you use static build. |
I need some time to recall the solution. |
No worries. I'll working on it. |
By the way, while experimenting with the
In |
Merged. |
FYI |
create separate libraries by module, and an optional
rime-plugins
library.