Problems linking

My project uses some prebuilt lib files which are stored in

C:\Users\amonra\Documents\GitHub\DSS\libs\Win64\DebugLibs
  and
C:\Users\amonra\Documents\GitHub\DSS\libs\Win64\ReleaseLibs

so for example exiv2d.lib is in the DebugLibs folder above.

So I put this in my CMakeLists.txt file:

link_directories(
	../libraw/$<CONFIG>
	../libtiff/$<CONFIG>
	../ZClass/$<CONFIG>	
	"$<$<CONFIG:Debug>:C:/Users/amonra/Documents/GitHub/DSS/libs/Win64/DebugLibs>"
	"$<$<CONFIG:Release>:C:/Users/amonra/Documents/GitHub/DSS/libs/Win64/ReleaseLibs>"
	"$<$<CONFIG:Debug>:C:/Program Files (x86)/Visual Leak Detector/lib/Win64>"
	)
	
    ... stuff omitted

set(ADDITIONAL_LIBRARY_DEPENDENCIES
    "$<$<CONFIG:Debug>:"
        "exiv2d;"
        "libexpatd;"
        "zlibstaticd"
    ">"
    "$<$<CONFIG:Release>:"
        "exiv2;"
        "libexpat;"
        "zlibstatic"
    ">"
    "user32;"
    "psapi;"
    "$(Qt_LIBS_);"
    "htmlhelp;"
    "cfitsio"
)
target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}")

but when I build the project created from that I get:

7>LINK : fatal error LNK1181: cannot open input file 'exiv2d.lib'

Clearly I did that wrong, but what did I mess up?

Thanks, David

Each generator expression must be expressed as one string, not multiple strings. So the definition of variable ADDITIONAL_LIBRARY_DEPENDENCIES seems problematic. Moreover, your usage of semicolon is not judicious. I suggest the following:

set(DEBUG_DEPENDENCIES exiv2d libexpatd zlibstaticd)
set(RELEASE_DEPENDENCIES exiv2 libexpat zlibstatic)

set(ADDITIONAL_LIBRARY_DEPENDENCIES
    "$<$<CONFIG:Debug>:${DEBUG_DEPENDENCIES}>"
    "$<$<CONFIG:Release>:${RELEASE_DEPENDENCIES}>"
    "user32"
    "psapi"
    "$(Qt_LIBS_)"
    "htmlhelp"
    "cfitsio"
)

target_link_libraries(${PROJECT_NAME} PRIVATE ${ADDITIONAL_LIBRARY_DEPENDENCIES})

The set() command naturally build a list when multiple items are specified (not need to specify semicolon). And evaluate the variable ADDITIONAL_LIBRARY_DEPENDENCIES, as part of target_link_libraries() command, without quotes to get the list.

To finish, what is the goal of $(Qt_LIBS_)? Clearly not a CMake variable evaluation.

I made the changes you proposed, so I now have:

link_directories(
	../libraw/$<CONFIG>
	../libtiff/$<CONFIG>
	../ZClass/$<CONFIG>	
	"$<$<CONFIG:Debug>:C:/Users/amonra/Documents/GitHub/DSS/libs/Win64/DebugLibs>"
	"$<$<CONFIG:Release>:C:/Users/amonra/Documents/GitHub/DSS/libs/Win64/ReleaseLibs>"
	"$<$<CONFIG:Debug>:C:/Program Files (x86)/Visual Leak Detector/lib/Win64>"
	)

################################################################################
# Dependencies
################################################################################
# Link with other targets.
target_link_libraries(DeepSkyStacker PRIVATE
    Qt6::Widgets
	Qt6::Network
	DeepSkyStackerKernel
    libraw
    libtiff
    ZClass
)

set(DEBUG_DEPENDENCIES exiv2d libexpatd zlibstaticd)
set(RELEASE_DEPENDENCIES exiv2 libexpat zlibstatic)

set(ADDITIONAL_LIBRARY_DEPENDENCIES
    "$<$<CONFIG:Debug>:${DEBUG_DEPENDENCIES}>"
    "$<$<CONFIG:Release>:${RELEASE_DEPENDENCIES}>"
    "user32"
    "psapi"
    "htmlhelp"
    "cfitsio"
)

It still fails with:

7>LINK : fatal error LNK1181: cannot open input file 'exiv2d.lib'

The Qt_LIBS_ thing was a dropping from a conversion tool that didn’t do as good a job as I’d hoped.

Are you sure that file exiv2d.lib exists in one of your directories?

Yes I am. I actually found the problem I had a duplicate target_link_libraries with some libraries missing from the list in the relevant file. Once i deleted that, things worked a lot better.

David