This is unfortunately not possible. In a nutshell, my setup is as follows:
## top_level/CMakeLists.txt:
set_property(GLOBAL PROPERTY my_project_list
${variable_defined_on_command_line})
get_property(projects GLOBAL PROPERTY my_project_list)
while(projects)
set_property(GLOBAL PROPERTY my_project_list "")
foreach(proj IN LISTS projects)
add_subdirectory(${proj}) # this can add projects to
my_project_list global property and/or modify my_istallations global
property
endforeach()
endwhile()
install(TARGETS ${some_targets_defined_in_subdirectories} DESTINATION
${something_which_depends_on_global_property_my_installations})
##
As a workaround, I am currently using install(PROGRAMS
path_to_target's_output ...), but if there is a way to use the actual
target, I would prefer it.
Petr
On Thu, Apr 26, 2012 at 3:14 PM, David Cole wrote:
> If it really "depends on stuff which happens" then the
> add_subdirectory call should be "after that stuff"
>
>
> On Thu, Apr 26, 2012 at 2:54 AM, Petr Kmoch wrote:
>> Hi all,
>>
>> I have a rather complex setup with multiple subdirectories under one
>> top-level CMakeLists.txt file. I need to install some targets defined
>> in subdirectories, but the destination of the install is not known at
>> the time the subdirectory is processed (it potentially depends on
>> stuff which happens in the top-level CMakeLists.txt after the
>> subdirectories are added).
>>
>> Is there a way to do this? When I simply tried putting the
>> install(TARGETS ...) commands into the top-level CMakeLists.txt, it
>> complained along the lines of "no such target in current directory."
>>
>> Thanks in advance for any replies.
>>
>> Petr
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake