[CMake] Writing platform check

Eric Noulard eric.noulard at gmail.com
Wed Nov 5 02:03:24 EST 2008


2008/11/5 Rajika Kumarasiri <rajika at wso2.com>:
> hello every body,
> I was trying to generate and use a config.h file from a very simple
> config.h.in file for cross compilation of my software, cmake gave me the
> following error. I was reading the guide here[1].
>
>
> -- The C compiler identification is GNU
> -- The CXX compiler identification is GNU
> -- Check for working C compiler: /usr/lib/ccache/gcc
> -- Check for working C compiler: /usr/lib/ccache/gcc -- works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Check for working CXX compiler: /usr/lib/ccache/c++
> -- Check for working CXX compiler: /usr/lib/ccache/c++ -- works
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- Looking for include files HAVE_MALLOC_H
> -- Looking for include files HAVE_MALLOC_H - found
> -- Looking for include files HAVE_SYS_MOUNT_H
> -- Looking for include files HAVE_SYS_MOUNT_H - found
> CMake Error: Could not open file for write in copy
> operation /util/include/config.h.tmp
> CMake Error: : System Error: No such file or directory
> CMake Error at util/CMakeLists.txt:9 (CONFIGURE_FILE):
>  configure_file Problem configuring file
>
> CMake looks for a file named config.h.tmp which is not actually not
> there cause the problem. My CMakeLists.txt in /util and my simple
> config-util.h.in  /util/include is as follows.

Do you really mean "/util" as an absolute path or is <some_prefix>/util ?

>
> CMakeLists.txt
> --------------
>
> ADD_SUBDIRECTORY(src)
>
> INCLUDE (CheckIncludeFiles)
>
> CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
> CHECK_INCLUDE_FILES ("sys/param.h;sys/mount.h" HAVE_SYS_MOUNT_H)
>
> CONFIGURE_FILE(${TEST_SOURCE_DIR}/util/include/config-util.h.in
> ${TEST_SOURCE_DIR}/util/include/config.h)

Is your project called TEST ?

You may be trying to write a file in a place where you don't have the
right to do so.
Usual way to call CONFIGURE_FILE is:

CONFIGURE_FILE(config-util.h.in config.h)
from within a CMakeLists.txt which is in the same directory as
"config-util.h.in"
or may be with
CONFIGURE_FILE(util/include/config-util.h.in util/include/config.h)

config.h will end-up in the build tree, which is fine for a generated file.

-- 
Erk


More information about the CMake mailing list