[CMake] Forcing CMake to never search install path
Michael Hertling
mhertling at online.de
Fri May 20 06:17:48 EDT 2011
On 05/20/2011 12:08 AM, Clifford Yapp wrote:
> Michael,
>
> At first glance those would be what I need (although it is not clear
> if I need to specify bin/lib/include for CMAKE_SYSTEM_IGNORE_PATH as
> well as CMAKE_IGNORE_PATH.) I have tested both out, and unfortunately
> they do not seem to exclude the CMAKE_INSTALL_PREFIX path when I
> supply it - I still get find results even after appending the install
> path to CMAKE_SYSTEM_IGNORE_PATH. I also tried
>
> get_filename_component(PATH_NORMALIZED ${CMAKE_INSTALL_PREFIX}/lib ABSOLUTE)
>
> to make it easier for Find to ignore the path, but that didn't seem to
> help. I've tried forcing the results into the Cache as well. Is
> there something else I need to do?
>
> Thanks,
> CY
On *nix, I experimented with the following CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(IGNORE C)
SET(CMAKE_VERBOSE_MAKEFILE ON)
FIND_LIBRARY(XYZ_LIBRARY xyz)
MESSAGE("XYZ_LIBRARY: ${XYZ_LIBRARY}")
MESSAGE("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
MESSAGE("CMAKE_SYSTEM_PREFIX_PATH: ${CMAKE_SYSTEM_PREFIX_PATH}")
FILE(WRITE ${CMAKE_BINARY_DIR}/xyz.c "void xyz(void){}\n")
ADD_LIBRARY(xyz STATIC xyz.c)
INSTALL(TARGETS xyz ARCHIVE DESTINATION lib)
First of all, I built from within an empty build directory with
cmake <SRCDIR> -DCMAKE_INSTALL_PREFIX=/dev/shm/xyz; make install
and got /dev/shm/xyz/lib/libxyz.a as expected. Subsequently, a
rm CMakeCache.txt; cmake <SRCDIR> -DCMAKE_INSTALL_PREFIX=/dev/shm/xyz
finds /dev/shm/xyz/lib/libxyz.a because CMAKE_INSTALL_PREFIX is
mentioned in CMAKE_SYSTEM_PREFIX_PATH - also expected - but a
rm CMakeCache.txt; cmake <SRCDIR> -DCMAKE_INSTALL_PREFIX=/dev/shm/xyz
-DCMAKE_IGNORE_PATH=/dev/shm/xyz/lib
as well as a
rm CMakeCache.txt; cmake <SRCDIR> -DCMAKE_INSTALL_PREFIX=/dev/shm/xyz
-DCMAKE_SYSTEM_IGNORE_PATH=/dev/shm/xyz/lib
shows that the library is not found anymore, although CMAKE_SYSTEM_
IGNORE_PATH isn't meant to be set by the project. Therefore, I would
conclude that these variables act according to their documentation. If
this isn't the case w.r.t. your issue, could you provide a minimal but
complete example which demonstrates these variables' failure? Possibly,
it might be considered as a bug.
Regards,
Michael
> On Thu, May 19, 2011 at 7:47 AM, Michael Hertling <mhertling at online.de> wrote:
>>
>> Have you already tried the CMAKE_[SYSTEM_]IGNORE_PATH variables? At
>> the first glance, they provide exactly the functionality you need.
More information about the CMake
mailing list