Marcel Loose | 1 Jul 2009 10:13
Picon
Favicon

CheckIncludeFiles: how to use?

Hi all,

Maybe it's because of a partially sleepless night, but I can't seem to
figure out how I should use check_include_files().

According to the docs (and the implementation) this macro should be used
as:

  CHECK_INCLUDE_FILES(INCLUDE VARIABLE)

where INCLUDE should contain the list of files to include.
Problem is, however, that the following doesn't work:

  CHECK_INCLUDE_FILES(unistd.h stdio.h var)

because this will assign "unistd.h" to the variable INCLUDE and
"stdio.h" to the variable VARIABLE.

The following also doesn't work:

  SET(files unistd.h stdio.h)
  CHECK_INCLUDE_FILES(files var)

because the variable INCLUDE is not handled as the name of the list
containing the header files, but as the name of the header file itself.

Am I missing something here, or is this a bug in check_include_files()?

Best regards,
Marcel Loose.
(Continue reading)

Marcel Loose | 1 Jul 2009 10:56
Picon
Favicon

if(string MATCHES regex) question

Hi all,

In a number of standard CMake modules I encountered the following line:

  IF("${VARIABLE}" MATCHES "^${VARIABLE}$")

Can anyone explain the rationale of this conditional to me. To my
cluttered mind this seems to be an "always-true" condition.

Best regards,
Marcel Loose.

_______________________________________________
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

David Cole | 1 Jul 2009 15:48
Favicon
Gravatar

Re: CheckIncludeFiles: how to use?

Try:

CHECK_INCLUDE_FILES("unistd.h;stdio.h" var)

Or:
SET(files unistd.h stdio.h)
CHECK_INCLUDE_FILES("${files}" var)


On Wed, Jul 1, 2009 at 4:13 AM, Marcel Loose <loose-JEfgvD5ZcVNmR6Xm/wNWPw@public.gmane.org> wrote:
Hi all,

Maybe it's because of a partially sleepless night, but I can't seem to
figure out how I should use check_include_files().

According to the docs (and the implementation) this macro should be used
as:

 CHECK_INCLUDE_FILES(INCLUDE VARIABLE)

where INCLUDE should contain the list of files to include.
Problem is, however, that the following doesn't work:

 CHECK_INCLUDE_FILES(unistd.h stdio.h var)

because this will assign "unistd.h" to the variable INCLUDE and
"stdio.h" to the variable VARIABLE.

The following also doesn't work:

 SET(files unistd.h stdio.h)
 CHECK_INCLUDE_FILES(files var)

because the variable INCLUDE is not handled as the name of the list
containing the header files, but as the name of the header file itself.

Am I missing something here, or is this a bug in check_include_files()?

Best regards,
Marcel Loose.






_______________________________________________
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

_______________________________________________
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
James C. Sutherland | 1 Jul 2009 15:58
Picon
Favicon

Re: Problem with generated source and header files

>
> So, in general, when using globbing, YOU are responsible for rerunning
> CMake whenever you've added a source file. Otherwise you run the  
> risk of
> the new file not being compiled. Furthermore, you might accidentally
> compile sources that were just lying around in your directory as test
> code. Deletion of sources can also cause interesting effects if you
> create a library, because the object will remain in that library until
> you (manually) remove and recreate the library.
>
> I hope my examples convinced you enough that globbing is (in  
> general) a
> bad idea.
>
So is it common practice among users of CMake to manually create and  
maintain a list of all files that are to be compiled, even if such a  
list is very large and may involve several directories and  
subdirectories?
_______________________________________________
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

John Drescher | 1 Jul 2009 16:06
Picon

Re: Problem with generated source and header files

>> I hope my examples convinced you enough that globbing is (in general) a
>> bad idea.
>>
> So is it common practice among users of CMake to manually create and
> maintain a list of all files that are to be compiled, even if such a list is
> very large and may involve several directories and subdirectories?
>
I do with all of my projects. The thing is that I generally add only 2
or 4 files at a time so its not like this is a lot of work.

John
_______________________________________________
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

Mark Lohry | 1 Jul 2009 18:03
Picon

appending srcs to custom_target, or doxygen support

Apologies if this has been covered, but I'm only seeing occasional references to doxygen in the archives.

Is there any built-in mechanism for some kind of "make doc" to invoke building documentation through doxygen, or does it require ADD_CUSTOM_TARGET?

Presuming there isn't, I have several library directories beneath the top source directory, each of which contains it's own doxygen config file. I'd like the flexibility of building within just those libraries individually (i.e. run cmake on ./src/lib1/, and make doc to use ./src/lib1/DOXYGEN_CONFIG_FILE), or building all at once with the top level cmakelists (i.e. run cmake on ./src, and make doc to build all the individual library docs.)

in ./src/lib1/cmakelists.txt I have:

if(DOXYGEN_EXECUTABLE AND UNIX)
  IF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
    message( "***** Doxygen config file found *****" )
    SET(DOXYFILE_FOUND true)
    ADD_CUSTOM_TARGET( doc ${DOXYGEN_EXECUTABLE}
      "${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE}" )
    install(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/ DESTINATION ${docdir}/html)
  ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
endif(DOXYGEN_EXECUTABLE AND UNIX)



which works fine for just that one directory, but placing that same section in ./src/lib2,3,4.. gives an error "target doc already defined". I'd rather not have a custom doc target (make doc_lib1, make doc_lib2...) for each library. So is there any facility to do something like  "if( exists custom_target doc ) then append( command to doxy the next library)"?

Thanks in advance!

_______________________________________________
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
Tyler Roscoe | 1 Jul 2009 18:22

Re: appending srcs to custom_target, or doxygen support

On Wed, Jul 01, 2009 at 11:03:10AM -0500, Mark Lohry wrote:
> in ./src/lib1/cmakelists.txt I have:
> 
> if(DOXYGEN_EXECUTABLE AND UNIX)
>   IF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
>     message( "***** Doxygen config file found *****" )
>     SET(DOXYFILE_FOUND true)
>     ADD_CUSTOM_TARGET( doc ${DOXYGEN_EXECUTABLE}
>       "${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE}" )
>     install(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/ DESTINATION ${docdir}/html)
>   ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
> endif(DOXYGEN_EXECUTABLE AND UNIX)
> 
> 
> which works fine for just that one directory, but placing that same section
> in ./src/lib2,3,4.. gives an error "target doc already defined". I'd rather
> not have a custom doc target (make doc_lib1, make doc_lib2...) for each
> library. So is there any facility to do something like  "if( exists
> custom_target doc ) then append( command to doxy the next library)"?

Look at if(TARGET ...) and add_custom_command(... APPEND). I'm not sure
the APPEND part will work because there are issues with custom_commands
across multiple directories (I don't remember the details, but the
archives do).

tyler
_______________________________________________
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

Mark Lohry | 1 Jul 2009 18:27
Picon

Re: appending srcs to custom_target, or doxygen support

perfect, thank you

On Wed, Jul 1, 2009 at 11:22 AM, Tyler Roscoe <tyler-DXGRUvK/JSnR7s880joybQ@public.gmane.org> wrote:
On Wed, Jul 01, 2009 at 11:03:10AM -0500, Mark Lohry wrote:
> in ./src/lib1/cmakelists.txt I have:
>
> if(DOXYGEN_EXECUTABLE AND UNIX)
>   IF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
>     message( "***** Doxygen config file found *****" )
>     SET(DOXYFILE_FOUND true)
>     ADD_CUSTOM_TARGET( doc ${DOXYGEN_EXECUTABLE}
>       "${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE}" )
>     install(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/ DESTINATION ${docdir}/html)
>   ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
> endif(DOXYGEN_EXECUTABLE AND UNIX)
>
>
> which works fine for just that one directory, but placing that same section
> in ./src/lib2,3,4.. gives an error "target doc already defined". I'd rather
> not have a custom doc target (make doc_lib1, make doc_lib2...) for each
> library. So is there any facility to do something like  "if( exists
> custom_target doc ) then append( command to doxy the next library)"?

Look at if(TARGET ...) and add_custom_command(... APPEND). I'm not sure
the APPEND part will work because there are issues with custom_commands
across multiple directories (I don't remember the details, but the
archives do).

tyler

_______________________________________________
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
Eric Noulard | 1 Jul 2009 18:28
Picon

Re: if(string MATCHES regex) question

2009/7/1 Marcel Loose <loose@...>:
> Hi all,
>
> In a number of standard CMake modules I encountered the following line:
>
>  IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
>
> Can anyone explain the rationale of this conditional to me.

The rational no but ....

> To my cluttered mind this seems to be an "always-true" condition.

this is definitely not always true.
The variable your are testing may contain "un-evaluated" var
or some special regex character( *, ?, ...)

See attached example, you may test it with
$ cmake -P matches.cmake
MATCHES -- MYVAR = A good var
Look that one = double-dollar = blah / single-dollar = MYVAR2
NO MATCHES ** MYVAR = MYVAR2
$

However I have no such usage currently :-)

--

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
Attachment (matches.cmake): application/octet-stream, 545 bytes
_______________________________________________
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
Florent Teichteil | 1 Jul 2009 19:23
Picon

FindxxWidgets.cmake: wrong wxWidgets_INCLUDE_DIRS on UNIX

Hi,

I am trying to write a CMakeLists.txt file on a Linux Ubuntu 9.04 
platform. I'd like to test the presence of wxwidgets on the system, and 
  use the include files of wxwidgets. This file is very simple at the 
moment:

// BEGINNING OF CMakeLists.txt

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
find_package(wxWidgets COMPONENTS base core REQUIRED)
include_directories(${wxWidgets_INCLUDE_DIRS})
add_definitions(${wxWidgets_DEFINITIONS})
message(STATUS ${wxWidgets_INCLUDE_DIRS})

// END OF CMakeLists.txt

When I run "cmake ." in a terminal window, I get the following output:

-- /usr/lib/wx/include/gtk2-unicode-release-2.8/usr/include/wx-2.8
-- Configuring done
-- Generating done

The first line gives the value of "wxWidgets_INCLUDE_DIRS" which is 
obviously wrong. It seems 2 paths have been concatenated without white 
space. I think it should be something like 
"/usr/lib/wx/include/gtk2-unicode-release-2.8 /usr/include/wx-2.8".

All the best,
Florent
_______________________________________________
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


Gmane