MantisBT - CMake
View Issue Details
0014591CMakeCMakepublic2013-11-22 05:002014-06-02 08:37
holtgrewe 
 
normalmajoralways
closedno change required 
x86Windows7
CMake 2.8.12 
 
0014591: find_path appears to ignore PATH_SUFFIXES
I am using the CMakeLists.txt from below and tried it with different CMake versions. Note that the include/zlib.h file exists.

The problem occured with 2.12.1 (see below).
See below.
C:\Temp\example-build>cmake --version
cmake version 2.8.11.1

C:\Temp\example-build>cmake ..\example -G "Visual Studio 11"
-- The C compiler identification is MSVC 17.0.60610.1
-- The CXX compiler identification is MSVC 17.0.60610.1
-- Check for working C compiler using: Visual Studio 11
-- Check for working C compiler using: Visual Studio 11 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 11
-- Check for working CXX compiler using: Visual Studio 11 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- RESULT C:/seqan-contrib-D20130710-x86/vs11/include
-- RESULT2 C:/seqan-contrib-D20130710-x86/vs11/include
-- RESULT3 C:/seqan-contrib-D20130710-x86/vs11/include
-- EXISTS C:/seqan-contrib-D20130710-x86/vs11/include/zlib.h
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Temp/example-build

C:\Temp\example-build>cmake --version
cmake version 2.8.11.2

C:\Temp\example-build>cmake ..\example -G "Visual Studio 11"
-- The C compiler identification is MSVC 17.0.60610.1
-- The CXX compiler identification is MSVC 17.0.60610.1
-- Check for working C compiler using: Visual Studio 11
-- Check for working C compiler using: Visual Studio 11 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 11
-- Check for working CXX compiler using: Visual Studio 11 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- RESULT C:/seqan-contrib-D20130710-x86/vs11/include
-- RESULT2 C:/seqan-contrib-D20130710-x86/vs11/include
-- RESULT3 C:/seqan-contrib-D20130710-x86/vs11/include
-- EXISTS C:/seqan-contrib-D20130710-x86/vs11/include/zlib.h
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Temp/example-build

C:\Temp\example-build>cmake --version
cmake version 2.8.12.1

C:\Temp\example-build>cmake ..\example -G "Visual Studio 11"
-- The C compiler identification is MSVC 17.0.60610.1
-- The CXX compiler identification is MSVC 17.0.60610.1
-- Check for working C compiler using: Visual Studio 11
-- Check for working C compiler using: Visual Studio 11 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 11
-- Check for working CXX compiler using: Visual Studio 11 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- RESULT RESULT-NOTFOUND
-- RESULT2 RESULT2-NOTFOUND
-- RESULT3 C:/seqan-contrib-D20130710-x86/vs11/include
-- EXISTS C:/seqan-contrib-D20130710-x86/vs11/include/zlib.h
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Temp/example-build

==> CMakeLists.txt <==

cmake_minimum_required (VERSION 2.8)
set (CMAKE_MODULE_PATH "C:/seqan-trunk/util/cmake" ${CMAKE_MODULE_PATH})
set (CMAKE_FIND_ROOT_PATH "C:/seqan-contrib-D20130710-x86/vs11")

find_path (RESULT zlib.h PATH_SUFFIXES include)
message (STATUS "RESULT ${RESULT}")

find_path (RESULT2 zlib.h "C:/seqan-contrib-D20130710-x86/vs11" PATH_SUFFIXES include)
message (STATUS "RESULT2 ${RESULT2}")

find_path (RESULT3 zlib.h "C:/seqan-contrib-D20130710-x86/vs11/include")
message (STATUS "RESULT3 ${RESULT3}")

if (EXISTS "C:/seqan-contrib-D20130710-x86/vs11/include/zlib.h")
  message (STATUS "EXISTS C:/seqan-contrib-D20130710-x86/vs11/include/zlib.h")
else ()
  message (STATUS "DOES NOT EXIST C:/seqan-contrib-D20130710-x86/vs11/include/zlib.h")
endif ()
No tags attached.
has duplicate 0014619closed  Windows: Regression affecting CMAKE_FIND_ROOT_PATH interaction with FIND_* commands, introduced since 2.8.11 
Issue History
2013-11-22 05:00holtgreweNew Issue
2013-11-22 10:09Brad KingNote Added: 0034520
2013-11-22 10:10Brad KingNote Added: 0034521
2013-11-22 10:10Brad KingStatusnew => resolved
2013-11-22 10:10Brad KingResolutionopen => no change required
2013-12-03 08:49Brad KingRelationship addedhas duplicate 0014619
2014-06-02 08:37Robert MaynardNote Added: 0036049
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0034520)
Brad King   
2013-11-22 10:09   
The find_path command has both a simple and a full signature:

 http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:find_path [^]

Your RESULT3 example works because you are using the simple signature where the third and later arguments are paths to search.

Your RESULT2 example fails because you are using the PATH_SUFFIXES option which enables the full signature. The full signature treats all arguments after the result variable and prior to any keyword arguments as names to consider rather than paths to search If I change the RESULT2 example to the full signature:

 find_path (RESULT2 NAMES zlib.h PATHS "C:/seqan-contrib-D20130710-x86/vs11" PATH_SUFFIXES include)

then it works. Without this change you provide no paths and depend on the builtin search paths to work.

Your RESULT example provides no paths and depends on the builtin search paths to work.

Now let's look at the system search paths.
CMAKE_FIND_ROOT_PATH is not a list of installation prefixes to search.
It is a list of paths to prefix to *other* search paths that would otherwise be searched directly.
This is for use when cross-compiling to help locate files inside target-platform SDKs.

The reason setting CMAKE_FIND_ROOT_PATH appeared to work in 2.8.11 and earlier but not in 2.8.12 is because prior to the bug fix for issue 0010994:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9eee7f1 [^]

the CMAKE_SYSTEM_PREFIX_PATH contained "/" on Windows. When the CMAKE_FIND_ROOT_PATH is prefixed to "/" the result appears to search all the prefixes in CMAKE_FIND_ROOT_PATH, but only by accident.

In the example use case you should set CMAKE_PREFIX_PATH instead:

 http://www.cmake.org/cmake/help/v2.8.12/cmake.html#variable:CMAKE_PREFIX_PATH [^]

If I set that then all three examples (RESULT, RESULT2, RESULT3) work.
(0034521)
Brad King   
2013-11-22 10:10   
For further help please inquire on the mailing list:

 http://www.cmake.org/cgi-bin/mailman/listinfo/cmake [^]
(0036049)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.