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
9 changes: 5 additions & 4 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}/lib" "./" "../lib" )
list( APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" "./" "../lib" )
Copy link

Choose a reason for hiding this comment

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

Great, but CMAKE_INSTALL_LIBDIR can be an absolute path on some platforms like NixOS... Perhaps just use ${CMAKE_INSTALL_FULL_LIBDIR} instead of ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}?

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 remember that problem on openSUSE, years ago. I thought it had been solved. Not everywhere, it comes out.

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_library(kvazaar SHARED ${LIB_SOURCES})
else()
Expand Down Expand Up @@ -231,6 +231,7 @@ else()
set(EXTRA_LIBS ${EXTRA_LIBS} ${CMAKE_BINARY_DIR}/lib/libcryptopp.a)
endif ()

target_link_libraries(kvazaar PUBLIC ${EXTRA_LIBS})
target_link_libraries(kvazaar-bin PUBLIC ${EXTRA_LIBS} )
endif()

Expand Down Expand Up @@ -281,16 +282,16 @@ source_group( "" FILES ${SOURCE_GROUP_TOPLEVEL})

# ToDo: make configurable

install(FILES ${PROJECT_SOURCE_DIR}/src/kvazaar.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pkgconfig)
install(FILES ${PROJECT_SOURCE_DIR}/src/kvazaar.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_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}/lib)
install(TARGETS kvazaar DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_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)
endif()
endif()
install(FILES ${PROJECT_SOURCE_DIR}/src/kvazaar.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
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_INCLUDEDIR

install(FILES ${PROJECT_SOURCE_DIR}/doc/kvazaar.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man)
install(FILES ${PROJECT_SOURCE_DIR}/doc/kvazaar.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
Copy link

Choose a reason for hiding this comment

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

Suggested change
install(FILES ${PROJECT_SOURCE_DIR}/doc/kvazaar.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
install(FILES ${PROJECT_SOURCE_DIR}/doc/kvazaar.1 DESTINATION ${CMAKE_INSTALL_MANDIR})


IF(UNIX)
# DIST
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}/lib
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
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