[CMake] Specifying libraries with a variable

Arindam Mukherjee arindam.mukerjee at gmail.com
Tue Oct 2 09:11:10 EDT 2012


Hi,

I want to define a single variable in a top-level CMakeLists.txt and
use it in multiple CMakeLists.txt in sub-directories to specify
target_link_libraries for executables built in these subdirectories. I
tried defining a custom variable in the root CMakeLists.txt and using
it in others but its value doesn't seem to be used.

Tried something:

src/CMakeLists.txt
------------------------
set (MYPROJ_LINK_LIBS, "iconv perfstat mylib")


src/cmd/dsbv/CMakeLists.txt
--------------------------
target_link_libraries(${PROJECT_NAME}, ${MYPROJ_LINK_LIBS})

What's the right way to achieve this?

Thanks,
Arindam


More information about the CMake mailing list