summaryrefslogtreecommitdiffstats
path: root/mkspecs/local/CMakeLists.txt
blob: 57549ff98d865ca43691f8c08c5b27cc4431fea9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
macro(type_to_varname _type _varname)
  string( TOUPPER "${_type}" ${_varname} )
  string( REPLACE " " "_" "${${_varname}}" ${_varname} )
  string( REPLACE "*" "P" "${${_varname}}" ${_varname} )
endmacro( type_to_varname )

# A helper macro to determin the type used as socklen_t
macro( check_socklen_t_type _var )
  foreach( _type ${ARGN})
    type_to_varname( "HAVE_${_type}_AS_SOCKLEN_T" _type_var)
    check_cxx_source_compiles(
      "#include <sys/types.h>
      #include <sys/socket.h>
      int main(){
        ${_type} len;
        getpeername(0,0,&len);
      }"
      ${_type_var}
    )
    if( ${_type_var} )
      set( ${_var} ${_type} CACHE INTERNAL "A socklen_t type" )
      break()
    endif()
  endforeach()
endmacro( check_socklen_t_type )

if( UNIX )

  check_symbol_exists( SIG_IGN  "signal.h"          HAVE_SIG_IGN  )
  if( NOT HAVE_SIG_IGN )
    tde_message_fatal( "Systems without SIG_IGN definition are not supported" )
  endif()

  # Check which type we should use as socklen_t
  check_socklen_t_type( QT_SOCKLEN_T socklen_t size_t int )
  if( NOT QT_SOCKLEN_T )
    tde_message_fatal( "Failed to determin typy used as socklen_t" )
  endif()

  check_symbol_exists( snprintf  "stdio.h"          QT_SNPRINTF  )
  check_symbol_exists( vsnprintf "stdarg.h;stdio.h" QT_VSNPRINTF )

  tde_save_and_set( CMAKE_REQUIRED_LIBRARIES "Xext" )
  check_symbol_exists( XShmCreateImage "X11/Xlib.h;X11/extensions/XShm.h" QT_MITSHM )
  tde_restore( CMAKE_REQUIRED_LIBRARIES )

  configure_file( qplatformdefs_unix.h.cmake qplatformdefs.h     @ONLY )
else()
  tde_message_fatal(
    "Unsupported platform"
    "Currently tqt cmake supports autoconfiguration only for unix platforms."
    "Use -DTQT_PLATFORM=platform to specify specify another platform."
  )
endif()

configure_file( qmake.conf.cmake  qmake.conf  @ONLY )

if( BUILD_TQMAKE )
  install(
    FILES
      ${CMAKE_CURRENT_BINARY_DIR}/qplatformdefs.h
      ${CMAKE_CURRENT_BINARY_DIR}/qmake.conf
    DESTINATION "${QT_INSTALL_DATA}/mkspecs/local/"
  )
endif( BUILD_TQMAKE )