Skip to content
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

Merged
merged 10 commits into from
Jan 28, 2020
Merged

Libdap #3333

merged 10 commits into from
Jan 28, 2020

Conversation

kneumiller
Copy link
Contributor

@kneumiller kneumiller commented Jan 16, 2020

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:

  • [ X ] I have tested my new feature locally to ensure it is correct.
  • [ X ] I have created a testcase for the new feature/benchmark in the tests/ directory.
  • [ X ] I have added a changelog entry in the doc/modules/changes directory that will inform other users of my change.

Copy link
Member

@tjhei tjhei left a 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.

)

FIND_LIBRARY(LIBDAP_LIBRARY
NAMES libdap.dylib
Copy link
Member

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" ?

Copy link
Contributor Author

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

Copy link
Member

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)
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@tjhei tjhei Jan 18, 2020

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.

Copy link
Member

@tjhei tjhei Jan 18, 2020

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.

Copy link
Contributor Author

@kneumiller kneumiller Jan 22, 2020

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)
Copy link
Member

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)
Copy link
Member

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?

Copy link
Contributor Author

@kneumiller kneumiller Jan 17, 2020

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.

Copy link
Member

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".

Copy link
Contributor Author

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…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
@tjhei
Copy link
Member

tjhei commented Jan 22, 2020

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?

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/.
Is there documentation available how libdap likes people to link to it?

…FindLIBDAP cmake file rather than in the CMakeLists
@kneumiller
Copy link
Contributor Author

but I think that you need to discover from libdap where its dependencies are.

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.

Is there documentation available how libdap likes people to link to it?

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.

@tjhei
Copy link
Member

tjhei commented Jan 23, 2020

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:

$ cmake -D ASPECT_WITH_LIBDAP=ON -D LIBDAP_DIR=/ssd/spack/opt/spack/linux-ubuntu16.04-broadwell/gcc-5.4.0/libdap4-3.20.4-2dzjmq6onqavz3cc5gbdeh3jgppkv7lu  ..
[...]
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.47.0")  
[...]

but

$ ldd $DAP_PATH/libdapclient.so | grep curl
        libcurl.so.4 => /ssd/spack/opt/spack/linux-ubuntu16.04-broadwell/gcc-5.4.0/curl-7.63.0-776fukubmmxkthgfnaohu2ntw36ukseq/lib/libcurl.so.4 (0x00007f0a38a94000

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.

@kneumiller
Copy link
Contributor Author

kneumiller commented Jan 23, 2020

I would greatly appreciate the help, what did you have in mind?

@tjhei
Copy link
Member

tjhei commented Jan 27, 2020

I have a draft in this branch: https://github.com/tjhei/aspect/tree/libdap_dep
Can you please take a look and test if this works for you on OSX?

@kneumiller
Copy link
Contributor Author

kneumiller commented Jan 27, 2020

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?

@tjhei
Copy link
Member

tjhei commented Jan 27, 2020

Do we want to keep all of the output of libs and flags? It looks like a lot of information being displayed at once.

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
Copy link
Member

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>
Copy link
Member

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?

@tjhei
Copy link
Member

tjhei commented Jan 27, 2020

If so then I think it should be ready, correct?

with the changes above, I think we are finally good to go.

@tjhei tjhei merged commit 5bf8002 into geodynamics:master Jan 28, 2020
tjhei added a commit to tjhei/aspect that referenced this pull request Jan 28, 2020
- fix list of libraries linked to
- add ASPECT header
- fix changelog and add myself
- fix include path detection
tjhei added a commit to tjhei/aspect that referenced this pull request Jan 28, 2020
- fix list of libraries linked to
- add ASPECT header
- fix changelog and add myself
- fix include path detection
- cleaner output
gassmoeller added a commit that referenced this pull request Jan 29, 2020
followup to #3333: libdap configuration
@gassmoeller gassmoeller mentioned this pull request Feb 10, 2020
1 task
naliboff pushed a commit to naliboff/aspect that referenced this pull request Feb 11, 2020
- fix list of libraries linked to
- add ASPECT header
- fix changelog and add myself
- fix include path detection
- cleaner output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants