[CMake] How to add files to Visual Studio 'Utility' project

J. Caleb Wherry calebwherry at gmail.com
Fri Feb 2 12:03:35 EST 2018


Agreed. If I don't here anything else about this, I'll write up a feature
request.

On Fri, Feb 2, 2018 at 9:50 AM, Eric Noulard <eric.noulard at gmail.com> wrote:

> There is some history on that:
>
> https://gitlab.kitware.com/cmake/cmake/issues/7835  linked to older
> https://itk.org/Bug/view.php?id=7835
>
> May be this is a plain feature request that should be properly written
> based on history and current usage.
> Typically I think that anyone would want to add any file to IDE project
> display.
>
>
> 2018-02-02 14:57 GMT+01:00 J. Caleb Wherry <calebwherry at gmail.com>:
>
>> Yes, I understand that. The error message is pretty clear.
>>
>> My main question is really why is that the case? In VS, there is no
>> restriction to adding files to a utility project. So why does CMake have
>> this restriction?
>>
>> I assume it is because it is generator specific and there isn’t a clean
>> way to implement add_custom_target across all of them. In that case I would
>> expect some special case handling for generators that do support it.
>>
>> And it’s not like CMake can’t add files to that Utility project, because
>> it does: it adds the Java rules files. It just doesn’t allow the user the
>> do the same. It’s a restriction that doesn’t really make sense to me.
>>
>> -Caleb
>>
>> On Fri, Feb 2, 2018 at 3:35 AM CHEVRIER, Marc <marc.chevrier at sap.com>
>> wrote:
>>
>>> This approach is not possible for Java because the command add_jar is
>>> implemented using commands add_custom_command and add_custom_target. And
>>> command target_sources implies that the target was created by one the
>>> commands add_library or add_executable.
>>>
>>>
>>>
>>>
>>>
>>> *From: *CMake <cmake-bounces at cmake.org> on behalf of "J. Caleb Wherry" <
>>> calebwherry at gmail.com>
>>> *Date: *Thursday 1 February 2018 at 19:30
>>> *To: *CMake ML <cmake at cmake.org>
>>> *Subject: *[CMake] How to add files to Visual Studio 'Utility' project
>>>
>>>
>>>
>>> Hello!
>>>
>>>
>>>
>>> I am having trouble with a generated VS project that I hope is either a
>>> bug or has an easy fix...
>>>
>>>
>>>
>>> When using UseJava, the add_jar function, and Visual Studio 2015, a VS
>>> 'Utility' project is created. I then want to add additional non-compiled
>>> files to this project so I try to use target_sources but get his error:
>>>
>>>
>>>
>>> "target_sources called with non-compilable target type"
>>>
>>>
>>>
>>> In VS, I can easily add files to the project without issue. But I cannot
>>> seem to add any additional files to this created 'Utility' project through
>>> CMake.
>>>
>>>
>>>
>>> I do this in other projects by using target_sources and setting the
>>> HEADER_FILE_ONLY and WRAP_EXCLUDE properties to make sure the project
>>> doesn't do anything with them and it works fine. Just can't do it for these
>>> Utility projects.
>>>
>>>
>>>
>>> My use case here is that the add_jar command doesn't actually add the
>>> java source files to the project. I want to use VS as a code editor in this
>>> case because it builds the jar. However, without them in the project, I
>>> have to go outside of VS to edit them (and thus outside of my VS perforce
>>> control).
>>>
>>>
>>>
>>> Thoughts? Maybe I am adding them incorrectly?
>>>
>>>
>>>
>>> -Caleb
>>>
>> --
>> Sent from my iPhone 4s
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> https://cmake.org/mailman/listinfo/cmake
>>
>>
>
>
> --
> Eric
>



-- 
J. Caleb Wherry
*Scientific Software Engineer*

<http://www.calebwherry.com>
http://www.calebwherry.com
+1 (615) 708-5651
calebwherry at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180202/2a5b5c5b/attachment.html>


More information about the CMake mailing list