-
Notifications
You must be signed in to change notification settings - Fork 45
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
Allow specifying FIND_SHARED_LIBS per-TPL #624
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Samuel E. Browne <[email protected]>
@bartlettroscoe no particular rush on this, but I'd appreciate a review whenever you have the time. |
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.
@sebrowne, thanks for the PR. This is a very reasonable extension. And thanks for adding the test case! (If you revert the change to the *.cmake file, does the test fail? Hopefully yes but it is worth checking.)
Just a coupe of things should be addressed before merging:
- The logic for how the var
${TPL_NAME}_FIND_SHARED_LIBS
is set should be tweaked (see below) - This needs to be documented somehow. I might suggest adding a mention of this variable to the section Building static libraries and executables? (Or it could be a new subsection?)
@@ -411,10 +411,15 @@ function(tribits_tpl_find_include_dirs_and_libraries TPL_NAME) | |||
#print_var(TPL_CMAKE_FIND_LIBRARY_SUFFIXES_DEFAULT) | |||
endif() | |||
|
|||
# Allow per-TPL shared lib find setting | |||
if (NOT DEFINED ${TPL_NAME}_FIND_SHARED_LIBS) |
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.
if (NOT DEFINED ${TPL_NAME}_FIND_SHARED_LIBS) | |
if ("${${TPL_NAME}_FIND_SHARED_LIBS}" STREQUAL "") |
This works if the variable is undefined and of it is set to "unset" state (see How to check for and tweak TriBITS “ENABLE” cache variables).
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.
Alternatively, you could just property define a cache var in one statement with:
set_cache_on_off_empty(
${TPL_NAME}_FIND_SHARED_LIBS "${TPL_FIND_SHARED_LIBS}"
"Find only shared libs for TPL ${TPL_NAME}")
(see set_cache_on_off_empty()
).
You would do that if you wanted to provide documentation for the user in the cache file (and with the various CMake GUIs like ccmake
or cmake-gui
).
Currently we (Trilinos) wish to be able to find all TPLs statically...except for some which we must find shared, because static installations do not exist in the environment we're using. For example, we want to use "all" static TPLs for our CUDA build, but the installation of METIS is only shared. Currently, this is done by setting
TPL_FIND_SHARED_LIBS
toOFF
, and specifyingMETIS_LIBRARIES
to be the explicit full path tolibmetis.so
. This unfortunately bypasses the 'finding' of METIS. It would be nicer if we could pass-DTPL_FIND_SHARED_LIBS=OFF -DMETIS_FIND_SHARED_LIBS=ON
and have TriBITS continue to do the same thing for each TPL, by finding METIS as normal (eliminates some brittleness in our configuration management).I looked at doing this, and the code change seems fairly trivial unless I'm missing something. I added a test as well.