From 4ab0b71fa863eab43a44e0d90b1826802ffb00ca Mon Sep 17 00:00:00 2001 From: Bertrand Coconnier <bcoconni@users.sourceforge.net> Date: Sat, 4 Feb 2017 20:21:19 +0100 Subject: [PATCH] The flag ENABLE_SIMD is now automatically carried over from SimGear. Mixed configurations between FG & SG could crash FG so this should not be allowed. --- CMakeLists.txt | 15 ++++++++++++++- tests/test-simd-enabled.c | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/test-simd-enabled.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7742447e6..85df27fa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,7 +178,6 @@ option(SYSTEM_FLITE "Set to ON to build Flightgear with the system's Flite option(SYSTEM_HTS_ENGINE "Set to ON to build Flightgear with the system's HTS Engine library" ${SYSTEM_HTS_ENGINE_DEFAULT}) option(FG_NIGHTLY "Set to ON to mark this as a nightly build" OFF) option(ENABLE_DEV_WARNINGS "Set to ON to include developer-warnings" OFF) -option(ENABLE_SIMD "Enable SSE/SSE2 support for x86 compilers" ON) # additional utilities option(ENABLE_FGELEV "Set to ON to build the fgelev application (default)" ON) @@ -358,6 +357,20 @@ else() message(STATUS "RTI: DISABLED") endif(ENABLE_RTI) +# Check if the flag ENABLE_SIMD was enabled during the compilation of SimGear. +# The same value has to be carried over for FlightGear to prevent crashes. +try_run(ENABLE_SIMD COMPILE_RESULT_TEST_SIMD ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/tests/test-simd-enabled.c) + +if (COMPILE_RESULT_TEST_SIMD AND ENABLE_SIMD + AND NOT (ENABLE_SIMD EQUAL FAILED_TO_RUN)) + set(ENABLE_SIMD ON) + message(STATUS "SSE/SSE2 support: ENABLED") +else() + set(ENABLE_SIMD OFF) + message(STATUS "SSE/SSE2 support: DISABLED") +endif() + if(CMAKE_COMPILER_IS_GNUCXX) set(WARNING_FLAGS_CXX "-Wall") set(WARNING_FLAGS_C "-Wall") diff --git a/tests/test-simd-enabled.c b/tests/test-simd-enabled.c new file mode 100644 index 000000000..20d4e9d54 --- /dev/null +++ b/tests/test-simd-enabled.c @@ -0,0 +1,9 @@ +#include <simgear/simgear_config.h> + +int main(void) { + #ifdef ENABLE_SIMD + return 1; + #else + return 0; + #endif +}