Hi all,<div><br></div><div>I am currently building a collection of inter-dependent libraries and tools, mostly cmake-built, all installed to a common staging directory.</div><div><br></div><div>I therefore need CMake find_library & find_package commands to search in the staging directory first, before inspecting the system.</div>
<div><br></div><div>Here's my problem: I can't get any combination of CMAKE_PREFIX_PATH or CMAKE_FIND_ROOT_PATH_MODE_* (in BOTH/NEVER/ONLY modes) to do this correctly, when find_library is given multiple names for the library.</div>
<div><br></div><div>It only works using CMAKE_PREFIX_PATH, or CMAKE_FIND_ROOT_PATH & CMAKE_FIND_ROOT_PATH_MODE=BOTH, provided that the name of the library present in the stage directory is the *first* of the library names list given to find_library.</div>
<div><br></div><div>It seems like the search order in such cases is as follows (in pseudo-code):</div><div><br></div><div>for each name in names</div><div> for dir in stage, system</div><div> if library_found(dir, name)</div>
<div> return dir, name</div><div> end</div><div> end</div><div>end</div><div><br></div><div>My use case would require the inner and outer loops to be swapped.</div><div><br></div><div>Please find attached a minimal test case illustrating my problem.</div>
<div><br></div><div>When running it on my Mac OS X 10.6 macbook, I get the following output:</div><div><br></div><div><div>==============================> cmake -DCMAKE_FIND_ROOT_PATH:PATH=/Users/nt/Hacks/cmake-find-png/stage -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY:STRING=ONLY ..</div>
<div>-- The C compiler identification is GNU</div><div>-- The CXX compiler identification is GNU</div><div>-- Checking whether C compiler has -isysroot</div><div>-- Checking whether C compiler has -isysroot - yes</div><div>
-- Checking whether C compiler supports OSX deployment target flag</div><div>-- Checking whether C compiler supports OSX deployment target flag - yes</div><div>-- Check for working C compiler: /usr/bin/gcc</div><div>-- Check for working C compiler: /usr/bin/gcc -- works</div>
<div>-- Detecting C compiler ABI info</div><div>-- Detecting C compiler ABI info - done</div><div>-- Checking whether CXX compiler has -isysroot</div><div>-- Checking whether CXX compiler has -isysroot - yes</div><div>-- Checking whether CXX compiler supports OSX deployment target flag</div>
<div>-- Checking whether CXX compiler supports OSX deployment target flag - yes</div><div>-- Check for working CXX compiler: /usr/bin/c++</div><div>-- Check for working CXX compiler: /usr/bin/c++ -- works</div><div>-- Detecting CXX compiler ABI info</div>
<div>-- Detecting CXX compiler ABI info - done</div><div>==============================> Looking for: png;png14</div><div>==============================> Found: /Users/nt/Hacks/cmake-find-png/stage/lib/libpng14.a</div>
<div>==============================> Looking for: png14;png</div><div>==============================> Found: /Users/nt/Hacks/cmake-find-png/stage/lib/libpng14.a</div><div>-- Configuring done</div><div>-- Generating done</div>
<div>-- Build files have been written to: /Users/nt/Hacks/cmake-find-png/build-ROOT_PATH_ONLY</div><div>/Users/nt/Hacks/cmake-find-png</div><div>==============================> cmake -DCMAKE_FIND_ROOT_PATH:PATH=/Users/nt/Hacks/cmake-find-png/stage -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY:STRING=BOTH ..</div>
<div>-- The C compiler identification is GNU</div><div>-- The CXX compiler identification is GNU</div><div>-- Checking whether C compiler has -isysroot</div><div>-- Checking whether C compiler has -isysroot - yes</div><div>
-- Checking whether C compiler supports OSX deployment target flag</div><div>-- Checking whether C compiler supports OSX deployment target flag - yes</div><div>-- Check for working C compiler: /usr/bin/gcc</div><div>-- Check for working C compiler: /usr/bin/gcc -- works</div>
<div>-- Detecting C compiler ABI info</div><div>-- Detecting C compiler ABI info - done</div><div>-- Checking whether CXX compiler has -isysroot</div><div>-- Checking whether CXX compiler has -isysroot - yes</div><div>-- Checking whether CXX compiler supports OSX deployment target flag</div>
<div>-- Checking whether CXX compiler supports OSX deployment target flag - yes</div><div>-- Check for working CXX compiler: /usr/bin/c++</div><div>-- Check for working CXX compiler: /usr/bin/c++ -- works</div><div>-- Detecting CXX compiler ABI info</div>
<div>-- Detecting CXX compiler ABI info - done</div><div>==============================> Looking for: png;png14</div><div>==============================> Found: /usr/X11R6/lib/libpng.dylib</div><div>==============================> Looking for: png14;png</div>
<div>==============================> Found: /Users/nt/Hacks/cmake-find-png/stage/lib/libpng14.a</div><div>-- Configuring done</div><div>-- Generating done</div><div>-- Build files have been written to: /Users/nt/Hacks/cmake-find-png/build-ROOT_PATH_BOTH</div>
<div>/Users/nt/Hacks/cmake-find-png</div><div>==============================> cmake -DCMAKE_FIND_ROOT_PATH:PATH=/Users/nt/Hacks/cmake-find-png/stage -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY:STRING=NEVER ..</div><div>-- The C compiler identification is GNU</div>
<div>-- The CXX compiler identification is GNU</div><div>-- Checking whether C compiler has -isysroot</div><div>-- Checking whether C compiler has -isysroot - yes</div><div>-- Checking whether C compiler supports OSX deployment target flag</div>
<div>-- Checking whether C compiler supports OSX deployment target flag - yes</div><div>-- Check for working C compiler: /usr/bin/gcc</div><div>-- Check for working C compiler: /usr/bin/gcc -- works</div><div>-- Detecting C compiler ABI info</div>
<div>-- Detecting C compiler ABI info - done</div><div>-- Checking whether CXX compiler has -isysroot</div><div>-- Checking whether CXX compiler has -isysroot - yes</div><div>-- Checking whether CXX compiler supports OSX deployment target flag</div>
<div>-- Checking whether CXX compiler supports OSX deployment target flag - yes</div><div>-- Check for working CXX compiler: /usr/bin/c++</div><div>-- Check for working CXX compiler: /usr/bin/c++ -- works</div><div>-- Detecting CXX compiler ABI info</div>
<div>-- Detecting CXX compiler ABI info - done</div><div>==============================> Looking for: png;png14</div><div>==============================> Found: /usr/X11R6/lib/libpng.dylib</div><div>==============================> Looking for: png14;png</div>
<div>==============================> Found: /usr/X11R6/lib/libpng.dylib</div><div>-- Configuring done</div><div>-- Generating done</div><div>-- Build files have been written to: /Users/nt/Hacks/cmake-find-png/build-ROOT_PATH_NEVER</div>
<div>/Users/nt/Hacks/cmake-find-png</div><div>==============================> cmake -DCMAKE_PREFIX_PATH:PATH=/Users/nt/Hacks/cmake-find-png/stage ..</div><div>-- The C compiler identification is GNU</div><div>-- The CXX compiler identification is GNU</div>
<div>-- Checking whether C compiler has -isysroot</div><div>-- Checking whether C compiler has -isysroot - yes</div><div>-- Checking whether C compiler supports OSX deployment target flag</div><div>-- Checking whether C compiler supports OSX deployment target flag - yes</div>
<div>-- Check for working C compiler: /usr/bin/gcc</div><div>-- Check for working C compiler: /usr/bin/gcc -- works</div><div>-- Detecting C compiler ABI info</div><div>-- Detecting C compiler ABI info - done</div><div>-- Checking whether CXX compiler has -isysroot</div>
<div>-- Checking whether CXX compiler has -isysroot - yes</div><div>-- Checking whether CXX compiler supports OSX deployment target flag</div><div>-- Checking whether CXX compiler supports OSX deployment target flag - yes</div>
<div>-- Check for working CXX compiler: /usr/bin/c++</div><div>-- Check for working CXX compiler: /usr/bin/c++ -- works</div><div>-- Detecting CXX compiler ABI info</div><div>-- Detecting CXX compiler ABI info - done</div>
<div>==============================> Looking for: png;png14</div><div>==============================> Found: /usr/X11R6/lib/libpng.dylib</div><div>==============================> Looking for: png14;png</div>
<div>==============================> Found: /Users/nt/Hacks/cmake-find-png/stage/lib/libpng14.a</div><div>-- Configuring done</div><div>-- Generating done</div><div>-- Build files have been written to: /Users/nt/Hacks/cmake-find-png/build-PREFIX</div>
<div>/Users/nt/Hacks/cmake-find-png</div></div><div><br></div><div>Any thoughts?</div><div><br></div><div><div>Thanks for making such a useful cross-platform build tool.</div><div>--<br><br>
</div></div>