How to prevent 'target_link_libraries' from adding visual studio project reference to a static library?
I just started participating in my first cmake project. The project that has many static libraries and a single executable that link them all.
Currently, a typical CMakeLists.txt for one of the static libraries 'this_lib' has this form:
target_include_directories(
this_lib
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
${Boost_INCLUDE_DIRS}
)
target_link_libraries (this_lib PUBLIC
lib1
lib2
lib3
lib4
lib5
${Boost_LIBRARIES}
)
target_link_libraries
adds additional include directories and project dependencies in the form of a visual studio ProjectReference entry in the generated vcxproj file. As a result, the 'this_lib' is not compiled concurrently with the rest of the libraries which greatly increases compile time.
So is there a way to configure target_link_libraries
so it will not add a Project Reference in Visual Studio?
This is what I tried so far:
If I move the parameters from target_link_libraries to target_include_directories, I get compilation errors (missing include) because it seems target_link_libraries operates recursively, meaning it adds include directories of linked libraries as well.