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

Minor cmake fixes #385

Merged
merged 13 commits into from
Jan 25, 2024
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ if (USE_CRYPTO)
endif ()

if(KVZ_BUILD_SHARED_LIBS)
list( APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" "./" "../lib" )
list( APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}" "./" "../lib" )
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_library(kvazaar SHARED ${LIB_SOURCES})
else()
Expand Down Expand Up @@ -282,9 +282,9 @@ source_group( "" FILES ${SOURCE_GROUP_TOPLEVEL})

# ToDo: make configurable

install(FILES ${PROJECT_SOURCE_DIR}/src/kvazaar.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES ${PROJECT_SOURCE_DIR}/src/kvazaar.pc DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig)
install(TARGETS kvazaar-bin DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
Copy link

Choose a reason for hiding this comment

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

Use CMAKE_INSTALL_BINDIR

install(TARGETS kvazaar DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
install(TARGETS kvazaar DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
if(KVZ_BUILD_SHARED_LIBS) # Just add the lib to the bin directory for now
if(MSVC)
Copy link

Choose a reason for hiding this comment

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

Why is this MSVC only? One can build shared libs on MINGW as well, so this should potentially be WIN32?

Also, maybe there is no need to special case this anyway? If you do

install(TARGETS kvazaar
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

this will work out for shared and static libraries for all platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, maybe there is no need to special case this anyway? If you do

RUNTIME is not being installed that way. Do I need to define it somewhere first?

install(TARGETS kvazaar DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
Expand Down
2 changes: 1 addition & 1 deletion src/kvazaarCMake.pc.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
Copy link

@kmilos kmilos Jan 19, 2024

Choose a reason for hiding this comment

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

Ah, here you actually don't want an absolute path always in order to enable a relocatable package...

Instead, one has to check if CMAKE_INSTALL_LIBDIR was absolute and act accordingly. See for example lensfun/lensfun@542b989

Copy link

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Considering that the kvazaarCMake.pc.in is based on the one that is used by uvg266, we are going to be maintaining two templates regardless, unless automake can also use the CMake version. Additionally, the template has been updated literally once, nine years ago, it is not really an issue to have two templates, even if it is not an optimal solution.

If you are adamant on us not having two templates on this repository I will accept a PR, but please submit a similar PR for uvg266 also.

Copy link

Choose a reason for hiding this comment

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

If you are adamant on us not having two templates on this repository

I'm not. Just sharing what has become sort of "best practice" I've experienced across several imaging related libraries, especially ones that are (or were) supporting both autotools and cmake, like libtiff and libheif for example. I see no reason not to reuse it...

It's of course your prerogative how you want to maintain your repositories, and apologies to have annoyed you with my comments.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I understand why having two templates cannot be considered a best practice. However, considering the low maintenance needed for these files, and the fact that we aim not to support both autotools and cmake, but replace autotools with cmake, I'm fine with not following best practices here.

For your other suggestions I'm grateful, as I have very little experience with CMake.

apologies to have annoyed you with my comments.

I interpreted your usage of ellipsis as a criticism towards the fact that I was not aware of the best practices, which I assume was not the intention? I would like to apologize for my maybe overly harsh comments towards you.

Otherwise, in your opinion, does the current state of the PR adhere to the best practices?

Copy link

Choose a reason for hiding this comment

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

No problem. There's just two more minor details, I'll leave comments on the latest commits.

incdir=${prefix}/include
Copy link

Choose a reason for hiding this comment

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

Add @KVAZAAR_PC_INCDIR@


Name: libkvazaar
Expand Down