cmake_minimum_required(VERSION 3.25)
project(GarbageCollector C)
set(CMAKE_C_STANDARD 23)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
add_library(collections SHARED IMPORTED)
set_target_properties(collections PROPERTIES
IMPORTED_IMPLIB "lib/Release/Collections.lib"
IMPORTED_LOCATION "bin/Debug/Collections.dll")
add_executable(gc ./main.c)
target_link_libraries(gc collections)
LINK : fatal error LNK1104. says that cant open Collections.lib
when i try to cmake --build build i get LINK : fatal error LNK1104.
Both
IMPORTED_IMPLIBandIMPORTED_LOCATIONrequire full (absolute) paths.If you want to anchor the paths you have to something, see the following variables and use whichever one suits the needs in your context:
CMAKE_SOURCE_DIRPROJECT_SOURCE_DIR<PROJECT-NAME>_SOURCE_DIRCMAKE_CURRENT_SOURCE_DIRCMAKE_CURRENT_LIST_DIREx.