cmake/sdlchecks.cmake
changeset 9414 669bf9fb901e
parent 9409 9df20f292907
child 9415 93547cc94383
equal deleted inserted replaced
9413:eb50f63a5777 9414:669bf9fb901e
   723     endif()
   723     endif()
   724 
   724 
   725   endif()
   725   endif()
   726 endmacro()
   726 endmacro()
   727 
   727 
   728 # Rquires:
   728 # Requires:
   729 # - nada
   729 # - nada
   730 # Optional:
   730 # Optional:
   731 # - THREADS opt
   731 # - THREADS opt
   732 # Sets:
   732 # Sets:
   733 # PTHREAD_CFLAGS
   733 # PTHREAD_CFLAGS
   774       set(PTHREAD_LDFLAGS "-lpthread")
   774       set(PTHREAD_LDFLAGS "-lpthread")
   775     endif()
   775     endif()
   776 
   776 
   777     # Run some tests
   777     # Run some tests
   778     set(CMAKE_REQUIRED_FLAGS "${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
   778     set(CMAKE_REQUIRED_FLAGS "${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
   779     check_c_source_runs("
   779     if(CMAKE_CROSSCOMPILING)
       
   780       set(HAVE_PTHREADS 1)
       
   781     else()
       
   782       check_c_source_runs("
   780         #include <pthread.h>
   783         #include <pthread.h>
   781         int main(int argc, char** argv) {
   784         int main(int argc, char** argv) {
   782           pthread_attr_t type;
   785           pthread_attr_t type;
   783           pthread_attr_init(&type);
   786           pthread_attr_init(&type);
   784           return 0;
   787           return 0;
   785         }" HAVE_PTHREADS)
   788         }" HAVE_PTHREADS)
       
   789     endif()
   786     if(HAVE_PTHREADS)
   790     if(HAVE_PTHREADS)
   787       set(SDL_THREAD_PTHREAD 1)
   791       set(SDL_THREAD_PTHREAD 1)
   788       list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
   792       list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
   789       list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
   793       list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
   790       set(SDL_CFLAGS "${SDL_CFLAGS} ${PTHREAD_CFLAGS}")
   794       set(SDL_CFLAGS "${SDL_CFLAGS} ${PTHREAD_CFLAGS}")
   829 
   833 
   830       check_c_source_compiles("
   834       check_c_source_compiles("
   831           #include <pthread.h>
   835           #include <pthread.h>
   832           #include <pthread_np.h>
   836           #include <pthread_np.h>
   833           int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
   837           int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
   834       check_function_exists(pthread_setname_np HAVE_PTHREAD_setNAME_NP)
   838       check_function_exists(pthread_setname_np HAVE_PTHREAD_SETNAME_NP)
   835       check_function_exists(pthread_set_name_np HAVE_PTHREAD_set_NAME_NP)
   839       check_function_exists(pthread_set_name_np HAVE_PTHREAD_SET_NAME_NP)      set(CMAKE_REQUIRED_FLAGS)
   836       set(CMAKE_REQUIRED_FLAGS)
       
   837 
   840 
   838       set(SOURCE_FILES ${SOURCE_FILES}
   841       set(SOURCE_FILES ${SOURCE_FILES}
   839           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
   842           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
   840           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c   # Can be faked, if necessary
   843           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c   # Can be faked, if necessary
   841           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c    # Can be faked, if necessary
   844           ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c    # Can be faked, if necessary