Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 2.76 KB | None | 0 0
  1. cmake_minimum_required(VERSION 3.5.1)
  2.  
  3. #define project
  4. set(MATH_SIMULATOR MathSimulator)
  5. project(${MATH_SIMULATOR})
  6.  
  7. set(PROJECT_ROOT_DIR "${${MATH_SIMULATOR}_SOURCE_DIR}")
  8.  
  9. #Base QT directory
  10. set(QT_PATH "home/QT")
  11.  
  12. #Build output path of your QT Creator project
  13. set(QT_BIN "./build-MathSimulator-Desktop_Qt_5_10_1_GCC_64bit-Debug")
  14.  
  15. #QT Version used, e.g. Probably found in ${QT_PATH}
  16. set(QT_VERSION "5.5")
  17.  
  18. #Libraries to link to
  19. set(QT_LIBRARIES Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Charts)
  20.  
  21. #Libraries required. Probably the same as above minus the '::'. find_package() will be called on these
  22. set(QT_LIBRARIES_REQUIRED Qt5Core Qt5Widgets Qt5Gui Qt5Charts) #CANNOT FIND Qt5Charts
  23. #################################################################
  24.  
  25. #Pull needed header files generated by QT first
  26. set(QT_GENERATED qtGenerated)
  27. add_custom_target(${QT_GENERATED})
  28.  
  29. #Get all header files in the directory
  30. file(GLOB QT_GEN_HEADERS ${QT_BIN}/*.h)
  31.  
  32. #Copy them to the project dir
  33. foreach(QT_GEN_HEADERS ${QT_GEN_HEADERS})
  34.     add_custom_command(TARGET ${QT_GENERATED} PRE_BUILD COMMAND
  35.             ${CMAKE_COMMAND} -E copy_if_different
  36.             ${QT_GEN_HEADERS} ${CMAKE_SOURCE_DIR})
  37. endforeach()
  38.  
  39. # Find the Qt libraries
  40. foreach(QT_LIBRARIES_REQUIRED ${QT_LIBRARIES_REQUIRED})
  41.     find_package( ${QT_LIBRARIES_REQUIRED} REQUIRED )
  42. endforeach()
  43.  
  44. #set(QT_GENERATED qtGenerated)
  45. #add_custom_target(${QT_GENERATED})
  46. #add_dependencies(${PROJECT_NAME} ${QT_GENERATED})
  47.  
  48. #Get all header files in the directory
  49. file(GLOB QT_GEN_HEADERS ./QtBinDebug542/*.h)
  50.  
  51. #Copy them to the project dir
  52. foreach(QT_GEN_HEADERS ${QT_GEN_HEADERS})
  53.     add_custom_command(TARGET ${QT_GENERATED} PRE_BUILD COMMAND
  54.             ${CMAKE_COMMAND} -E copy_if_different
  55.             ${QT_GEN_HEADERS} ${CMAKE_SOURCE_DIR})
  56. endforeach()
  57.  
  58. file(GLOB QT_CPP_GENERATED ./QtBinDebug542/debug/*.cpp)
  59.  
  60. #file(GLOB...) allows for wildcard additions:
  61. #NOTE: every cmake article I've read suggest to manually list all of the files
  62. #instead of using GLOBs, because this could lead to weird dependancies.
  63. #For now leave it as GLOB and before release -> They will be listed.
  64. file(GLOB SOURCES
  65.         "${PROJECT_ROOT_DIR}/*.cpp"
  66.         "${PROJECT_ROOT_DIR}/utils/*.cpp"
  67.         "${PROJECT_ROOT_DIR}/Charts/*.cpp"
  68.         ${QT_GEN_HEADERS}
  69.         ${QT_CPP_GENERATED})
  70.  
  71.  
  72. #generate engine binary
  73. add_executable(${MATH_SIMULATOR}
  74.                ${SOURCES})
  75.  
  76.  
  77. #adding -std=c++14 flag
  78. set_property(TARGET ${MATH_SIMULATOR} PROPERTY CXX_STANDARD 14)
  79.  
  80.  
  81. target_link_libraries(${MATH_SIMULATOR}
  82.                         Qt5::Core
  83.                         Qt5::Widgets
  84.                         Qt5::Gui
  85. #                        Qt5::Charts
  86.                       m)                             # -lm flag
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement