[CMake] FooConfig.cmake with Foo_DIR issue

Tristan Carel tristan.carel at gmail.com
Tue Dec 19 18:09:48 EST 2006


On 12/19/06, Kedzierski,  Artur CIV NAVSURFWARCENDIV CORONA
<artur.kedzierski at navy.mil> wrote:
>
>
>
>         Hi,
>
>         For a package Foo, I have FooConfig.cmake that contains
>> Foo_LIBRARIES "${Foo_DIR}/lib/@Foo_LIBRARY_NAME@"
>>         That works fine on Linux. However, on Windows, I get
> Foo_LIBRARIES to be something like: "c:\Program Files\Foo\/lib/foo.lib".
> Is there anyway to tell CMake to substitute Foo_DIR with a path that uses
> forward slashes? The backslashes give me an error in CMake about
> incorrect escape sequences.
>         Thank You.

Hi Artur.

You can fix the non homogeneous paths with the following commands:
FILE(TO_CMAKE_PATH path result)
FILE(TO_NATIVE_PATH path result)

all details here:
http://cmake.org/HTML/Documentation.html

Example:
SET(variable "C:\\Program Files\\Aspell/doc/html")
FILE(TO_CMAKE_PATH "${variable}" variable) # will use /

So try to put this just after the assignment of Foo_DIR:
FILE(TO_CMAKE_PATH "${Foo_DIR}" Foo_DIR)

-- 
Tristan Carel
Music with dinner is an insult both to the cook and the violinist.


More information about the CMake mailing list