On Tuesday 15 September 2009 11:43:04 am Alexander Neundorf wrote: > On Tuesday 15 September 2009, Casey Jones wrote: > > On Monday 14 September 2009 3:22:14 pm Alexander Neundorf wrote: > > > On Sunday 13 September 2009, Casey Jones wrote: > > > > Hello, I'm trying to link a Qt4 library into my program as an > > > > optional dependency. I can get it to find and link the library with > > > > a FindFoo.cmake. But when I use check_include_files( foo.h HAVE_FOO_H > > > > ) it says it can't find the header. So looking in CMakeError.log it > > > > says it found foo.h but since it includes Qt headers like: > > > > #include <QString> > > > > instead of > > > > #include <qt4/QtCore/QString> > > > > it can't compile the test program. > > > > > > > > Is there a way to have check_include_files() not compile the test > > > > program and just make sure the header exists? > > > > > > You could just use find_path(FOO_INCLUDE_DIR foo.h ...), usually this > > > is good. enough. > > > Or you can set the cmake variable CMAKE_REQUIRED_INCLUDES before > > > calling the check_include_files() macro so that it lists all necessary > > > include dirs (should be ${QT_QTCORE_INCLUDE_DIR} or something like > > > this) > > > > > > > Or is there some other way to create the config.h.in and config.h? > > > > > > You don't *have* to compile anything in order to create a config.h from > > > a config.h.in. > > > configure_file() reads the config.h.in and replaces all cmake variables > > > with their values in that file and writes the output file. > > > It doesn't matter where these values come from, whether a > > > check_include_files() or if you just set them. > > > > > > Alex > > > > I'm trying out FIND_PATH(), but how do I put that variable into > > config.h.in? I have the variable HAVE_FOO_H, and it finds the header, but > > I just don't know what to do with that variable. > > > > Would I need to do something like: > > IF( ${HAVE_FOO_H} ) > > WRITE_TO_FILE(src/config.h.in "#cmakedefine HAVE_FOO_H" > > ENDIF( ${HAVE_FOO_H} ) > > > > I don't know if the write_to_file function exists or not, so thats why > > I'm asking. > > You should write a file like e.g. "myheader.h.in", which could look like > that: > > #define GREETING_TEXT "@MY_MESSAGE@" > > #cmakedefine HAVE_FOO_H 1 > > > Then in your CMakeLists.txt you do: > > set(MY_MESSAGE "Hello world") > set(HAVE_FOO_H TRUE) > > configure_file(myheader.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) > > This will make cmake read the existing myheader.h.in, replace the > @MY_MESSAGE@ with the contents of the cmake variable with the same name, > and turn the line with #cmakedefine either to > #define HAVE_FOO_H 1 > (if the cmake variable HAVE_FOO_H is true) or to > #undefine HAVE_FOO_H > (if the cmake variable HAVE_FOO_H is not true). > > HTH > Alex >
Thanks. I just added #cmakedefine HAVE_FOO_H to config.h.in, and used FIND_PATH() to set the variable. Also, sorry about that last reply. Apparently I forgot to change the "To" field so I sent it to your email and not the cmake list. Casey _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake