cmake: prefer dash-style MSVC options
They play better with Unixy shells. The compiler has been supporting dash options since its early versions. Also fix to detect warnings options passed in dash-style. Closes #16063
This commit is contained in:
parent
cd9107e012
commit
8dfd271c35
6
.github/workflows/windows.yml
vendored
6
.github/workflows/windows.yml
vendored
@ -686,7 +686,7 @@ jobs:
|
||||
if [ '${{ matrix.plat }}' = 'uwp' ]; then
|
||||
options+=' -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0'
|
||||
cflags='-DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP'
|
||||
ldflags='/OPT:NOREF /OPT:NOICF /APPCONTAINER:NO'
|
||||
ldflags='-OPT:NOREF -OPT:NOICF -APPCONTAINER:NO'
|
||||
vsglobals=';AppxPackage=false;WindowsAppContainer=false'
|
||||
fi
|
||||
cmake -B bld ${options} \
|
||||
@ -694,8 +694,8 @@ jobs:
|
||||
-DVCPKG_INSTALLED_DIR="$VCPKG_INSTALLATION_ROOT/installed" \
|
||||
-DVCPKG_TARGET_TRIPLET='${{ matrix.arch }}-${{ matrix.plat }}' \
|
||||
-DCMAKE_C_FLAGS="${cflags}" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO ${ldflags}" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO ${ldflags}" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-INCREMENTAL:NO ${ldflags}" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="-INCREMENTAL:NO ${ldflags}" \
|
||||
-DCMAKE_VS_GLOBALS="TrackFileAccess=false${vsglobals}" \
|
||||
-DCMAKE_BUILD_TYPE='${{ matrix.type }}' \
|
||||
-DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
|
||||
|
||||
@ -249,7 +249,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND MSVC)
|
||||
if(_ccopt MATCHES "^-W" AND NOT _ccopt STREQUAL "-Wall")
|
||||
list(APPEND _picky_tmp ${_ccopt})
|
||||
else()
|
||||
list(APPEND _picky_tmp "/clang:${_ccopt}")
|
||||
list(APPEND _picky_tmp "-clang:${_ccopt}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(_picky ${_picky_tmp})
|
||||
|
||||
@ -193,8 +193,8 @@ if(WIN32)
|
||||
option(CURL_STATIC_CRT "Build libcurl with static CRT with MSVC (/MT)" OFF)
|
||||
if(CURL_STATIC_CRT AND MSVC)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -MT")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -MTd")
|
||||
endif()
|
||||
|
||||
option(ENABLE_UNICODE "Use the Unicode version of the Windows API functions" OFF)
|
||||
@ -1928,23 +1928,23 @@ endif()
|
||||
|
||||
if(MSVC)
|
||||
# Disable default manifest added by CMake
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -MANIFEST:NO")
|
||||
|
||||
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
if(CMAKE_C_FLAGS MATCHES "[/-]W[0-4]")
|
||||
string(REGEX REPLACE "[/-]W[0-4]" "-W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W4")
|
||||
endif()
|
||||
|
||||
# Use multithreaded compilation on VS2008+
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1500)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CURL_WERROR)
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -WX")
|
||||
else()
|
||||
# This assumes clang or gcc style options
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user