mirror of
https://github.com/curl/curl.git
synced 2025-04-12 16:20:35 +08:00
cmake: misc tidy-ups
- replace `add_compile_options()`, `add_definitions()` with directory properties. To harmonize this across all scripts. The new commands are verbose, but describe better how they work. The syntax is also closer to setting target properties, helps grepping. - prefer `CMAKE_INSTALL_PREFIX` over `--prefix` (in tests, CI). - tidy up cmake invocations. - formatting. Closes #16238
This commit is contained in:
parent
ca2f49ded0
commit
45f7cb7695
3
.github/workflows/linux.yml
vendored
3
.github/workflows/linux.yml
vendored
@ -589,6 +589,7 @@ jobs:
|
||||
fi
|
||||
if [ -n '${{ matrix.build.generate }}' ]; then
|
||||
cmake -B . -G Ninja \
|
||||
-DCMAKE_INSTALL_PREFIX="$HOME/curl" \
|
||||
-DCMAKE_C_COMPILER_TARGET=$(uname -m)-pc-linux-gnu -DBUILD_STATIC_LIBS=ON \
|
||||
-DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON -DCURL_WERROR=ON \
|
||||
${{ matrix.build.generate }}
|
||||
@ -637,7 +638,7 @@ jobs:
|
||||
|
||||
- name: 'cmake install'
|
||||
if: ${{ matrix.build.generate }}
|
||||
run: cmake --install . --prefix $HOME/curl --strip
|
||||
run: cmake --install . --strip
|
||||
|
||||
- name: 'build tests'
|
||||
if: ${{ matrix.build.install_steps != 'skipall' }}
|
||||
|
2
.github/workflows/non-native.yml
vendored
2
.github/workflows/non-native.yml
vendored
@ -311,7 +311,7 @@ jobs:
|
||||
https://github.com/libressl/portable/releases/download/v${{ env.libressl-version }}/libressl-${{ env.libressl-version }}.tar.gz | tar -x
|
||||
cd libressl-${{ env.libressl-version }}
|
||||
# FIXME: on the 4.0.1 release, delete '-DHAVE_ENDIAN_H=0'
|
||||
cmake . \
|
||||
cmake -B . \
|
||||
-DHAVE_ENDIAN_H=0 \
|
||||
-DCMAKE_INSTALL_PREFIX="$HOME/libressl" \
|
||||
-DCMAKE_SYSTEM_NAME=iOS \
|
||||
|
@ -202,9 +202,9 @@ if(WIN32)
|
||||
set(ENABLE_UNICODE ON)
|
||||
endif()
|
||||
if(ENABLE_UNICODE)
|
||||
add_definitions("-DUNICODE" "-D_UNICODE")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "UNICODE" "_UNICODE")
|
||||
if(MINGW)
|
||||
add_compile_options("-municode")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-municode")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -216,7 +216,7 @@ if(WIN32)
|
||||
|
||||
set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string")
|
||||
if(CURL_TARGET_WINDOWS_VERSION)
|
||||
add_definitions("-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}")
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}") # Apply to all feature checks
|
||||
endif()
|
||||
|
||||
@ -513,7 +513,7 @@ endif()
|
||||
|
||||
# If we are on AIX, do the _ALL_SOURCE magic
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
|
||||
add_definitions("-D_ALL_SOURCE")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_ALL_SOURCE")
|
||||
endif()
|
||||
|
||||
# If we are on Haiku, make sure that the network library is brought in.
|
||||
@ -605,8 +605,8 @@ if(ENABLE_IPV6)
|
||||
if(WIN32)
|
||||
check_struct_has_member("struct sockaddr_in6" "sin6_scope_id" "winsock2.h;ws2tcpip.h" HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
|
||||
else()
|
||||
check_struct_has_member("struct sockaddr_in6" "sin6_addr" "netinet/in.h" HAVE_SOCKADDR_IN6_SIN6_ADDR)
|
||||
check_struct_has_member("struct sockaddr_in6" "sin6_scope_id" "netinet/in.h" HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
|
||||
check_struct_has_member("struct sockaddr_in6" "sin6_addr" "netinet/in.h" HAVE_SOCKADDR_IN6_SIN6_ADDR)
|
||||
if(NOT HAVE_SOCKADDR_IN6_SIN6_ADDR)
|
||||
if(NOT DOS AND NOT AMIGA)
|
||||
message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support")
|
||||
@ -1932,7 +1932,7 @@ endif()
|
||||
|
||||
include(CMake/OtherTests.cmake)
|
||||
|
||||
add_definitions("-DHAVE_CONFIG_H")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "HAVE_CONFIG_H")
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND CURL_LIBS "ws2_32" "bcrypt")
|
||||
|
@ -56,7 +56,7 @@ if [ "${BUILD_SYSTEM}" = 'CMake' ]; then
|
||||
[ "${PRJ_CFG}" = 'Release' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE='
|
||||
[[ "${PRJ_GEN}" = *'Visual Studio'* ]] && options+=' -DCMAKE_VS_GLOBALS=TrackFileAccess=false'
|
||||
# shellcheck disable=SC2086
|
||||
cmake -B "_bld${_chkprefill}" "-G${PRJ_GEN}" ${TARGET} \
|
||||
cmake -B "_bld${_chkprefill}" -G "${PRJ_GEN}" ${TARGET} \
|
||||
-DCURL_USE_OPENSSL="${OPENSSL}" \
|
||||
-DCURL_USE_SCHANNEL="${SCHANNEL}" \
|
||||
-DHTTP_ONLY="${HTTP_ONLY}" \
|
||||
|
@ -251,7 +251,7 @@ You can build curl with cmake:
|
||||
% cd ..
|
||||
% git clone https://github.com/curl/curl
|
||||
% cd curl
|
||||
% cmake . -B bld -DCURL_USE_OPENSSL=ON -DUSE_OPENSSL_QUIC=ON
|
||||
% cmake -B bld -DCURL_USE_OPENSSL=ON -DUSE_OPENSSL_QUIC=ON
|
||||
% cmake --build bld
|
||||
% cmake --install bld
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
###########################################################################
|
||||
set(LIB_NAME "libcurl")
|
||||
set(LIBCURL_OUTPUT_NAME "libcurl" CACHE STRING "Basename of the curl library")
|
||||
add_definitions("-DBUILDING_LIBCURL")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "BUILDING_LIBCURL")
|
||||
|
||||
configure_file("curl_config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h")
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#
|
||||
###########################################################################
|
||||
set(EXE_NAME curl)
|
||||
add_definitions("-DBUILDING_CURL")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "BUILDING_CURL")
|
||||
|
||||
set(_curl_cfiles_gen "")
|
||||
set(_curl_hfiles_gen "")
|
||||
|
@ -28,9 +28,9 @@ fi
|
||||
|
||||
if [ "${mode}" = 'all' ] || [ "${mode}" = 'find_package' ]; then
|
||||
rm -rf bld-curl
|
||||
cmake ../.. -B bld-curl
|
||||
cmake ../.. -B bld-curl -DCMAKE_INSTALL_PREFIX="${PWD}/bld-curl/_pkg"
|
||||
cmake --build bld-curl
|
||||
cmake --install bld-curl --prefix bld-curl/_pkg
|
||||
cmake --install bld-curl
|
||||
rm -rf bld-find_package
|
||||
cmake -B bld-find_package \
|
||||
-DTEST_INTEGRATION_MODE=find_package \
|
||||
|
Loading…
x
Reference in New Issue
Block a user