[CMake] error while stage install of crosscompiled binaries

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jan 11 16:28:43 EST 2010


On Thursday 07 January 2010, Claus Klein wrote:
> Hi
>
> i want to install a cross compiled (build host is a MAC OS X) project
> to a temporary state dir to get an archive to distribute the binaries.
> The target is win32 (mingw), compiled to be installed at c:/usr as
> CMAKE_INSTALL_PREFIX.
> This prefix is used while compile the binaries, so I can't change it.
>
> I think, that when I use DESTDIR while "make DESTDIR=/tmp/cmake
> install", the device (C:) should be removed before to use it as part
> of a path like this:
>
> STRING(REGEX REPLACE "[A-Za-z:/]" "" CMAKE_INSTALL_PREFIX "$
> {CMAKE_INSTALL_PREFIX}")
>
> head cmake_install.cmake
> # Install script for directory: /Users/clausklein/Workspace/c/libsmi/
> trunk
> #
> # Set the install prefix
> IF(NOT DEFINED CMAKE_INSTALL_PREFIX)
>    SET(CMAKE_INSTALL_PREFIX "C:/usr")
> ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
> STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "$
> {CMAKE_INSTALL_PREFIX}")
> . . . .
>
> As you can see,  PREFIX is appended to DESDIR without modification.
> which is wrong in this special case.
> I am not sure if the file is wrong generated or called with wrong
> parameters?
>
>
> Any ideas about this?
>
> //regards
>
> Claus
> ------------------------------------------
>
> This happens on my Mac Os X:
> claus-kleins-macbook-pro:build clausklein$ make DESTDIR=/tmp/cmake
> install
> [ 30%] Built target smi
> [ 34%] Built target smidiff
> [ 87%] Built target smidump
> [ 90%] Built target smilint
> [ 94%] Built target smiquery
> [100%] Built target smixlate
> Install the project...
> -- Install configuration: "Release"
> CMake Error at cmake_install.cmake:31 (FILE):
>    file cannot create directory:
>    /tmp/cmake/Users/clausklein/Workspace/c/libsmi/trunk/build/C:/usr/

I guess the actual issue is that "C:/usr" is not recognized as absolute path, 
since on UNIX/OSX it is none, but on the target OS it would be one.
I never tried setting CMAKE_INSTALL_PREFIX to a relative path. Ok, just tried 
it:

hammer:~/src/CMake/tests/relativeinstallprefix$ cat CMakeLists.txt
add_executable(foo main.c)
install(TARGETS foo DESTINATION bin )
hammer:~/src/CMake/tests/relativeinstallprefix$ 
cmake -DCMAKE_INSTALL_PREFIX=rela/foo .
-- Check for working C compiler: /usr/bin/gcc
...
-- Configuring done
-- Generating done
-- Build files have been written 
to: /home/alex/src/CMake/tests/relativeinstallprefix
hammer:~/src/CMake/tests/relativeinstallprefix$ make install
Scanning dependencies of target foo
[100%] Building C object CMakeFiles/foo.dir/main.o
Linking C executable foo
[100%] Built target foo
Install the project...
-- Install configuration: ""
-- 
Installing /home/alex/src/CMake/tests/relativeinstallprefix/rela/foo/bin/foo
hammer:~/src/CMake/tests/relativeinstallprefix$                                       


So indeed a relative CMAKE_INSTALL_PREFIX is interpreted relative to the build 
dir.

Do you think this should be handled differently ?
Then c:/usr would have to be translated at some point to "/c:/usr" if cross 
compiling on some UNIX.
Would this make sense ?

Alex


More information about the CMake mailing list