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
29 changes: 18 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ set(KVZ_COMPILER_STRING "${KVZ_COMPILER_VERSION}")

add_definitions(-DCMAKE_BUILD)

# Set correct pkgconfig libdir variable
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
set(KVAZAAR_PC_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
set(KVAZAAR_PC_INCDIR "${CMAKE_INSTALL_INCLUDEDIR}")
Copy link

Choose a reason for hiding this comment

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

Suggested change
set(KVAZAAR_PC_INCDIR "${CMAKE_INSTALL_INCLUDEDIR}")

else()
set(KVAZAAR_PC_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
set(KVAZAAR_PC_INCDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
Copy link

Choose a reason for hiding this comment

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

Suggested change
set(KVAZAAR_PC_INCDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(KVAZAAR_PC_INCDIR "${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(KVAZAAR_PC_INCDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Silly me. Although it would have worked most of the time:)

Copy link

Choose a reason for hiding this comment

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

Probably, but there is no guarantee I guess!

endif()

# Apply dynamic info to the config files
configure_file("${PROJECT_SOURCE_DIR}/src/kvazaarCMake.pc.in" "${PROJECT_SOURCE_DIR}/src/kvazaar.pc" @ONLY)
configure_file("${PROJECT_SOURCE_DIR}/src/version.h.in" "${PROJECT_SOURCE_DIR}/src/version.h" @ONLY)
Expand Down Expand Up @@ -173,7 +182,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_LIBDIR}" "./" "../lib" )
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_library(kvazaar SHARED ${LIB_SOURCES})
else()
Expand Down Expand Up @@ -231,6 +240,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 +291,13 @@ source_group( "" FILES ${SOURCE_GROUP_TOPLEVEL})

# ToDo: make configurable

install(FILES ${PROJECT_SOURCE_DIR}/src/kvazaar.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pkgconfig)
install(TARGETS kvazaar-bin DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS kvazaar DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
if(KVZ_BUILD_SHARED_LIBS) # Just add the lib to the bin directory for now
if(MSVC)
install(TARGETS kvazaar DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif()
endif()
install(FILES ${PROJECT_SOURCE_DIR}/src/kvazaar.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(FILES ${PROJECT_SOURCE_DIR}/doc/kvazaar.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man)
install(FILES ${PROJECT_SOURCE_DIR}/src/kvazaar.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(TARGETS kvazaar-bin DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS kvazaar
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${PROJECT_SOURCE_DIR}/src/kvazaar.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${PROJECT_SOURCE_DIR}/doc/kvazaar.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)

IF(UNIX)
# DIST
Expand Down
4 changes: 2 additions & 2 deletions src/kvazaarCMake.pc.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/lib
incdir=${prefix}/include
libdir=@KVAZAAR_PC_LIBDIR@
incdir=@KVAZAAR_PC_INCDIR@

Name: libkvazaar
Description: @CMAKE_PROJECT_DESCRIPTION@
Expand Down