Roman Khvostikov
Roman Khvostikov

Reputation: 355

How to compile include_external_msproject() dependencies?

I am moving our project repo from MSVC project files to CMake. But one special module I want to leave in .vcxproj. This seem to be possible thanks to include_external_msproject(). There are a number of issues with this command. But the most stopping is that I need to somehow define dependences. Well, I use add_dependencies(). But it seems to be that CMake doesn't enforce dependent module to bi compiled :(

Is there any way to force dependency compilation?

Upvotes: 0

Views: 274

Answers (1)

Peter Tran
Peter Tran

Reputation: 1669

In the include_external_msproject did you list the library dependency at the end? Also are you able to add the dependent library project as a MODULE?

I came across this same problem and here's what fixed it for me:

In the library, e.g. mylib/CMakeLists.txt

add_library(MyLib MODULE ${SOURCES_${TARGET}} ${HEADERS_${TARGET}})

In the project, e.g. myproject/CMakeLists.txt

execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -t:restore myproject.vcxproj)

include_external_msproject(
    MyProject myproject.vcxproj
    MyLib)

Upvotes: 0

Related Questions