Tweak CMake project to include non-buildable files in the CodeBlocks project file

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Tweak CMake project to include non-buildable files in the CodeBlocks project file

Andreas Pakulat-2
Hi,

I'm using QtCreator with CMake and have several files that are included in targets depending on the platform on which I build.

Files that are not enabled on the current platform will not be included by CMake in the CodeBlocks file which in turn is used by QtCreator.

Since QtCreator only picks up files listed in the CodeBlocks project file for its project view I cannot easily open certain files using QtCreator.

I'm wondering wether CMake has a mechanism that would make these files show up in the CodeBlocks project file without them being actually compiled by the project build (I'm using Ninja for that part)? I was thinking of something similar to what can be used to create groups etc. for VS projects.

Andreas

--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Tweak CMake project to include non-buildable files in the CodeBlocks project file

Dario Oliveri
It is very simple for each of the files you want to include in the build (I use txt example so that you know it can work for arbitrary types):

---
set_source_files_properties( comment.txt PROPERTIES HEADER_FILE_ONLY true)
---
then you can include that file in the build to let it shows up in the IDE file

---
#example when adding a static library (works the same also for executables)
add_library( ${arg1} STATIC
    ${sourcefiles}   #files you need to REALLY BUILD
    comment.txt    #this file would be added, but not builded
  )
---

2015-01-11 22:27 GMT+01:00 Andreas Pakulat <[hidden email]>:
Hi,

I'm using QtCreator with CMake and have several files that are included in targets depending on the platform on which I build.

Files that are not enabled on the current platform will not be included by CMake in the CodeBlocks file which in turn is used by QtCreator.

Since QtCreator only picks up files listed in the CodeBlocks project file for its project view I cannot easily open certain files using QtCreator.

I'm wondering wether CMake has a mechanism that would make these files show up in the CodeBlocks project file without them being actually compiled by the project build (I'm using Ninja for that part)? I was thinking of something similar to what can be used to create groups etc. for VS projects.

Andreas

--

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:
http://public.kitware.com/mailman/listinfo/cmake


--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Tweak CMake project to include non-buildable files in the CodeBlocks project file

Andreas Pakulat-2
Hi,

On Sun, Jan 11, 2015 at 10:55 PM, Dario Oliveri <[hidden email]> wrote:
It is very simple for each of the files you want to include in the build (I use txt example so that you know it can work for arbitrary types):

---
set_source_files_properties( comment.txt PROPERTIES HEADER_FILE_ONLY true)
---
then you can include that file in the build to let it shows up in the IDE file

---
#example when adding a static library (works the same also for executables)
add_library( ${arg1} STATIC
    ${sourcefiles}   #files you need to REALLY BUILD
    comment.txt    #this file would be added, but not builded
  )
---

Ah, that works. Its a little ugly in the CMake files but I guess I can live with that. Ideally I was hoping to simply have a 'complete' list including actual sources and sources for other platforms and hand that to a special function - without passing the source-for-other-platform to the actual target. Oh well, I have to stop dreaming :)

Andreas

--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Tweak CMake project to include non-buildable files in the CodeBlocks project file

Nils Gladitz-2
On 01/12/2015 11:40 AM, Andreas Pakulat wrote:
> Ah, that works. Its a little ugly in the CMake files but I guess I can
> live with that. Ideally I was hoping to simply have a 'complete' list
> including actual sources and sources for other platforms and hand that
> to a special function - without passing the source-for-other-platform to
> the actual target. Oh well, I have to stop dreaming :)

You can also use add_custom_target(my_new_target SOURCES src1.cpp src2.cpp).

That will list the given sources in the IDE without adding build
semantics to them.

Since this lists the sources as part of a new target rather than an
existing target this will be visually distinct from the other approach
in some IDEs but should afaik make no difference in QtCreator.

In case you stick with HEADER_FILE_ONLY a custom function() might help
with the ugly.

Nils
--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Tweak CMake project to include non-buildable files in the CodeBlocks project file

Andreas Pakulat-2
Hi Nils,

On Mon, Jan 12, 2015 at 11:50 AM, Nils Gladitz <[hidden email]> wrote:
On 01/12/2015 11:40 AM, Andreas Pakulat wrote:
Ah, that works. Its a little ugly in the CMake files but I guess I can
live with that. Ideally I was hoping to simply have a 'complete' list
including actual sources and sources for other platforms and hand that
to a special function - without passing the source-for-other-platform to
the actual target. Oh well, I have to stop dreaming :)

You can also use add_custom_target(my_new_target SOURCES src1.cpp src2.cpp).

That will list the given sources in the IDE without adding build semantics to them.

Since this lists the sources as part of a new target rather than an existing target this will be visually distinct from the other approach in some IDEs but should afaik make no difference in QtCreator.

Thanks for that idea, having a dedicated target wouldn't be so bad even if its visible. With a bit of restructuring of the cmakelists.txt this may actually make the file quite a bit more 'declarative' and less convoluted.

Andreas 

--

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:
http://public.kitware.com/mailman/listinfo/cmake