View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007835CMakeCMakepublic2008-10-20 16:112016-06-10 14:30
ReporterEric NOULARD 
Assigned ToBill Hoffman 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0007835: Make it easier to add non-source (i.e. not compiled) file to a Visual Studio project
DescriptionCurrently if you want to add file to a Visual Studio project
you have to:

1) add the file to the source list of either
   add_executable
   add_library

2) Specify that the file is not to be compiled with:
   set_source_files_properties(thefile PROPERTIES HEADER_FILE_ONLY TRUE)


I would suggest an easier way to add "non compiled" source file to a project

Suggestion1) All files appearing as "InputFile" of configure_file cmake
             command should automatically show up in a "CONFIGURED_FILE"
             project, this project may not be "buildable" but it would
             ease the edition of this kind of "source files"

Suggestion2) We may add a ADD_EDITABLE command like
              add_editable(<name> editable1 editable2 ... editableN)
             which would create a non buildable (or doing nothing)
             project which will contains those "editable" files.

Note that the feature may be useful to other "IDE", XCode, Code::Blocks etc...
but I don't know that since I do not use those.
Additional Informationsee former discussions on this issue:
http://www.cmake.org/pipermail/cmake/2008-October/024691.html [^]
http://www.cmake.org/pipermail/cmake/2008-October/024652.html [^]
http://www.cmake.org/pipermail/cmake/2008-October/024648.html [^]
http://www.cmake.org/pipermail/cmake/2008-June/022420.html [^]
http://www.cmake.org/pipermail/cmake/2008-June/022386.html [^]
... may be more
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0025578)
Dorian Scholz (reporter)
2011-02-25 07:25

This does not only apply to VS, but also to other (if not all) IDE's.
I'm trying to get this to work on QtCreator.
(0036753)
ptxmac (reporter)
2014-09-09 07:29

Is anyone working on this?
(0037244)
SepticInsect (reporter)
2014-11-21 07:28

Is anyone working on this?
(0037247)
Nils Gladitz (developer)
2014-11-21 11:04

You can use add_custom_target(mytarget SOURCES src1 [src2...]) to add files without compile/build semantics.
(0037256)
SepticInsect (reporter)
2014-11-24 02:53

But I'm using add_custom_command to precompile a pgc-file to a c-file. Then I use the c-file in add_library. But I want QtCreator to find my pgc-file.
(0037257)
Nils Gladitz (developer)
2014-11-24 03:26

@SepticInsect: For that something like add_custom_target(new-target-for-my-pgc-file SOURCES path/to/my/foo.pgc) should work as well.
(0037258)
SepticInsect (reporter)
2014-11-24 03:29

I have tried add_custom_target but it doesn't work the first time I compile, when the c-file doesn't exist.
(0037260)
Nils Gladitz (developer)
2014-11-24 03:33

@SepticInsect: You might want to take the discussion to the user's mailing list.
The add_custom_target() call I suggested did not reference the c-file.
Can you elaborate?
(0037261)
SepticInsect (reporter)
2014-11-24 04:19

Maby I misunderstood you. I thought you meant that I should replace my add_custom_command with an add_custom_target? Or did you mean that I should keep my add_custom_command and add add_custom_target(new-target-for-my-pgc-file SOURCES path/to/my/foo.pgc)? Isn't that an ugly solution? To add and add_custom_target just go get my pgc-file in QtCreator?
(0037262)
Nils Gladitz (developer)
2014-11-24 04:26

@SepticInsect: Yes, I meant an additional custom target (unless you already have an existing custom target which would be appropriate).

Since as far as I can tell there are no compile/build semantics associated with .pgc files you could just as well list it in your add_library() call.
(0037263)
SepticInsect (reporter)
2014-11-24 04:34

Ok. If I do add_library(my_lib file1.c file2.pgc), cmake wouldn't care about file2.pgc and just build my_lib from file1.c?
(0037264)
Nils Gladitz (developer)
2014-11-24 04:37

@SepticInsect: CMake will assert file2.pgc exists and will add it to IDE file listings but will not influence the build beyond that (unless you define/enable a compiler which happens to use the .pgc suffix).
(0037265)
SepticInsect (reporter)
2014-11-24 04:39

Ok. Thanks for all the help!
(0037266)
SepticInsect (reporter)
2014-11-24 05:38
edited on: 2014-11-24 06:56

@ngladitz Is it wrong to add set_source_files_properties(file2.pgc PROPERTIES HEADER_FILE_ONLY TRUE) just to clarify that file2.pgc shall not be built into my_lib?

(0037267)
Nils Gladitz (developer)
2014-11-24 09:40

@SepticInsect: Sounds superfluous in this case but should not hurt either.
(0041151)
Mateusz Loskot (reporter)
2016-06-09 07:37

For anyone who is still looking for the solution to attach non-sources to an IDE project, here is a possible utility:


# collect_info_files function
# Takes collect_info_files - list of non-source files to look for
# Returns INFO_FILES with all files found from the input list.
# Based on macro posted here
# http://lists.qt-project.org/pipermail/qt-creator/2012-August/001191.html [^]
function(collect_info_files)
    list(APPEND _all_found)
    foreach(_it ${ARGN})
        if(NOT IS_DIRECTORY ${_it})
            get_filename_component(_path ${_it} ABSOLUTE)
            if(EXISTS ${_path})
                list(APPEND _all_found ${_it})
                if(NOT ${_it} MATCHES "^/\\\\..*$;~$")
                    set_source_files_properties(${_it} PROPERTIES HEADER_FILE_ONLY TRUE)
                endif()
            endif()
        endif()
    endforeach()
    set(INFO_FILES ${_all_found} PARENT_SCOPE)
endfunction()


and here is the function usage:

# List all non-source code files (documents, configuration files, etc.)
set(other_files .gitignore .travis.yml appveyor.yml README.md)
# Collect all existing files and configure as non-sources.
collect_info_files(${other_files})
# Create dummy target/project for an IDE with documents attached
add_custom_target(docs SOURCES ${INFO_FILES})
(0041456)
Kitware Robot (administrator)
2016-06-10 14:27

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2008-10-20 16:11 Eric NOULARD New Issue
2009-01-08 15:58 Bill Hoffman Status new => assigned
2009-01-08 15:58 Bill Hoffman Assigned To => Bill Hoffman
2011-02-25 07:25 Dorian Scholz Note Added: 0025578
2014-09-09 07:29 ptxmac Note Added: 0036753
2014-11-21 07:28 SepticInsect Note Added: 0037244
2014-11-21 11:04 Nils Gladitz Note Added: 0037247
2014-11-24 02:53 SepticInsect Note Added: 0037256
2014-11-24 03:26 Nils Gladitz Note Added: 0037257
2014-11-24 03:29 SepticInsect Note Added: 0037258
2014-11-24 03:33 Nils Gladitz Note Added: 0037260
2014-11-24 04:19 SepticInsect Note Added: 0037261
2014-11-24 04:26 Nils Gladitz Note Added: 0037262
2014-11-24 04:34 SepticInsect Note Added: 0037263
2014-11-24 04:37 Nils Gladitz Note Added: 0037264
2014-11-24 04:39 SepticInsect Note Added: 0037265
2014-11-24 05:38 SepticInsect Note Added: 0037266
2014-11-24 06:56 SepticInsect Note Edited: 0037266
2014-11-24 09:40 Nils Gladitz Note Added: 0037267
2016-06-09 07:37 Mateusz Loskot Note Added: 0041151
2016-06-10 14:27 Kitware Robot Note Added: 0041456
2016-06-10 14:27 Kitware Robot Status assigned => resolved
2016-06-10 14:27 Kitware Robot Resolution open => moved
2016-06-10 14:30 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team