[cmake-developers] Adding source files not built by targets to CMake project

Marcus D. Hanwell marcus.hanwell at kitware.com
Fri Nov 20 13:48:06 EST 2015


On Fri, Nov 20, 2015 at 10:46 AM, Nils Gladitz <nilsgladitz at gmail.com> wrote:
> On 11/20/2015 04:43 PM, Marcus D. Hanwell wrote:
>>
>> I would like to see these files listed in Qt Creator (or insert your
>> IDE of choice here). Is there anyway to do this, knowing that these
>> files are not going to be built for a target (or compiled in any way).
>> Any trick I am missing to make this work? When I include a .cmake file
>> I see it is added, so I feel like there is some plumbing already in
>> place to feed through these source files that are not built by
>> targets.
>
>
> If they are related to an existing build target
> (add_executable()/add_library()) you can list them there with your regular
> sources.
> Otherwise e.g. add_custom_target(my_custom_target SOURCES foo.py bar.json
> ...) should work.
>
Thanks, the add_custom_target works great. I hadn't thought of trying
that, glad the answer was so simple.

Marcus


More information about the cmake-developers mailing list