CMAKE_INSTALL_PREFIX ignored in Coin 4.0.0?

Create issue
Issue #181 resolved
Greg Earle created an issue

A co-worker asked me to install OpenSceneGraph, and said it needed Coin built & installed so he can read (Open)Inventor files.

I want to install the Coin library locally in our Open Source VICAR tree under /usr/local/vicar/external/coin/v4.0.0/x86-linux for OpenScene Graph to link to, so I set $CMAKE_INSTALL_PREFIX to that path and ran cmake ../coin (cmake 3.10.1 on RHEL 7.3).

None of the generated files had the substituted $CMAKE_INSTALL_PREFIX path. When the make finished and I ran make install, it tried to install into /usr/local/include/Inventor, et al. instead of $CMAKE_INSTALL_PREFIX/include/Inventor et al.

Did I do something obviously wrong or am I missing a switch somewhere or does Coin 4.0.0 not process $CMAKE_INSTALL_PREFIX?

Comments (17)

  1. Volker Enderlein

    Coin will respect your CMAKE_INSTALL_PREFIX if you provided one. Can you show us the exact sequence of commands you are using?

    And did you follow the build instructions from BuildWithCMake ? This recipe is known to work.

  2. Greg Earle reporter

    Hi Volker,

    I did not know about the BuildWithCMake Wiki. I just did the following:

    devlinux7{cm}% cd /usr/local/vicar/external/coin/v4.0.0/x86-64-linux
    devlinux7{cm}% setenv CMAKE_INSTALL_PREFIX /usr/local/vicar/external/coin/v4.0.0/x86-64-linux
    devlinux7{cm}% ls -l
    total 0
    devlinux7{cm}% cmake ../coin
    -- The C compiler identification is GNU 4.8.5
    -- The CXX compiler identification is GNU 4.8.5
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    [... all the CMake messages ...]
    -- Build files have been written to: /usr/local/vicar/external/coin/v4.0.0/x86-64-linux
    devlinux7{cm}% make
    Scanning dependencies of target soscxml
    [... all the build messages ...]
    [100%] Linking CXX executable ../bin/CoinTests
    [100%] Built target CoinTests
    devlinux7{cm}% make install
    [  1%] Built target soscxml
    [... all the repeated "Built target" messages ...]
    [ 86%] Built target Coin
    [100%] Built target CoinTests
    Install the project...
    -- Install configuration: "Release"
    -- Installing: /usr/local/include/Inventor
    CMake Error at src/cmake_install.cmake:41 (file):
      file INSTALL cannot make directory "/usr/local/include/Inventor":
      Permission denied
    Call Stack (most recent call first):
      cmake_install.cmake:44 (include)
    make: *** [install] Error 1

    I was assuming CMAKE_INSTALL_PREFIX was set in the environment, rather than passed in via -DCMAKE_INSTALL_PREFIX=. I’ll try that instead.

  3. Volker Enderlein

    Hi Greg,

    that’s exactly why I was asking for the exact command sequence. CMAKE_INSTALL_PREFIX is never read from the environment by CMake, you have to provide it to the cmake command via the -DCMAKE_INSTALL_PREFIX=… setting

    Cheers, Volker

  4. Greg Earle reporter

    Thanks Volker. Trying it now 🙂 Will mark resolved as soon as I verify it worked.

    BTW in the Linux section of the BuildWithCMake Wiki page there is a line with

    (3) cd_coin_build

    One too many “_”s methinks 😉

  5. Greg Earle reporter


    One last thing: The Wiki page says to run cpack --config fedora.cmake afterwards. I get this:

    devlinux7{cm}% cpack --config fedora.cmake
    CPack: Create package using RPM
    CPack: Install projects
    CPack: - Run preinstall target for: Coin
    CPack: - Install project: Coin
    CPack: -   Install component: development
    CPack: -   Install component: runtime
    CPack: Create package
    CMake Warning (dev) at /usr/share/cmake/Modules/CPackRPM.cmake:1418 (message):
      CPackRPM:Warning: Symbolic link '/usr/lib64/' points to location
      that is outside packaging path! Link will possibly not be relocatable.
    Call Stack (most recent call first):
      /usr/share/cmake/Modules/CPackRPM.cmake:2306 (cpack_rpm_prepare_install_files)
      /usr/share/cmake/Modules/CPackRPM.cmake:2774 (cpack_rpm_generate_package)
    This warning is for project developers.  Use -Wno-dev to suppress it.
    CPackRPM: Will use GENERATED spec file: /usr/local/vicar/external/coin/v4.0.0/x86-64-linx/cpack.d/_CPack_Packages/RPM/SPECS/Coin-devel.spec
    CPackRPM:Debug: You may consult rpmbuild logs in: 
    CPackRPM:Debug:    - /usr/local/vicar/external/coin/v4.0.0/x86-64-linx/cpack.d/_CPack_Packages/RPM/rpmbuildCoin-devel.err
    CPackRPM:Debug: *** error: line 10: Tag takes single token only: Release:        11514.fcRed Hat Enterprise Linux Workstation release 7.3 (Maipo)
    CPackRPM:Debug:    - /usr/local/vicar/external/coin/v4.0.0/x86-64-linx/cpack.d/_CPack_Packages/RPM/rpmbuildCoin-devel.out
    CPackRPM:Debug: *** Building target platforms: x86_64
    Building for target x86_64
    CMake Error at /usr/share/cmake/Modules/CPackRPM.cmake:2703 (message):
      RPM package was not generated!
    Call Stack (most recent call first):
      /usr/share/cmake/Modules/CPackRPM.cmake:2774 (cpack_rpm_generate_package)
    CPack Error: Error while execution CPackRPM.cmake
    CPack Error: Error while execution CPackRPM.cmake
    CPack Error: Problem compressing the directory
    CPack Error: Error when generating package: Coin
    devlinux7{cm}% sed -n '10,10p' /usr/local/vicar/external/coin/v4.0.0/x86-64-linx/cpack.d/_CPack_Packages/RPM/SPECS/Coin-devel.spec
    Release:        11514.fcRed Hat Enterprise Linux Workstation release 7.3 (Maipo)

    I don’t really need to build RPMs so this is a Don’t Care, but I’m just wondering if it’s because I’m on RHEL 7 not Fedora.

  6. Volker Enderlein

    Hi Greg,

    I am not very experienced with generating RPMs and DEBs, but as you don’t want to provide Coin packages to other users you can omit this step. May be we need to reword the BuildWithCMake document to make it more clear that this step is optional. Thanks for notifying us.

    @Giampiero Gabbiani Can you have a look onto this error message?

    Cheers, Volker

  7. Greg Earle reporter

    Maybe yes, you should re-word it.

    OK, I lied about the one last thing. 😉 In coin/bin there is the coin-config shell script; but after make install all I see in $CMAKE_INSTALL_PREFIX/bin is CoinTests:

    devlinux7{cm}% cd x86-64-linux/bin
    devlinux7{cm}% ls -l
    total 1896
    -rwxrwxr-x 1 cm cm 1932480 Oct 27 12:50 CoinTests

    I would have expected it to copy coin/bin/coin-config in to $CMAKE_INSTALL_PREFIX/bin/coin-config (and chmod +x it) and also copy Coin.pc to an appropriate place under $CMAKE_INSTALL_PREFIX.

    Did I do something wrong?

  8. Volker Enderlein

    Unfortunately no, it seems to be an oversight on our side when migrating to CMake. Looks like we forgot to install coin-config. Coin.pc is located in ${CMAKE_INSTALL_LIBDIR}/pkgconfig directory. The CoinTests executable never should be installed. Will have a closer look onto the issue. Cheers, Volker

  9. Greg Earle reporter

    Thanks Volker. I guess I will hand-install them into the right place(s). Thanks for your “real-time” help!

  10. Greg Earle reporter

    P.S. “Coin.pc is located in ${CMAKE_INSTALL_LIBDIR}/pkgconfig directory

    devlinux7{cm}% pwd
    devlinux7{cm}% find . -type f -name Coin.pc -print0 | xargs -0 ls -l
    -rw-r--r-- 1 cm cm 814 Oct 27 12:41 ./lib64/pkgconfig/Coin.pc
    -rw-r--r-- 1 cm cm 814 Oct 27 12:41 ./x86-64-linux/Coin.pc

    Shouldn’t $CMAKE_INSTALL_LIBDIR == ${CMAKE_INSTALL_PREFIX}/lib$ARCH? I have no lib or lib64 in my $CMAKE_INSTALL_PREFIX directory. Only in the src tree.

    If I add “-DCMAKE_INSTALL_LIBDIR=/usr/local/vicar/external/coin/v4.0.0/x86-64-linux/lib64” to the cmake arguments, then make install does the Right Thing™:

    devlinux7{cm}% find . -type f -name Coin.pc -print0 | xargs -0 ls -l
    -rw-r--r-- 1 cmbld cm 814 Oct 27 12:41 ./lib64/pkgconfig/Coin.pc
    -rw-r--r-- 1 cmbld cm 922 Oct 27 17:06 ./x86-64-linux/Coin.pc
    -rw-r--r-- 1 cmbld cm 922 Oct 27 17:06 ./x86-64-linux/lib64/pkgconfig/Coin.pc

    Maybe you need to add that switch to the Wiki page entry for Linux as well … ?

  11. Greg Earle reporter

    Update: copied in bin/coin-config to ${CMAKE_INSTALL_PREFIX}/bin/coin-config and chmod’ed it +x … then I get:

    devlinux7{cm}% bin/coin-config 
    coin-config: no default Coin config available in /usr/local/vicar/external/coin/v4.0.0/x86-64-linux/share/Coin/conf/
    devlinux7{cm}% grep -n default coin-config
    82:elif test -f $prefix/share/Coin/conf/coin-default.cfg; then
    83:  configfile="$prefix/share/Coin/conf/coin-default.cfg"
    86:  echo >&2 "$me: no default Coin config available in $prefix/share/Coin/conf/"

    It’s looking for a share/Coin/conf/coin-default.cfg file which doesn’t exist anywhere … I thought all the pkg-config scripts looked for pkg.pc, not pkg-default.cfg?

    How can this work with no supplied .cfg file? Am I the only person installing it outside of /usr/local and thus needing a callable coin-config script for other programs to find the bins/libs/includes? 🤷🏼‍♂️

  12. Giampiero Gabbiani

    @Volker Enderlein Ciao Volker, the issue about cpack is probably related to the version tag that relies on fedora naming convention only. I’ll work on a solution for RedHat this evening.



  13. Log in to comment