[CMake] include_external_msproject, add_dependencies and build type (debug/release)

Holzinger, Axel (ALC NetworX GmbH) Axel.Holzinger at alcnetworx.de
Tue Oct 27 08:06:02 EDT 2015


Hi list,

I'm on my wits end with include_external_msproject, add_dependencies and build type.

This is the situation: I have a CMake project with an external static library A which is included in the build via include_external_msproject, a static library B and a binary C.

B is depemding on A
C is depending on B

My upper (above the directories for B and C) CMakeLists.txt looks like this:

include_external_msproject(A ${CMAKE_SOURCE_DIR}/A.vcxproj)

The CMakeLists.txt for B has these (and other) parts:

cmake_policy(GET CMP0046 cmp)
if (NOT cmp STREQUAL "OLD")
    cmake_policy(SET CMP0046 OLD)
endif ()
add_dependencies (B A)
cmake_policy(SET CMP0046 NEW)
target_link_libraries(B ${CMAKE_BINARY_DIR}/Win32/${CMAKE_BUILD_TYPE}/A.lib)

The CMakeLists.txt for C has these (and other) parts:

target_link_libraries(C B)

In reality there are othe libs too. I reduced complexity to make it easier to understand the scenario.

The stuff above works fine for CMAKE_BUILD_TYPE=Debug, meaning in Visual Studio 2013 in the project build dependencies for B I see that it's depending on A and so the build order is A first then B. The project build dependencies for C say that the binary is depending on B and A and the build oreder is A first, then B and then C.

Perfect.

But with CMAKE_BUILD_TYPE=Release I see that B is depending on A, but C is ONLY depending on B, but NOT on A.

Can anybody explain what's going on? Any hint would be greatly appreciated.

Thank you
Axel

PS: I know that setting policies to OLD isn't the nice way, but I don't know of any other solution the depend on a external Visual Studio project.



More information about the CMake mailing list