[cmake-developers] Changing FOLDER property of ALL_BUILD and RUN_TESTS targets in VS

2016-04-12 Thread Robert Dailey
I have the following CMake code:

get_property( predefined_folder GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER )

set_target_properties( ALL_BUILD PROPERTIES FOLDER ${predefined_folder} )

if( BUILD_TESTING )
set_target_properties( RUN_TESTS PROPERTIES FOLDER "Testing" )
endif()

However this fails stating those targets do not exist. Is there a way
I can make this work? I'd like to organize these CMake targets in my
own way in the Visual Studio solution. There have been topics
regarding this on the mailing list in the past, but they have gone
unanswered.

Specifically, why are these targets treated as if they do not exist?
Does CMake only allow you to set properties on targets created
directly by the scripts themselves (i.e. no built-in targets can be
affected)?

I'm happy to contribute a patch to this if needed.

Thanks in advance.
-- 

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-developers


Re: [cmake-developers] Changing FOLDER property of ALL_BUILD and RUN_TESTS targets in VS

2016-04-12 Thread Brad King
On 04/12/2016 02:54 PM, Robert Dailey wrote:
> set_target_properties( ALL_BUILD PROPERTIES FOLDER ${predefined_folder} )
> 
> if( BUILD_TESTING )
> set_target_properties( RUN_TESTS PROPERTIES FOLDER "Testing" )
> endif()
> 
> However this fails stating those targets do not exist.

They don't exist because they are not created until generate-time.

FYI recent changes in 'master' move ALL_BUILD into the predefined
targets folder.

> Does CMake only allow you to set properties on targets created
> directly by the scripts themselves (i.e. no built-in targets can be
> affected)?

Correct.  See above.  This is not trivial to change because the
ALL_BUILD, INSTALL, etc. targets are not normal targets.
Internally they have type GLOBAL_TARGET.  There can be *multiple*
such targets of the same name created by the generators.  Each
directory whose CMakeLists.txt file calls project(SomeName) gets
a SomeName.sln in VS, for example.  Each such .sln has a different
ALL_BUILD target with its own dependencies.  The generators can
get away with this because nothing ever looks up these targets
by name.  Therefore trying to present such targets to CMake
project code is not well-defined.

-Brad

-- 

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-developers