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

Various CMake fixes #5

Merged
merged 5 commits into from
Dec 8, 2017
Merged

Various CMake fixes #5

merged 5 commits into from
Dec 8, 2017

Conversation

uartie
Copy link
Contributor

@uartie uartie commented Dec 1, 2017

Fixes for #1, #2 and #3

if(NOT "${LIBVA_INSTALL_PATH}" STREQUAL "")
include_directories(BEFORE ${LIBVA_INSTALL_PATH})
else()
include(FindPkgConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the prerequisite to make this FindPkgConfig work properly?
I just build libva below way in Ubuntu 16.04 -
$ ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
$ make
$ sudo make install
Then below LIBVA_INCLUDE_DIRS and LIBVA_X11_INCLUDE_DIRS are empty

Another strange thing is if I change the judgement as libva>=2.0.0 (even 3.0.0), LIBVA_FOUND will still be true. Same for LIBVA_X11.

I checked by pkg-config -
$ pkg-config --modversion libva
1.0.0
And /usr/lib/x86_64-linux-gnu/pkgconfig/libva.pc also told me -

Name: libva
Description: Userspace Video Acceleration (VA) core interface
Version: 1.0.0
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

What I missed? Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what's the prerequisite to make this FindPkgConfig work properly?

The prerequisite is that the libva.pc file must be in the pkg-config search path. In your case, it is (i.e. /usr/lib/x86_64-linux-gnu/pkgconfig). If the .pc file is not in the default search path, then user can set PKG_CONFIG_PATH environment variable to give pkg-config additional paths to search.

Then below LIBVA_INCLUDE_DIRS and LIBVA_X11_INCLUDE_DIRS are empty

LIBVA_INCLUDE_DIRS and LIBVA_X11_INCLUDE_DIRS will be empty if its directories are already included in the default cmake include paths.

Another strange thing is if I change the judgement as libva>=2.0.0 (even 3.0.0), LIBVA_FOUND will still be true. Same for LIBVA_X11.

I was able to reproduce your findings for libva>=2.0.0 but not for libva-x11>=2.0.0. Turns out that the previous call to pkg_check_modules(LIBVA REQUIRED libva>=1.0.0) in media_driver/cmake/linux/media_include_paths_linux.cmake overshadows the second call... I will fix this.

CMakeLists.txt Outdated

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh)

install (FILES ${CMAKE_CURRENT_BINARY_DIR}/media_driver/iHD_drv_video.so DESTINATION ${CMAKE_INSTALL_LIBDIR}/dri/)
Copy link
Contributor

Choose a reason for hiding this comment

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

on Ubuntu 64-bit, this CMAKE_INSTALL_LIBDIR will be 'lib', and the final install path will be '/usr/lib/dri/', which is not we wanted. how to remain original path (/usr/lib/x86_64-linux-gnu/dri/)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you define -DCMAKE_INSTALL_PREFIX=/usr during cmake, then CMAKE_INSTALL_LIBDIR will be set to /usr/lib/x86_64-linux-gnu on Ubuntu.

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, user can override with -DCMAKE_INSTALL_LIBDIR=<somedir>

CMakeLists.txt Outdated
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh)

install (FILES ${CMAKE_CURRENT_BINARY_DIR}/media_driver/iHD_drv_video.so DESTINATION ${CMAKE_INSTALL_LIBDIR}/dri/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/profile.d/)
Copy link
Contributor

Choose a reason for hiding this comment

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

on Ubuntu, this CMAKE_INSTALL_SYSCONFDIR is 'etc', and the final package will put intel-media.sh under /usr/etc/profile.d/ , which is not usable to set the LIBVA search path correctly. Why the prefix '/usr' is added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you define -DCMAKE_INSTALL_PREFIX=/usr during cmake, then CMAKE_INSTALL_SYSCONFDIR will be set to /etc on Ubuntu. (See https://cmake.org/cmake/help/v3.5/module/GNUInstallDirs.html#special-cases for more details)

CMakeLists.txt Outdated

if (IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../libva-install/usr/bin)
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../libva-install/usr/bin DESTINATION /usr/
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../libva-install/usr/bin DESTINATION ${CMAKE_INSTALL_PREFIX}
Copy link
Contributor

Choose a reason for hiding this comment

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

This CMAKE_INSTALL_PREFIX is /usr/local on Ubuntu, How to make it just '/usr'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

use -DCMAKE_INSTALL_PREFIX=/usr when configuring with cmake command

@@ -1,3 +1,3 @@
# add libva driver path/name exporting for intel media solution
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri/
export LIBVA_DRIVERS_PATH=${CMAKE_INSTALL_LIBDIR}/dri/
Copy link
Contributor

@oliver-sang oliver-sang Dec 4, 2017

Choose a reason for hiding this comment

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

again, since the CMAKE_INSTALL_LIBDIR will be 'lib', the intel-media.sh has the incorrect contents -

export LIBVA_DRIVERS_PATH=lib/dri/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, you are right... this should be CMAKE_INSTALL_FULL_LIBDIR. I will fix it.

@@ -27,6 +27,9 @@ else()
pkg_check_modules(LIBVA REQUIRED libva>=1.0.0)
if(LIBVA_FOUND)
include_directories(BEFORE ${LIBVA_INCLUDE_DIRS})
if("${LIBVA_DRIVERS_PATH}" STREQUAL "")
pkg_get_variable(LIBVA_DRIVERS_PATH libva driverdir)
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw this pkg_get_variable() get the correct LIBVA_DRIVERS_PATH as "/usr/lib/x86_64-linux-gnu/dri" but it cannot pass along to parent cmake
(root CMakefiles.txt uses add_subdirectory(media_driver) so the variables have another scope, though here LIBVA_DRIVERS_PATH get correct value, the counterpart one in up-level is still empty)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I will fix this.

@uartie uartie force-pushed the cmake-fixes branch 2 times, most recently from d0b9c0b to 79abc8c Compare December 4, 2017 19:03
@uartie
Copy link
Contributor Author

uartie commented Dec 4, 2017

@oliver-sang, the patches have been updated. Let me know if you find any more issues. Thanks.

@uartie
Copy link
Contributor Author

uartie commented Dec 4, 2017

@oliver-sang FYI I also added 2 additional patches.

@oliver-sang
Copy link
Contributor

@uartie thanks. I ran out of time today and will try your new patches tomorrow.

@uartie
Copy link
Contributor Author

uartie commented Dec 6, 2017

@oliver-sang looking forward to your final review

@oliver-sang
Copy link
Contributor

@uartie sorry, I added comments about configure_file() command. I suggest to set the target (intel-media.sh) as in CMAKE_CURRENT_BINARY_DIR (you just use CMAKE_CURRENT_SOURCE_DIR). Do I add that comment in improper way then it was missed? If so, sorry, and could you check and update the patch a little?

I like your patches that make us extend to none-ubuntu system. Thanks a lot!

@uartie
Copy link
Contributor Author

uartie commented Dec 7, 2017

@uartie sorry, I added comments about configure_file() command. I suggest to set the target (intel-media.sh) as in CMAKE_CURRENT_BINARY_DIR (you just use CMAKE_CURRENT_SOURCE_DIR). Do I add that comment in improper way then it was missed? If so, sorry, and could you check and update the patch a little?

Yes, I must have missed that comment. I used CMAKE_CURRENT_SOURCE_DIR since that is what was used originally (before my patch). How does CMAKE_CURRENT_BINARY_DIR make it different?

@uartie
Copy link
Contributor Author

uartie commented Dec 7, 2017

Oh nevermind, I understand what you're saying now... the "destination" path for configure_file should be CMAKE_CURRENT_BINARY_DIR. I will fix that.

If user does not set -DLIBVA_INSTALL_PATH, then attempt
to find it using pkgconfig.

Fixes intel#3

Signed-off-by: U. Artie Eoff <[email protected]>
@oliver-sang
Copy link
Contributor

@uartie yes, that's what I mean :) Thanks

Use GNUInstallDirs to determine where to install
artifacts.

Fixes intel#1

Signed-off-by: U. Artie Eoff <[email protected]>
1. If -DLIBVA_DRIVERS_PATH not defined and
   -DLIBVA_INSTALL_PATH defined, then set LIBVA_DRIVERS_PATH to
   a default value.

2. If -DLIBVA_DRIVERS_PATH not defined and
   -DLIBVA_INSTALL_PATH not defined, then set LIBVA_DRIVERS_PATH to
   libva.pc (pkgconfig) driverdir value if LIBVA_FOUND, otherwise
   set to a default value.

3. If -DLIBVA_DRIVERS_PATH defined, then use it.

Fixes intel#2

Signed-off-by: U. Artie Eoff <[email protected]>
cmake configuration now supports custom install prefix.

Update README and script to define "-DCMAKE_INSTALL_PREFIX=/usr"
for previous equivalent functionality.

Signed-off-by: U. Artie Eoff <[email protected]>
On some setups it does not make sense to require intel-media.sh
to be installed.  For example, most VAAPI power-users don't
want the VAAPI driver predefined since they may be using multiple
drivers for different purposes/setups.

Add -DINSTALL_DRIVER_SYSCONF=[ON|OFF] option so users can
enable/disable it as necessary.  Default value is "ON" to
maintain previous default functionality.

Signed-off-by: U. Artie Eoff <[email protected]>
@uartie
Copy link
Contributor Author

uartie commented Dec 7, 2017

Fixed.

CMakeLists.txt Outdated
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh DESTINATION /etc/profile.d/)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/cmrtlib/linux/igfxcmrt64.so DESTINATION /usr/lib/x86_64-linux-gnu/)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh)
Copy link
Contributor

Choose a reason for hiding this comment

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

could you change the configure target to BINARY_DIR? otherwise, it will leave a change in git repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm... this is an outdated change. latest changes use BINARY instead of SOURCE. Perhaps your comments got cached before I made the change and only got posted after you approved the latest.

Copy link
Contributor

Choose a reason for hiding this comment

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

don't know what happened. but when merging, it should use the latest version. Thanks!

CMakeLists.txt Outdated
if (INSTALL_DRIVER_SYSCONF)
configure_file (
${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh.in
${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest to config to BINARY_DIR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm... this is an outdated change. latest changes use BINARY instead of SOURCE

Copy link
Contributor

Choose a reason for hiding this comment

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

don't know what happened. but when merging, it should use the latest version. Thanks!

@oliver-sang
Copy link
Contributor

@uartie I plan to merge this PR. are you ok that I squash the 5 commits into one then merge? Or do you prefer merge as it is? Thanks

@uartie
Copy link
Contributor Author

uartie commented Dec 8, 2017

@oliver-sang it's really up to you if you want to squash them. However, I recommend merge as-is to retain commit messages and separation of changes.

@uartie
Copy link
Contributor Author

uartie commented Dec 8, 2017

In general, smaller changes per commit are easier to bisect if ever needed.

@uartie
Copy link
Contributor Author

uartie commented Dec 8, 2017

Also, I recommend a "Rebase and Merge" if you plan to use the GitHub UI to avoid an extra "merge commit"

@oliver-sang
Copy link
Contributor

ok. Thanks

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