[CMake] Having problems getting started

Daniel daniel at connect2.com
Sun Mar 2 03:28:21 EST 2008


Arlen Cox wrote:
> Thanks Mike.
> That was exactly what I was looking for.
> 
> -Arlen
> 
> On Fri, Feb 29, 2008 at 11:20 AM, Mike Jackson <imikejackson at gmail.com>
> wrote:
> 
>> You may want to look at the
>> file(GLOB variable [RELATIVE path] [globbing expressions]...)
>>
>> or
>>
>>   file(GLOB_RECURSE variable [RELATIVE path]
>>        [globbing expressions]...)
>>
>> if you do a cmake --help-command file  a print out of the documentation
>> for that command will be listed.
>>
>> Also,
>>   Some projects use the following as the way to get source files:
>>
>> SET (MyProject_SRCS   SomeFile.cpp  SomeOtherFile.cxx  lib/SomeLibFile.cpp
>> )
>>
>> ADD_LIBRARY(VSEngine ${MyProject_SRCS})
>>
>> That will default to a static library. If you want a shared library:
>>
>> ADD_LIBRARY(VSEngine SHARED ${MyProject_SRCS})
>>
>>
>> --
>> Mike Jackson
>>
>>
>> On Feb 29, 2008, at 11:37 AM, Arlen Cox wrote:
>>
>> 1.  Is there some way to use wildcards when specifying files for a
>> library?  Something like this:
>> add_library(VSEngine *.cpp)
>>
>> That particular line doesn't work.  I tried, but there must be a way that
>> I can add a file to a project without having to modify the makefil
>>

Just so that you are aware, if you use FILE(GLOB to build your source list, you 
will need to touch the CMakeLists.txt file every time you add a file.  This is 
because CMake does not look for new files when make is run, only when it rereads 
the CMakeLists files.
--
Daniel


More information about the CMake mailing list