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

Check GMT_DOC_DIR if SHAREDIR fails #1964

Merged
merged 6 commits into from
Nov 3, 2019
Merged

Check GMT_DOC_DIR if SHAREDIR fails #1964

merged 6 commits into from
Nov 3, 2019

Conversation

PaulWessel
Copy link
Member

While we configured GMT_DOC_DIR it was never used. Now it is, and hopefully this PR addresses #1960.

We configured but never used GMT_DOC_DIR.  This PR does and should address #1960.
@seisman
Copy link
Member

seisman commented Nov 2, 2019

Doesn't work. See the line 2 below.

docs [DEBUG]: Try URL path: file:https:////usr/local/Cellar/gmt/6.0.1/share/gmt/doc/html/coast.html
docs [DEBUG]: No access, Now try URL path: file:https:////usr/local/Cellar/gmt/6.0.1//usr/local/Cellar/gmt/6.0.1/share/doc/gmt/html/coast.html
docs [DEBUG]: No local access,use server URL path: https://docs.generic-mapping-tools.org/6.0/coast.html
docs [DEBUG]: Opening https://docs.generic-mapping-tools.org/6.0/coast.html via open
gmt [DEBUG]: Entering GMT_Destroy_Session

@PaulWessel
Copy link
Member Author

So line two:

file:https:////usr/local/Cellar/gmt/6.0.1//usr/local/Cellar/gmt/6.0.1/share/doc/gmt/html/coast.html

is the result of

snprintf (URL, PATH_MAX, "file:https:///%s/html/%s", GMT_DOC_DIR, module);

Thus GMT_DOC_DIR when brew configures things is

/usr/local/Cellar/gmt/6.0.1//usr/local/Cellar/gmt/6.0.1/share/doc/gmt

which is not too surprising given the config.h.in statement

/* path to documentation */
#define GMT_DOC_DIR "@CMAKE_INSTALL_PREFIX@/@GMT_DOCDIR@"

It sounds like this one simply must be

#define GMT_DOC_DIR "@GMT_DOCDIR@"

@seisman
Copy link
Member

seisman commented Nov 2, 2019

We probably need to check if GMT_DOCDIR is given as an absolute path (like in homebrew) or a relative path (like the GMT default path).

@PaulWessel
Copy link
Member Author

Yes, so when I just build in a local build dir parallel to src I have it install in build/gmt6/{bin, lib,..} so then GMT_DOC_DIR is "share/doc" and the @CMAKE_INSTALL_PREFIX@/@GMT_DOCDIR@ is what I need.

As for config.h it has

#define GMT_SHARE_DIR "/Users/pwessel/UH/RESEARCH/CVSPROJECTS/GMTdev/gmt-dev/dbuild/gmt6/share"
#define GMT_DOC_DIR "share/doc"

so maybe try both GMT_DOC_DIR and GMT_SHARE_DIR?

src/config.h.in Outdated
@@ -51,7 +51,7 @@
#define GMT_BINARY_DIR_SRC_DEBUG "@GMT_BINARY_DIR@/src"

/* path to documentation */
#define GMT_DOC_DIR "@CMAKE_INSTALL_PREFIX@/@GMT_DOCDIR@"
#define GMT_DOC_DIR "@GMT_DOCDIR@"
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little confused here. Does it mean @GMT_DOCDIR@ must be an absolute path?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, the way it was (line two above) you got two hard paths added together.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but if someone gives GMT_DOCDIR a relative path, then GMT_DOC_DIR is also a relative path.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I can put it back to what it was but then we get line 2 for brew.
We could add a GMT_INTALLDIR="@CMAKE_INSTALL_PREFIX@" to config.h to have a separate parameter for that, but I guess I don't understand exactly how the package managers are specifying things like doc dir, i.e., relative (to what?) or absolute.

Copy link
Member

Choose a reason for hiding this comment

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

Homebrew uses -DGMT_DOCDIR=#{share}/doc/gmt. I don't know exactly what #{share} means in homebrew, but probably homebrew should use -DGMT_DOCDIR=share/doc/gmt, which is relative to ${CMAKE_INSTALL_PREFIX}.

@seisman
Copy link
Member

seisman commented Nov 3, 2019

In cmake/ConfigUserTemplate.cmake, we claim that all the paths (GMT_BINDIR, GMT_LIBDIR, GMT_INCLUDEDIR, GMT_DATADIR, GMT_DOCDIR, GMT_MANDIR) can be either absolute or relative paths.

# ============================================================================
# Advanced configuration begins here. Usually it is not necessary to edit any
# settings below. You should know what you are doing if you do though. Note:
# installation paths are relative to ${CMAKE_INSTALL_PREFIX} unless absolute
# path is given.

However, it seems we assume that these paths must be relative paths, e.g.

gmt/src/config.h.in

Lines 36 to 42 in 816825d

/* path to executables/libs */
#define GMT_BINDIR_RELATIVE "@GMT_BINDIR@"
#define GMT_LIBDIR_RELATIVE "@GMT_LIBDIR@"
/* path to shared files */
#define GMT_SHARE_DIR "@CMAKE_INSTALL_PREFIX@/@GMT_DATADIR@"
#define GMT_SHARE_DIR_RELATIVE "@GMT_DATADIR@"

@PaulWessel
Copy link
Member Author

Would the brew guy know?

@seisman
Copy link
Member

seisman commented Nov 3, 2019

https://docs.brew.sh/Formula-Cookbook#variables-for-directory-locations

It seems #{share} is /usr/local/Cellar/gmt/6.0.0/share. Homebrew definitely should use a relative path, and we should claim that all the paths (e.g. GMT_DOCDIR) must be relative paths.

@PaulWessel
Copy link
Member Author

OK with me. So leave my changes to config.h.in then (removing the INSTALL PREFIX)?

@seisman
Copy link
Member

seisman commented Nov 3, 2019

The change to config.h.in should be reverted.

@PaulWessel
Copy link
Member Author

You mean it should be what it was, i.e.,

#define GMT_DOC_DIR "@CMAKE_INSTALL_PREFIX@/@GMT_DOCDIR@"

@seisman
Copy link
Member

seisman commented Nov 3, 2019

Yes, all the path settings in cmake/ConfigUserTemplate.cmake should be relative to CMAKE_INSTALL_PREFIX.

@seisman
Copy link
Member

seisman commented Nov 3, 2019

@claudiodsf I made some changes to the homebrew recipe (attached here gmt.rb.zip).

  1. Apply two patches in commit b65dc6e and the current PR
  2. Change GMT_DOCDIR and GMT_MANDIR to relative paths.

Then I reinstalled GMT with brew install --build-from-source -vv ./gmt.rb. It now works for me. It would be better if you can also give it a try.

@claudiodsf
Copy link
Contributor

I confirm that it now works and that the new formula has the same installation tree than the previous one.
I'll add a note to the formula for future maintainers on that GMT_DOCDIR and GMT_MANDIR must be relative paths.
I think we can keep this for 6.0.1, which should be not so far in the future, right?

@seisman seisman merged commit daf6465 into 6.0 Nov 3, 2019
@seisman seisman deleted the usedocsdir branch November 3, 2019 13:04
@seisman
Copy link
Member

seisman commented Nov 3, 2019

@claudiodsf Not sure when we'll release 6.0.1. Since "gmt docs" is the main new feature in GMT6, and many macOS users use homebrew, I suggest applying the two patches I mentioned before and bumping the homebrew revision number (i.e. 6.0.0-1).

@claudiodsf
Copy link
Contributor

Ok, I submitted the PR with version bump to homebrew-core: Homebrew/homebrew-core#46231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants