try workaround for VS generator and warnings

This commit is contained in:
Viktor Szakats 2025-08-07 17:22:18 +02:00
parent 860dc6f7c6
commit 0d5d17adfc
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201

View file

@ -46,6 +46,17 @@ foreach(_target IN LISTS check_PROGRAMS _all) # keep '_all' last
endif()
add_custom_target(curl-examples-build) # Special target to compile all tests quickly and build a single test to probe linkage
add_dependencies(curl-examples-build ${_target_name} ${_all_plus_one}) # Include a full build of a single test
if(MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
# CMake generates a static library for the OBJECT target. Which triggers warnings:
# warning LNK4006: main already defined in ....obj; second definition ignored
# warning LNK4221: This object file does not define any previously undefined public symbols,
# so it will not be used by any link operation that consumes this library
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(curl-examples-build PRIVATE "-ignore:4006" "-ignore:4221")
else()
target_link_libraries(curl-examples-build PRIVATE "-ignore:4006" "-ignore:4221")
endif()
endif()
else()
set(_all_plus_one ${_target_name}) # Save the last test for the curl-examples-build target
add_executable(${_target_name} EXCLUDE_FROM_ALL "${_target}.c")