[CMake] Get target name from command line for IF statement
Attila Krasznahorkay
attila.krasznahorkay at gmail.com
Mon Jan 4 09:26:55 EST 2016
Hi Yann,
I have no idea what LINKER_SCATTER_FILE does, but...
if( TARGET <bla> )
is a check that will evaluate to true if a target named <bla> *exists*. In this configuration neither "target_1" or "target_2" exist at the point when you run this check. So LINKER_SCATTER_FILE will always be set to "file_2".
I think you're mixing what happens when configuring your build, and when actually executing it. In this setup you seem to always want to build both target_1 and target_2. So you'll need to set some property on these targets to assign the different "scatter files" to them. (I have absolutely no idea what a "scatter file" is supposed to be...)
Could you elaborate on what you're really trying to do?
Cheers,
Attila
> On 30 Dec 2015, at 11:29, yann suisini <yannsuisini at gmail.com> wrote:
>
> Hi,
>
> I have a cmake file with 2 targets defined inside.
> For each target I have to specify a different scatter file for my linker
>
> so I want to use :
> if (TARGET target_1)
> SET (LINKER_SCATTER_FILE file_1)
> else ()
> SET (LINKER_SCATTER_FILE file_2)
> endif ()
>
> add_executable(target_1 ${srcs_target_1})
> add_executable(target_2 ${srcs_target_2})
>
>
> But if I'm calling cmake from my IDE to build my target using the --target command line option
> does it set the TARGET variable ? If not the case how I can link the targer name from the command line to my IF statement ?
>
> Regards,
>
> Yann.
>
>
>
>
> --
>
> 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
More information about the CMake
mailing list