Fix CMake CMAKE_REQUIRED_FLAGS handling to preserve existing CMake flags required by Emscripten toolchain.
authorJukka Jylänki <jujjyl@gmail.com>
Tue, 13 Sep 2016 00:03:50 -0700
changeset 10329ad0bee16b6b9
parent 10328 3e6cd603c977
child 10330 6928ce726856
Fix CMake CMAKE_REQUIRED_FLAGS handling to preserve existing CMake flags required by Emscripten toolchain.
CMakeLists.txt
cmake/sdlchecks.cmake
     1.1 --- a/CMakeLists.txt	Tue Sep 13 00:03:49 2016 -0700
     1.2 +++ b/CMakeLists.txt	Tue Sep 13 00:03:50 2016 -0700
     1.3 @@ -205,7 +205,7 @@
     1.4  if(CYGWIN)
     1.5    # We build SDL on cygwin without the UNIX emulation layer
     1.6    include_directories("-I/usr/include/mingw")
     1.7 -  set(CMAKE_REQUIRED_FLAGS "-mno-cygwin")
     1.8 +  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mno-cygwin")
     1.9    check_c_source_compiles("int main(int argc, char **argv) {}"
    1.10      HAVE_GCC_NO_CYGWIN)
    1.11    set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
     2.1 --- a/cmake/sdlchecks.cmake	Tue Sep 13 00:03:49 2016 -0700
     2.2 +++ b/cmake/sdlchecks.cmake	Tue Sep 13 00:03:50 2016 -0700
     2.3 @@ -766,7 +766,8 @@
     2.4      endif()
     2.5  
     2.6      # Run some tests
     2.7 -    set(CMAKE_REQUIRED_FLAGS "${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
     2.8 +    set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
     2.9 +    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
    2.10      if(CMAKE_CROSSCOMPILING)
    2.11        set(HAVE_PTHREADS 1)
    2.12      else()
    2.13 @@ -828,7 +829,7 @@
    2.14            int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
    2.15        check_function_exists(pthread_setname_np HAVE_PTHREAD_SETNAME_NP)
    2.16        check_function_exists(pthread_set_name_np HAVE_PTHREAD_SET_NAME_NP)
    2.17 -      set(CMAKE_REQUIRED_FLAGS)
    2.18 +      set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
    2.19  
    2.20        set(SOURCE_FILES ${SOURCE_FILES}
    2.21            ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
    2.22 @@ -882,7 +883,8 @@
    2.23      endif()
    2.24    endif()
    2.25  
    2.26 -  set(CMAKE_REQUIRED_FLAGS "${USB_CFLAGS}")
    2.27 +  set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
    2.28 +  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${USB_CFLAGS}")
    2.29    set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}")
    2.30    check_c_source_compiles("
    2.31         #include <sys/types.h>
    2.32 @@ -983,7 +985,7 @@
    2.33      set(HAVE_SDL_JOYSTICK TRUE)
    2.34  
    2.35      set(CMAKE_REQUIRED_LIBRARIES)
    2.36 -    set(CMAKE_REQUIRED_FLAGS)
    2.37 +    set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
    2.38    endif()
    2.39  endmacro()
    2.40  
    2.41 @@ -997,12 +999,13 @@
    2.42      listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
    2.43      listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
    2.44  
    2.45 -    set(CMAKE_REQUIRED_FLAGS "${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
    2.46 +    set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
    2.47 +    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
    2.48      set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBS}")
    2.49      check_c_source_compiles("
    2.50          #include <bcm_host.h>
    2.51          int main(int argc, char **argv) {}" HAVE_VIDEO_RPI)
    2.52 -    set(CMAKE_REQUIRED_FLAGS)
    2.53 +    set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
    2.54      set(CMAKE_REQUIRED_LIBRARIES)
    2.55  
    2.56      if(SDL_VIDEO AND HAVE_VIDEO_RPI)