0

Linking against a list of libs using CMake works for me if I put the following lines into CMakeLists.txt:

cmake_minimum_required(VERSION 3.1)

project(HelloWorld)

set( MY_LIBRARIES mylib1 mylib2 mylib3 )

add_executable( HelloWorld HelloWorld.cxx )

target_link_libraries( HelloWorld ${MY_LIBRARIES} )

However, I'm actually storing this list centrally in an environment variable in my .bashrc

export MY_LIBS=mylib1:mylib2:mylib3

in order to have to modify it only once for all projects and also because the Eclipse CDT IDE which I also use sometimes handles this as is without problems.

Now, I just can't get CMake to parse this environment variable properly. I've tried several related approaches from this forum using strings and list conversion, e.g.

string( REPLACE ":" " " MY_LIBRARIES $ENV{MY_LIBS} )

but to no avail. Any help is appreciated!

Greg814
  • 91
  • 8

0 Answers0