Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cmake_minimum_required(VERSION 3.5.1)
- #define project
- set(MATH_SIMULATOR MathSimulator)
- project(${MATH_SIMULATOR})
- set(PROJECT_ROOT_DIR "${${MATH_SIMULATOR}_SOURCE_DIR}")
- #Base QT directory
- set(QT_PATH "home/QT")
- #Build output path of your QT Creator project
- set(QT_BIN "./build-MathSimulator-Desktop_Qt_5_10_1_GCC_64bit-Debug")
- #QT Version used, e.g. Probably found in ${QT_PATH}
- set(QT_VERSION "5.5")
- #Libraries to link to
- set(QT_LIBRARIES Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Charts)
- #Libraries required. Probably the same as above minus the '::'. find_package() will be called on these
- set(QT_LIBRARIES_REQUIRED Qt5Core Qt5Widgets Qt5Gui Qt5Charts) #CANNOT FIND Qt5Charts
- #################################################################
- #Pull needed header files generated by QT first
- set(QT_GENERATED qtGenerated)
- add_custom_target(${QT_GENERATED})
- #Get all header files in the directory
- file(GLOB QT_GEN_HEADERS ${QT_BIN}/*.h)
- #Copy them to the project dir
- foreach(QT_GEN_HEADERS ${QT_GEN_HEADERS})
- add_custom_command(TARGET ${QT_GENERATED} PRE_BUILD COMMAND
- ${CMAKE_COMMAND} -E copy_if_different
- ${QT_GEN_HEADERS} ${CMAKE_SOURCE_DIR})
- endforeach()
- # Find the Qt libraries
- foreach(QT_LIBRARIES_REQUIRED ${QT_LIBRARIES_REQUIRED})
- find_package( ${QT_LIBRARIES_REQUIRED} REQUIRED )
- endforeach()
- #set(QT_GENERATED qtGenerated)
- #add_custom_target(${QT_GENERATED})
- #add_dependencies(${PROJECT_NAME} ${QT_GENERATED})
- #Get all header files in the directory
- file(GLOB QT_GEN_HEADERS ./QtBinDebug542/*.h)
- #Copy them to the project dir
- foreach(QT_GEN_HEADERS ${QT_GEN_HEADERS})
- add_custom_command(TARGET ${QT_GENERATED} PRE_BUILD COMMAND
- ${CMAKE_COMMAND} -E copy_if_different
- ${QT_GEN_HEADERS} ${CMAKE_SOURCE_DIR})
- endforeach()
- file(GLOB QT_CPP_GENERATED ./QtBinDebug542/debug/*.cpp)
- #file(GLOB...) allows for wildcard additions:
- #NOTE: every cmake article I've read suggest to manually list all of the files
- #instead of using GLOBs, because this could lead to weird dependancies.
- #For now leave it as GLOB and before release -> They will be listed.
- file(GLOB SOURCES
- "${PROJECT_ROOT_DIR}/*.cpp"
- "${PROJECT_ROOT_DIR}/utils/*.cpp"
- "${PROJECT_ROOT_DIR}/Charts/*.cpp"
- ${QT_GEN_HEADERS}
- ${QT_CPP_GENERATED})
- #generate engine binary
- add_executable(${MATH_SIMULATOR}
- ${SOURCES})
- #adding -std=c++14 flag
- set_property(TARGET ${MATH_SIMULATOR} PROPERTY CXX_STANDARD 14)
- target_link_libraries(${MATH_SIMULATOR}
- Qt5::Core
- Qt5::Widgets
- Qt5::Gui
- # Qt5::Charts
- m) # -lm flag
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement