getopt-win32 provides CMake targets: find_package(getopt CONFIG REQUIRED) target_link_libraries(main PRIVATE $,getopt::getopt_shared,getopt::getopt_static>)