add <3.12 support

This commit is contained in:
Viktor Szakats 2025-08-07 00:24:10 +02:00
parent 071528d3fa
commit 860dc6f7c6
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201

View file

@ -33,12 +33,17 @@ set(_all "all")
foreach(_target IN LISTS check_PROGRAMS _all) # keep '_all' last
set(_target_name "curl-example-${_target}")
if(_target STREQUAL "all")
if(CMAKE_VERSION VERSION_LESS 3.12)
continue()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
set(_examples_c "${check_PROGRAMS}")
list(TRANSFORM _examples_c APPEND ".c")
add_library(${_target_name} OBJECT EXCLUDE_FROM_ALL ${_examples_c})
else()
set(_examples_c "")
foreach(_src IN LISTS check_PROGRAMS)
list(APPEND _examples_c "${_src}.c")
endforeach()
add_library(${_target_name} STATIC EXCLUDE_FROM_ALL ${_examples_c})
endif()
set(_examples_c "${check_PROGRAMS}")
list(TRANSFORM _examples_c APPEND ".c")
add_library(${_target_name} OBJECT EXCLUDE_FROM_ALL ${_examples_c})
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
else()