Skip to content

CMake: Fix libdir in pkg-config file#214

Closed
akien-mga wants to merge 1 commit intoKhronosGroup:masterfrom
akien-mga:pkgconfig-libdir
Closed

CMake: Fix libdir in pkg-config file#214
akien-mga wants to merge 1 commit intoKhronosGroup:masterfrom
akien-mga:pkgconfig-libdir

Conversation

@akien-mga
Copy link
Copy Markdown
Contributor

The previous code assumed that CMAKE_INSTALL_LIBDIR is a relative
path, which it is not guaranteed to be, so we could end up with things
like this:

libdir=${exec_prefix}//usr/lib64

CMAKE_INSTALL_FULL_LIBDIR is guaranteed to be an absolute path.
We do lose the ${exec_prefix} variable, the full path is now
hardcoded.

While at it, I made the include path configurable similarly, and fixed
Libs.private which would get duplicate entries:

Libs.private:  -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc

list(APPEND PRIVATE_LIBS_LIST "-l${LIB}")
endforeach()
list(REMOVE_DUPLICATES PRIVATE_LIBS_LIST)
list(JOIN PRIVATE_LIBS_LIST " " PRIVATE_LIBS)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not a CMake expert, so if there's a cleverer way to prevent adding duplicates to a string without having to use a list and a REMOVE_DUPLICATES filter, that could be used it.

Or maybe iterating over both CMAKE_CXX_IMPLICIT_LINK_LIBRARIES and PLATFORM_LIBS is overkill, I did not investigate further.

Copy link
Copy Markdown
Contributor

@lenny-lunarg lenny-lunarg left a comment

Choose a reason for hiding this comment

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

This looks good to me. Stripping duplicates seems like a good idea, even if it wasn't already causing trouble.

@lenny-lunarg
Copy link
Copy Markdown
Contributor

lenny-lunarg commented Aug 8, 2019

Let me just add one more comment, can I request that you rebase this so we can hopefully get a CI pass on Linux? Windows CI is still failing, but Linux CI is working on the last code in master. I just want to double check that this can pass a build on the CI machine (because these failures are caused because master was failing when you opened the PR).

@lenny-lunarg lenny-lunarg self-assigned this Aug 8, 2019
The previous code assumed that `CMAKE_INSTALL_LIBDIR` is a relative
path, which it is not guaranteed to be, so we could end up with things
like this:
```
libdir=${exec_prefix}//usr/lib64
```

`CMAKE_INSTALL_FULL_LIBDIR` is guaranteed to be an absolute path.
We do lose the `${exec_prefix}` variable, the full path is now
hardcoded.

While at it, I made the include path configurable similarly, and fixed
`Libs.private` which would get duplicate entries:
```
Libs.private:  -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
```
@lenny-lunarg
Copy link
Copy Markdown
Contributor

I don't know why I didn't think to just rebase this myself when I requested the rebase for CI. Ijust did that now. Assuming it passes I'll merge.

@akien-mga
Copy link
Copy Markdown
Contributor Author

Sorry I had forgotten about this, I would have rebased otherwise :)

@lenny-lunarg
Copy link
Copy Markdown
Contributor

No worries. I would have done it sooner, too if I had been thinking about this.

@lenny-lunarg
Copy link
Copy Markdown
Contributor

I'm sorry I didn't reply to this at the time, but the reason I didn't merge this earlier was that the change was failing CI. The reason for this list that the list(JOIN ...) command was added in CMake 3.12. Since we support back to CMake 3.10, we can't use this (and our CI uses CMake 3.10). I'm going to close this issue since it's so old, but if you modify this so that it passes with CMake 3.10, I'd be happy to take the same change in a new PR.

@akien-mga
Copy link
Copy Markdown
Contributor Author

I opened #491 to fix the libdir in the pkg-config file.

I left out the Libs.private issue as I don't intend to dig further into CMake docs/stackoverflow to figure out how to properly filter the duplicates out. I opened #490 to keep track of that issue.

lenny-lunarg pushed a commit that referenced this pull request Oct 20, 2020
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.

2 participants