-
Notifications
You must be signed in to change notification settings - Fork 232
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
Libdap #3333
Libdap #3333
Conversation
… up the libdap libraries/directories if the user sets LIBDAP_ON=ON.
…ml2 fix Timo suggested
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.
I have a few comments after reading through it. Let us know when this is ready for review/testing.
cmake/modules/FindLIBDAP.cmake
Outdated
) | ||
|
||
FIND_LIBRARY(LIBDAP_LIBRARY | ||
NAMES libdap.dylib |
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 seems to be OSX specific. Can you try if this works when using "NAMES libdap" ?
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.
I couldn't get it to work with just "NAMES libdap", but I can list different options so that it searches for our library with different extensions in the order given: NAMES libdap.so libdap.dylib libdap.la
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.
at least .so and .dylib. I am not sure about ".la".
Added: A module in the cmake directory that looks for, and adds the path of, the libdap libraries. | ||
A lookup was also added in CMakeLists for the libdap, libxml, and curl libraries. | ||
<br> | ||
(Kodi Neumiller, 2020/01/16) |
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.
please add a newline at the end.
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.
Do you mean another newline after my name/date?
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.
correct.
CMakeLists.txt
Outdated
# Added: 10/16/18 | ||
IF(LIBDAP) | ||
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}/cmake/modules") | ||
MESSAGE(STATUS "cmake module path = ${CMAKE_MODULE_PATH}") |
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.
remove this
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 I remove this then CMakeLists appears to not be able to run FindLIBDAP.cmake which is in the cmake/modules/ directory. If I remove the LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}/cmake/modules")
then I have to put the FindLIBDAP.cmake file in the aspect directory, unless there is another way to do this.
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.
I can remove the MESSAGE(STATUS "cmake module path = ${CMAKE_MODULE_PATH}")
if you want though, that was just there so the user knew where CMakeLists.txt was calling its other, external 'Find.cmake' files.
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, sorry, I meant the MESSAGE. I don't think it is particularly useful for the user to know.
CMakeLists.txt
Outdated
FIND_PACKAGE(LIBDAP) | ||
IF(${LIBDAP_FOUND}) | ||
FIND_PACKAGE(LibXml2) | ||
FIND_PACKAGE(CURL) |
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 here. Also, what if one of these checks fails?
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.
Right now if the FIND_PACKAGE fails it just returns: "Could not find a package configuration file provided by CURL/LibXml2".
However it looks like it still finds the libdap libraries if they are installed. Without CURL or libxml2 then the code we added to utilities.cc in url_reader won't be able to read data from a url. I could add a warning or an error if one or both of the CURL/libxml2 packages aren't found.
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.
Then it is probably best to find the packages first and only enable it if you find all three. I am still confused though, shouldn't libdab provide you with all information including what libraries we need to link to? This can be handled inside FindLIBDAP if needed.
I just checked my installation of libdab and found ./bin/dap-config --libs
, which returns the complete link line. That would be one way to find the necessary information.
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 exactly the same as curl doesn't have other libs as dependencies, but this might help: https://github.com/Kitware/CMake/blob/master/Modules/FindCURL.cmake#L136
Let me know if you need more help.
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.
I've updated the code to not build if one or both CURL and libxml2 are not found. If you think there's more to be done please let me know. In your latest comment are you saying I could add the dependent library lookups to FindLIBDAP?
Thanks for all of the help by the way
CMakeLists.txt
Outdated
MESSAGE(STATUS "cmake module path = ${CMAKE_MODULE_PATH}") | ||
FIND_PACKAGE(LIBDAP) | ||
IF(${LIBDAP_FOUND}) | ||
FIND_PACKAGE(LibXml2) |
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.
What if this check find a different libxml than libdap was configured with?
CMakeLists.txt
Outdated
# Find the libdap package so that Aspect can connect to the OPeNDAP servers | ||
# Author: Kodi Neumiller | ||
# Added: 10/16/18 | ||
IF(LIBDAP) |
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.
what does this IF do?
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.
We put this in there in case the user wants to compile aspect without libdap. We added an option for when cmake is run: 'LIBDAP=ON'. The default is set to OFF, but if the user wishes to search for and use the libdap package they will need to run cmake with the option '-DLIBDAP=ON'.
I can take this out which would just display "libdap package not found" if the user ran cmake without libdap packages installed. It's up to you, we had it in there so that the user could decide if they wanted aspect to search for libdap libraries and to avoid more clutter when cmake is run and the user doesn't care about the libdap libraries.
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.
oh, okay. Can you use something like ASPECT_WITH_LIBDAP and create a cache variable like https://github.com/geodynamics/aspect/blob/master/CMakeLists.txt#L116-L118 ? This way it can be toggled inside "ccmake".
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 looks like a much better idea, I'll make those changes.
CMakeLists.txt
Outdated
FIND_PACKAGE(CURL) | ||
INCLUDE_DIRECTORIES(${LIBDAP_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}/libxml2 ${CURL_INCLUDE_DIR}) | ||
TARGET_LINK_LIBRARIES(${TARGET} ${LIBDAP_LIBRARIES} ${LIBXML2_LIBRARIES} ${CURL_LIBRARIES}) | ||
ADD_DEFINITIONS(-DHAVE_LIBDAP=TRUE) |
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.
can you use something like https://github.com/geodynamics/aspect/blob/master/CMakeLists.txt#L441 instead please?
…g for libraries in this way will make it so that the correct library is found based on the system the user is using.
…CT_WITH_LIBDAP'. Changed the way the 'HAVE_LIBDAP' definition is added to fit how others are added. Added a newline after my name in the doc/module/ file
This is a good start, but I think that you need to discover from libdap where its dependencies are. For example, my system has different versions of libcurl installed and the one linked to by libdap is not the one in /usr/lib/. |
…FindLIBDAP cmake file rather than in the CMakeLists
I don't think we support that in libdap itself. Unless I'm misunderstanding and there is a way to do it in CMakeLists or FindLibdap.
there is dap-config which is a script that takes a number of switches like --libs and --cflags that tell poeple how to link and compile code that will use libdap. |
To get correct results, we probably need to parse exactly that information. Let me explain with my machine as an example:
but
which means dap is compiled with a different version of libcurl than the one you detect. It is even worse for libxml2: the script can not find it, as there is no system installation (I have all 3 installed using spack). Let me know if you want me to help with making this work. |
I would greatly appreciate the help, what did you have in mind? |
I have a draft in this branch: https://github.com/tjhei/aspect/tree/libdap_dep |
Looks good! I will push the changes up. Do we want to keep all of the output of libs and flags? It looks like a lot of information being displayed at once. If so then I think it should be ready, correct? |
…for the curl and libxml2 libraries.
It helped me with debugging the output, but I don't feel strongly about it. You can remove the output inside the loop if you prefer. |
.gitignore
Outdated
@@ -61,3 +61,4 @@ | |||
|
|||
.idea/ | |||
cmake-build-debug/ | |||
/.autotools |
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.
is this still needed?
A lookup was also added in CMakeLists for the libdap, libxml, and curl libraries. | ||
<br> | ||
(Kodi Neumiller, 2020/01/16) | ||
<br> |
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.
can you remove this
line please?
with the changes above, I think we are finally good to go. |
- fix list of libraries linked to - add ASPECT header - fix changelog and add myself - fix include path detection
- fix list of libraries linked to - add ASPECT header - fix changelog and add myself - fix include path detection - cleaner output
followup to #3333: libdap configuration
- fix list of libraries linked to - add ASPECT header - fix changelog and add myself - fix include path detection - cleaner output
Part of the pull requests for OPeNDAP:
These new additions will search for the libdap libraries through cmake. Libdap is necessary for reading data from a url, which is what the "url reader" pull request adds.
Before your first pull request:
For all pull requests:
For new features/models or changes of existing features: