[CMake] Variable target name visible at the top level

Eric Noulard eric.noulard at gmail.com
Fri Oct 26 05:16:04 EDT 2012


2012/10/26 Vyacheslav Karamov <ubuntulist at yandex.ru>:
> Hi All!
>
> I have project with the structure similar to this
>
> worker
>  |     |
>  |     chatterbox
>  |     |    |
>  |     |    CMakeLists.txt
>  |     |
>  |     externals
>  |     |    |
>  |     |    sndlib
>  |     |       |
>  |     |       CMakeLists.txt
>  |     CMakeLists.txt
>  |
>  CMakeLists.txt
>
>
>
> $ cat worker/CMakeLists.txt
>
> cmake_minimum_required(VERSION 2.6)
>
> add_subdirectory(externals)
> add_subdirectory(chatterbox)
>
> If I set sndlib target as a variable
>
> set (snd_lib "sndlib")
> add_library(${snd_lib} SHARED ...)
>
> variable ${snd_lib} is undefined at the parent scope, i.e. I can't use
> ${snd_lib} in chatterbox/ CMakeLists.txt
>
> target_link_libraries(chatterbox  ${snd_lib})  # ${snd_lib} is empty!



More information about the CMake mailing list