[cmake-developers] [CMake 0014631]: Unable To Add Output Of Custom Command To Source Group Command

Mantis Bug Tracker mantis at public.kitware.com
Wed Dec 4 14:33:17 EST 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=14631 
====================================================================== 
Reported By:                Ryan H. Kawicki
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14631
Category:                   CMake
Reproducibility:            always
Severity:                   tweak
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-12-04 14:33 EST
Last Modified:              2013-12-04 14:33 EST
====================================================================== 
Summary:                    Unable To Add Output Of Custom Command To Source
Group Command
Description: 
Output of the custom command is unable to be properly placed in the IDE folder
structure.

// simple example
cmake_minimum_required(VERSION 2.8.11.1)

project(blah)

set(all_src blah.cpp blah2.cpp)
SOURCE_GROUP("BlahFiles\\Source" FILES ${all_src})

ADD_CUSTOM_COMMAND(OUTPUT blah2.cpp
                   COMMAND del blah2.cpp
                   COMMAND echo 2>blah2.cpp
                   WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
                   COMMENT "create me some source")

add_executable(blah_test WIN32 ${all_src})
// end simple example

- first problem is that the IDE thinks that blah2.cpp is generated in binary
source directory but the execution of the commands happens in the source
directory.  a little confusing and may need documentation updated to reflect
this more clearly.

- the first issue can be resolved by removing the WORKING_DIRECTORY command. 
This solves the issue of not being able to find it correctly in the IDE (even
though not correct directory), the build rules are able to execute, but it still
shows up in the wrong location in the IDE.

- to resolve the second issue, we have to make a further change that i will just
show in the next modified example below.  What was changed was that I had to
prefix CMAKE_CURRENT_BINARY_DIR to the source file to have it be able to place
it correctly in the IDE.  The odd thing here is that if not adding the prefix,
things still work correctly.  Add_executable, in the original issue, was still
able to determine that blah2.cpp was a generated file and that it understood
that the list of files provided somehow matched up (no cmake errors). 
Source_group, on the other hand, requires a full physical path of the generated
file for it to properly find it in the list of provided source files, even
though add_executable was able to determine that blah2.cpp was a GENERATED file
without the full path.

// simple example
cmake_minimum_required(VERSION 2.8.11.1)

project(blah)

set(all_src blah.cpp "${CMAKE_CURRENT_BINARY_DIR}/blah2.cpp")
SOURCE_GROUP("BlahFiles\\Source" FILES ${all_src})

ADD_CUSTOM_COMMAND(OUTPUT blah2.cpp
                   COMMAND del blah2.cpp
                   COMMAND echo 2>blah2.cpp
                   COMMENT "create me some source")

add_executable(blah_test WIN32 ${all_src})
// end simple example

- my question / suggestion is to determine if it is possible for SOURCE_GROUP to
also be able to understand, like add_executable, that blah2.cpp is a generated
file and to marry the two together without the full path.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-12-04 14:33 Ryan H. KawickiNew Issue                                    
======================================================================




More information about the cmake-developers mailing list