1
0
Fork 0

Fix: [CMake] restore CMAKE_REQUIRED_FLAGS if you change it

pull/13393/head
Patric Stout 2025-01-27 19:59:57 +01:00
parent 3dc12e3d65
commit bc07695a3e
3 changed files with 9 additions and 0 deletions

View File

@ -2,6 +2,7 @@
# SSE version (SSE 2.0, SSSE 3.0). # SSE version (SSE 2.0, SSSE 3.0).
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "") set(CMAKE_REQUIRED_FLAGS "")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
@ -15,3 +16,5 @@ check_cxx_source_compiles("
int main() { return 0; }" int main() { return 0; }"
SSE_FOUND SSE_FOUND
) )
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})

View File

@ -1,6 +1,7 @@
# Autodetect if xaudio2 can be used. # Autodetect if xaudio2 can be used.
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "") set(CMAKE_REQUIRED_FLAGS "")
check_cxx_source_compiles(" check_cxx_source_compiles("
@ -17,3 +18,5 @@ check_cxx_source_compiles("
int main() { printf(\"%s\\\\n\", XAUDIO2_DLL_A); return 0; }" int main() { printf(\"%s\\\\n\", XAUDIO2_DLL_A); return 0; }"
XAUDIO2_FOUND XAUDIO2_FOUND
) )
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})

View File

@ -1,6 +1,7 @@
# LibLZMA is a custom addition to the emscripten SDK, so it is possible # LibLZMA is a custom addition to the emscripten SDK, so it is possible
# someone patched their SDK. Test out if the SDK supports LibLZMA. # someone patched their SDK. Test out if the SDK supports LibLZMA.
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "--use-port=contrib.liblzma") set(CMAKE_REQUIRED_FLAGS "--use-port=contrib.liblzma")
check_cxx_source_compiles(" check_cxx_source_compiles("
@ -18,3 +19,5 @@ if (LIBLZMA_FOUND)
else() else()
message(WARNING "You are using an emscripten SDK without LibLZMA support. Many savegames won't be able to load in OpenTTD. Please copy liblzma.py to your ports/contrib folder in your local emsdk installation.") message(WARNING "You are using an emscripten SDK without LibLZMA support. Many savegames won't be able to load in OpenTTD. Please copy liblzma.py to your ports/contrib folder in your local emsdk installation.")
endif() endif()
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})