enable_language(C) if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang") set(CMAKE_LINK_LIBRARY_USING_weak_library "PATH{-weak_library }NAME{LINKER:-weak-l}") set(CMAKE_LINK_LIBRARY_USING_weak_library_SUPPORTED TRUE) else() # feature not yet supported for the other environments set(CMAKE_LINK_LIBRARY_USING_whole_library_SUPPORTED FALSE) endif() add_library(lib SHARED base.c lib.c unref.c) set_property(TARGET lib PROPERTY OUTPUT_NAME base) add_executable(main main.c) target_link_libraries(main PRIVATE "$") add_executable(main2 main.c) target_link_directories(main2 PRIVATE "$") target_link_libraries(main2 PRIVATE "$")