cmake: use more COMPILER_OPTIONS, LINK_OPTIONS / LINK_FLAGS

- replace `COMPILE_FLAGS` with `COMPILE_OPTIONS` that superceded it.

  Follow-up to 6140dfcf3e
  https://cmake.org/cmake/help/v4.1/prop_sf/COMPILE_FLAGS.html

- replace `target_link_libraries()` with `LINK_FLAGS` property for
  CMake <=3.12, because we are passing linker options (not libs).

  Follow-up to 91720b620e #18468
  Follow-up to 548873921c #17670
  Follow-up to 95aea798db #5843
  https://cmake.org/cmake/help/v3.7/command/target_link_libraries.html
  https://cmake.org/cmake/help/v3.7/prop_tgt/LINK_FLAGS.html

- replace `target_link_options()` with `LINK_OPTIONS` propery for
  CMake 3.13+, to use the modern style.

  Follow-up to 91720b620e #18468
  Follow-up to 548873921c #17670
  https://cmake.org/cmake/help/v3.13/command/target_link_options.html
  https://cmake.org/cmake/help/v3.13/prop_tgt/LINK_OPTIONS.html

Also:

- fix to append to, not override, previously set linker options when
  using `CURL_LIBCURL_VERSIONED_SYMBOLS=ON`. Before this patch, it was
  overwriting linker options when using `CURL_CODE_COVERAGE=ON`.

  Follow-up to 91720b620e #18468

Closes #18762
This commit is contained in:
Viktor Szakats 2025-09-28 02:34:13 +02:00
parent 81a9197102
commit e17aa98bfe
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
2 changed files with 11 additions and 11 deletions

View file

@ -123,9 +123,9 @@ endif()
if(ENABLE_UNICODE AND MINGW AND NOT MINGW32CE)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(${EXE_NAME} PRIVATE "-municode")
set_property(TARGET ${EXE_NAME} APPEND PROPERTY LINK_OPTIONS "-municode")
else()
target_link_libraries(${EXE_NAME} PRIVATE "-municode")
set_property(TARGET ${EXE_NAME} APPEND PROPERTY LINK_FLAGS "-municode")
endif()
endif()
@ -133,9 +133,9 @@ if(CURL_CODE_COVERAGE)
set_property(TARGET ${EXE_NAME} APPEND PROPERTY COMPILE_DEFINITIONS ${CURL_COVERAGE_MACROS})
set_property(TARGET ${EXE_NAME} APPEND PROPERTY COMPILE_OPTIONS ${CURL_COVERAGE_CFLAGS})
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(${EXE_NAME} PRIVATE ${CURL_COVERAGE_LDFLAGS})
set_property(TARGET ${EXE_NAME} APPEND PROPERTY LINK_OPTIONS ${CURL_COVERAGE_LDFLAGS})
else()
target_link_libraries(${EXE_NAME} PRIVATE ${CURL_COVERAGE_LDFLAGS})
set_property(TARGET ${EXE_NAME} APPEND PROPERTY LINK_FLAGS ${CURL_COVERAGE_LDFLAGS})
endif()
endif()