2

You can add multiple dependencies writing

add_dependencies(main_executable lib1 lib2)

but you cannot do so writing

add_dependencies(main_executable "lib1;lib2")
  • Why doesn't CMake accept the second syntax?
  • Why doesn't CMake output any error?

Note that I observe this behavior using the Visual Studio 10 generator. I couldn't test it for other generators but assume CMake will behave equally.

Roland Sarrazin
  • 1,203
  • 11
  • 29
  • 1
    `Doesn't CMake automatically convert the semicolon-separated list into a space-separated list` - there is no space-separated list in CMake sence. **All lists are semicolon-separated**. Parameters to any CMake function/macro are also (semicolon-separated) list. So you need `GENERATOR_LIST` to be like `foo;bar;baz`, not like `foo bar baz`. – Tsyvarev Nov 16 '15 at 23:18
  • Are you sure that your `GENERATOR_LIST` is really a list, as @Tsyvarev has emphasized is semicolon separated? Do you get semicolons between your generator names with `message("${GENERATOR_LIST}")`? I think your first example code to build a list utilizing a cached variable won't work (for details see [here](http://stackoverflow.com/questions/31037882)). For building your global reference list I would recommend something like `set_property(GLOBAL APPEND PROPERTY GENERATOR_LIST MessageGenerator1)` and then `get_property(_generator_list GLOBAL PROPERTY GENERATOR_LIST)`. – Florian Nov 17 '15 at 09:28
  • Btw, to really increase the performance I have recompiled `cmake.exe` itself with all speed optimizations Visual Studio does offer. I've added the following to the CMake's own main `CMakeLists.txt` after the `project()` command: `if (MSVC)`|`set(CMAKE_CXX_FLAGS_RELEASE "/MP /MD /GS /GL /TP /Qpar /Ox /Ot /Ob2 /D NDEBUG" CACHE STRING "" FORCE)`|`set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO" CACHE STRING "" FORCE)`|`endif()` – Florian Nov 17 '15 at 09:58
  • Is your CMake process really that slow? Have you measured what the problem is? Some wise man once said: "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%" – usr1234567 Nov 17 '15 at 12:31
  • @usr1234567: As I wrote in my edit part, I'm more concerned about not understanding why add_dependencies doesn't work with a list rather than about improving the performance. – Roland Sarrazin Nov 17 '15 at 14:37
  • Can you print out the value of _lib and GENERATOR_LIST? – usr1234567 Nov 17 '15 at 14:42
  • I want to reproduce my problem in a smaller (example) project to be sure that it is not related to something else but I cannot do it right now. Thanks to all for your comments so far. – Roland Sarrazin Nov 17 '15 at 15:37
  • Fyi: All previous comments refer to a previous version of the question that didn't emphasize enough that my question is about the add_dependencies command. Thanks for the input so far. – Roland Sarrazin Nov 18 '15 at 14:44

0 Answers0