[geos-devel] cmake detailed comments

Paul Ramsey pramsey at cleverelephant.ca
Fri Oct 15 12:33:00 PDT 2021


So, I think dispensing with CMAKE_BUILD_RPATH while retaining CMAKE_INSTALL_RPATH as you have it gives results that allow you to run your script to completion cleanly... at least, I checked the output on MacOS, and it's like this:

First using the current setup in your script. As you note in the pre-install state we end up with binaries that have the system path first and the build path second, which would result in bad output if I had libraries living in there.

cmake .. \                   
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_BUILD_RPATH=${LIBDIR} \
-DCMAKE_INSTALL_RPATH=${LIBDIR}

PRE-INSTALL OBJDUMP (geosop):

Load command 17
          cmd LC_RPATH
      cmdsize 32
         path /usr/pkg/lib (offset 12)
Load command 18
          cmd LC_RPATH
      cmdsize 64
         path /Users/pramsey/Code/geos-3.10.0beta3/build/lib (offset 12)


However, at install time (using DESTDIR), the build path is stripped away and things are nicely pathed to their actual future install location. So this is good!

POST-INSTALL  OBJDUMP (geosop):

Load command 19
          cmd LC_RPATH
      cmdsize 32
         path /usr/pkg/lib (offset 12)


What if we use drop the CMAKE_BUILD_RPATH, as I suggest?

cmake .. \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_INSTALL_RPATH=${LIBDIR}

Now the pre-install binaries have the build path in them only, so they will run the tests against the build libs (and all should work)

PRE-INSTALL (geosop)

Load command 17
          cmd LC_RPATH
      cmdsize 64
         path /Users/pramsey/Code/geos-3.10.0beta3/build/lib (offset 12)


And post-install we are still looking good with a proper system path in the rpath.

POST-INSTALL (geosop)

Load command 19
          cmd LC_RPATH
      cmdsize 32
         path /usr/pkg/lib (offset 12)


Let me know what happens on your system?

P


> On Oct 15, 2021, at 12:01 PM, Paul Ramsey <pramsey at cleverelephant.ca> wrote:
> 
> I'm running your script now, but just from looking at it, this seems
> suspicious...
> 
> cmake .. \
>           -DCMAKE_INSTALL_PREFIX=${PREFIX} \
>           -DCMAKE_BUILD_RPATH=${LIBDIR} \
>           -DCMAKE_INSTALL_RPATH=${LIBDIR}
> 
> My understanding of the "build rpath" is that it exists in the built
> binaries PRE install, so for build testing, PRE install, you want it
> to point into the local library location. By over-riding it and
> setting it to LIBDIR, you're saying "no no no, please put this path
> into the rpath of of the PRE install binaries". I'd guess/hope that
> removing the CMAKE_BUILD_RPATH while leaving CMAKE_INSTALL_RPATH as
> you have it is closer to the intent, but I'll play with a build
> myself.
> 
> P
> 
> On Fri, Oct 15, 2021 at 6:02 AM Greg Troxel <gdt at lexort.com> wrote:
>> 
>> 
>> tl;dr:
>> 
>> I've done things the cmake way and the test are still not ok.
>> The problem is that the test RPATH is being *appended* to the BUILD
>> RPATH, instead of prepended.
>> 
>> long version:
>> 
>> My build script is:
>> ----------------------------------------
>> #!/bin/sh
>> 
>> if [ -d $HOME/bin/ccache ]; then
>>    echo "enabling ccache"
>>    ccache -z
>>    PATH=$HOME/bin/ccache:$PATH
>> fi
>> 
>> PREFIX=/usr/pkg
>> LIBDIR=${PREFIX}/lib
>> 
>> # In theory, BSD make is ok.
>> MAKE=make
>> 
>> (rm -rf build destdir &&
>>     mkdir build &&
>>     cd build &&
>>     cmake .. \
>>           -DCMAKE_INSTALL_PREFIX=${PREFIX} \
>>           -DCMAKE_BUILD_RPATH=${LIBDIR} \
>>           -DCMAKE_INSTALL_RPATH=${LIBDIR} \
>>> OUT.00.cmake 2>&1 &&
>>     ${MAKE} > OUT.10.make 2>&1 &&
>>     (${MAKE} check > OUT.20.check 2>&1 || true) && \
>>     make DESTDIR=../destdir install > OUT.30.install 2>&1 && \
>>     echo BUILD DONE
>> )
>> ----------------------------------------
>> 
>> BUILD_RPATH is passed because a packaging system invoking cmake must in
>> general ensure that programs/libs in the build environment can find
>> their dependencies at test time.
>> 
>> Some tests pass, and some fail, with "std:alloc bad" and various other
>> stuff.  But a quick look shows that objdump -x of one of the test
>> programs has:
>> 
>>  RPATH                /usr/pkg/lib:/home/n0/gdt/SOFTWARE/GEO/GEOS/geos-master/build/lib
>> 
>> so I expect it to go badly.   This should have been
>> 
>>  RPATH                /home/n0/gdt/SOFTWARE/GEO/GEOS/geos-master/build/lib:/usr/pkg/lib
>> 
>> and then I think it would have been fine.
>> 
>> 
>> If anyone can tell me what cmake args I should be using instead for the
>> general case of a program with a correct cmake setup and  which might be
>> finding dependencies from ${PREFIX}, I'd like to hear about it.   The
>> list above is what I came up after reading the cmake docs pointed out by
>> pramsey@ and strk at .
>> 
>> Greg
>> _______________________________________________
>> geos-devel mailing list
>> geos-devel at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/geos-devel



More information about the geos-devel mailing list