Skip to content

Instantly share code, notes, and snippets.

@jedbrown
Last active December 26, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedbrown/7062540 to your computer and use it in GitHub Desktop.
Save jedbrown/7062540 to your computer and use it in GitHub Desktop.
CMake crash when passing linker flags containing comma
int bar() {return 0;}
cmake_minimum_required(VERSION 2.8)
project(foo)
add_library(foo foo.cc)
target_link_libraries(foo ${DEP_LIBS})
add_library(bar bar.cc)
target_link_libraries(bar foo)
int foo() {return 0;}
@jedbrown
Copy link
Author

$ mkdir build && cd build
$ cmake -DDEP_LIBS:STRING='-Wl,--start-group -llapack -lblas -Wl,--end-group' ..
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
CMake Error:
  Error evaluating generator expression:

    $<LINK_ONLY:-Wl,--start-group -llapack -lblas -Wl,--end-group>

  $<LINK_ONLY> expression requires exactly one parameter.

CMake Warning (dev) in CMakeLists.txt:
  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  Static library target "foo" has a INTERFACE_LINK_LIBRARIES property.  This
  should be preferred as the source of the link interface for this library.
  Ignoring the property and using the link implementation as the link
  interface instead.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /tmp/cmake-comma/build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment