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

CHEVRIER, Marc marc.chevrier at sap.com
Fri Feb 2 03:35:49 EST 2018


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180202/745e7774/attachment-0001.html>


More information about the CMake mailing list