-
Notifications
You must be signed in to change notification settings - Fork 3.5k
CMake Toolkit: Shared Library as Side Module #16281
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
Changes from all commits
3ff2906
82733b2
d3aa7f3
4f103cb
23cb03b
c442b91
e49a8dc
2296976
afb0439
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6644,7 +6644,7 @@ def line_splitter(data): | |
| Path('codec/CMakeFiles/j2k_to_image.dir/convert.c.o'), | ||
| Path('codec/CMakeFiles/j2k_to_image.dir/__/common/color.c.o'), | ||
| Path('bin/libopenjpeg.a')], | ||
| configure=['cmake', '.'], | ||
| configure=['cmake', '.', '-DBUILD_SHARED_LIBS=OFF'], | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed if the default is set of OFF above?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder as well. Without it the Is the toolchain file even used here?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it's because # OpenJPEG build configuration options.
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)Before this change, this was force-changed to static (in
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see.. I'm ok with the explicit extra |
||
| # configure_args=['--enable-tiff=no', '--enable-jp3d=no', '--enable-png=no'], | ||
| make_args=[]) # no -j 2, since parallel builds can fail | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
not really needed, default is also static.
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.
Our goal should be this table.
add_library(foo)add_library(foo)add_library(foo SHARED)add_library(foo)option(BUILD_SHARED_LIBS "" ON)add_library(foo)option(BUILD_SHARED_LIBS "" ON)The most important thing will be that
option(BUILD_SHARED_LIBS "" ON)should be overridden to OFF for compatibility unlessBUILD_SHARED_LIBS=ONis explicitly specified.Just adding
configure=['cmake', '.', '-DBUILD_SHARED_LIBS=OFF']will be sufficient for this andset(BUILD_SHARED_LIBS OFF)can be deleted.The other solution will be that caching
BUILD_SHARED_LIBS, this will overwriteoption(BUILD_SHARED_LIBS "" ON).Uh oh!
There was an error while loading. Please reload this page.
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.
Hi @nokotan,
what you write in this table is very reasonable, but there is a misunderstanding on your side how CMake works.
Yes,
add_librarydefaults will be based on theBUILD_SHARED_LIBSdefault. That one is static now.No, if a user sets either
set(BUILD_SHARED_LIBS ON)oroption(BUILD_SHARED_LIBS "" ON)this will be overwritten. This is a clear user decision then (in theirCMakeLists.txt) and we cannot overwrite this without disabling shared library support altogether (which was done prior to this PR). In other worlds: the 2nd last row in your table is not possible.All other rows are exactly with this PR as you also wrote.
I hope this clarifies a bit, please let me know if you have more questions.
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.
The question remains,
option(BUILD_SHARED_LIBS "" ON)seems to do nothing whenBUILD_SHARED_LIBSis set by user or is already cached, after CMake 3.13. (CMP0077)Uh oh!
There was an error while loading. Please reload this page.
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.
That is exactly how all cached variables and options work in CMake.
Yes, user CLI parameters, toolchain files and cache files can be used by users to overwrite the default of an
option()- that is fine and how all CMake options should work. If we would mingle with that behavior, then we would break a lot of package management software and stray from community standards.