CMakeExternalLibs.cmake 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # ------------------------------------------------------------------------------
  2. # Qt
  3. # ------------------------------------------------------------------------------
  4. set( CMAKE_AUTOMOC ON )
  5. set( CMAKE_AUTORCC ON )
  6. # FIXME Eventually turn this on when we've completed the move to targets
  7. #set( CMAKE_AUTOUIC ON )
  8. set( QT5_ROOT_PATH CACHE PATH "Qt5 root directory (i.e. where the 'bin' folder lies)" )
  9. if ( QT5_ROOT_PATH )
  10. list( APPEND CMAKE_PREFIX_PATH ${QT5_ROOT_PATH} )
  11. endif()
  12. find_package( Qt5
  13. COMPONENTS
  14. Concurrent
  15. Core
  16. Gui
  17. OpenGL
  18. OpenGLExtensions
  19. PrintSupport
  20. Svg
  21. Widgets
  22. REQUIRED
  23. )
  24. # in the case no Qt5Config.cmake file could be found, cmake will explicitly ask the user for the QT5_DIR containing it!
  25. # thus no need to keep additional variables and checks
  26. # Starting with the QtCore lib, find the bin and root directories
  27. get_target_property( Qt5_LIB_LOCATION Qt5::Core LOCATION_${CMAKE_BUILD_TYPE} )
  28. get_filename_component( Qt5_LIB_LOCATION ${Qt5_LIB_LOCATION} DIRECTORY )
  29. if ( WIN32 )
  30. get_target_property( QMAKE_LOCATION Qt5::qmake IMPORTED_LOCATION )
  31. get_filename_component( Qt5_BIN_DIR ${QMAKE_LOCATION} DIRECTORY )
  32. get_filename_component( QT5_ROOT_PATH "${Qt5_BIN_DIR}/.." ABSOLUTE )
  33. endif()
  34. # turn on QStringBuilder for more efficient string construction
  35. # see https://doc.qt.io/qt-5/qstring.html#more-efficient-string-construction
  36. add_definitions( -DQT_USE_QSTRINGBUILDER )
  37. # ------------------------------------------------------------------------------
  38. # OpenGL
  39. # ------------------------------------------------------------------------------
  40. if ( UNIX )
  41. set(OpenGL_GL_PREFERENCE GLVND)
  42. endif()
  43. if ( MSVC )
  44. # Where to find OpenGL libraries
  45. set(WINDOWS_OPENGL_LIBS "C:\\Program Files (x86)\\Windows Kits\\8.0\\Lib\\win8\\um\\x64" CACHE PATH "WindowsSDK libraries" )
  46. list( APPEND CMAKE_PREFIX_PATH ${WINDOWS_OPENGL_LIBS} )
  47. endif()
  48. # ------------------------------------------------------------------------------
  49. # OpenMP
  50. # ------------------------------------------------------------------------------
  51. if ( NOT APPLE )
  52. find_package(OpenMP QUIET)
  53. if (OPENMP_FOUND)
  54. message(STATUS "OpenMP found")
  55. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  56. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  57. endif()
  58. endif()