2021-09-03 16:56:57 +00:00
|
|
|
################################################################################
|
|
|
|
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
|
|
|
## ##
|
2022-03-06 16:54:05 +00:00
|
|
|
## Project for working with OpenGL and Qt6 widgets ##
|
2021-09-03 16:56:57 +00:00
|
|
|
################################################################################
|
|
|
|
cmake_minimum_required(VERSION 3.5)
|
|
|
|
|
|
|
|
project(
|
|
|
|
#[[NAME]] Qtk
|
|
|
|
VERSION 1.0
|
|
|
|
DESCRIPTION "An example project using QT and OpenGL"
|
2021-09-12 16:49:59 +00:00
|
|
|
LANGUAGES CXX C
|
2021-09-03 16:56:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2022-03-06 16:54:05 +00:00
|
|
|
#find_package(QT NAMES Qt6 COMPONENTS Widgets REQUIRED)
|
|
|
|
find_package(Qt6 COMPONENTS Widgets OpenGLWidgets OpenGL REQUIRED)
|
2021-09-03 16:56:57 +00:00
|
|
|
|
|
|
|
# Add our Qt resources.qrc file to our application
|
|
|
|
set(SOURCES app/main.cpp)
|
2022-03-06 16:54:05 +00:00
|
|
|
qt6_add_resources(SOURCES resources.qrc)
|
2021-09-03 16:56:57 +00:00
|
|
|
|
|
|
|
add_executable(
|
|
|
|
qtk # Executable name
|
|
|
|
${SOURCES} # Executable source code
|
|
|
|
)
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# External Libraries
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Find and link OpenGL package; Otherwise show an error
|
|
|
|
set(OpenGL_GL_PREFERENCE LEGACY)
|
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
|
|
|
|
# https://github.com/assimp/assimp/commit/6ac8279977c3a54118551e549d77329497116f66
|
|
|
|
find_package(assimp REQUIRED)
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Custom Libraries
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Mainwidget
|
|
|
|
add_library(main-widget lib/mainwidget.cpp)
|
|
|
|
target_include_directories(main-widget PUBLIC lib/)
|
2021-09-12 16:49:59 +00:00
|
|
|
target_include_directories(main-widget PRIVATE ${OPENGL_INCLUDE_DIR})
|
|
|
|
target_link_libraries(main-widget PRIVATE ${OPENGL_LIBRARIES})
|
2021-09-03 16:56:57 +00:00
|
|
|
|
|
|
|
# Input
|
|
|
|
add_library(input lib/input.cpp)
|
|
|
|
target_include_directories(input PUBLIC lib/)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(input PUBLIC Qt${QT_VERSION_MAJOR}::Widgets)
|
2021-09-03 16:56:57 +00:00
|
|
|
|
|
|
|
# Mesh
|
|
|
|
add_library(mesh lib/mesh.cpp)
|
|
|
|
target_include_directories(mesh PUBLIC lib/)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(mesh PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
|
2021-09-03 16:56:57 +00:00
|
|
|
|
|
|
|
# Texture
|
|
|
|
add_library(texture lib/texture.cpp)
|
|
|
|
target_include_directories(texture PUBLIC lib/)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(texture PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
|
2021-09-03 16:56:57 +00:00
|
|
|
|
|
|
|
# Object
|
|
|
|
add_library(object lib/object.cpp)
|
|
|
|
target_include_directories(object PUBLIC lib/)
|
2021-09-19 18:06:41 +00:00
|
|
|
target_link_libraries(object INTERFACE mesh)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(object PUBLIC Qt${QT_VERSION_MAJOR}::OpenGL)
|
|
|
|
target_link_libraries(object PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
|
2021-09-03 16:56:57 +00:00
|
|
|
|
|
|
|
# MeshRenderer
|
|
|
|
add_library(meshrenderer lib/meshrenderer.cpp)
|
|
|
|
target_include_directories(meshrenderer PUBLIC lib/)
|
2021-09-19 18:06:41 +00:00
|
|
|
target_link_libraries(meshrenderer PUBLIC object)
|
2021-09-03 16:56:57 +00:00
|
|
|
|
2021-09-12 16:49:59 +00:00
|
|
|
# Camera3D
|
|
|
|
add_library(camera3d lib/camera3d.cpp)
|
|
|
|
target_include_directories(camera3d PUBLIC lib/)
|
2021-09-19 18:06:41 +00:00
|
|
|
target_link_libraries(camera3d INTERFACE input)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(camera3d PUBLIC Qt${QT_VERSION_MAJOR}::Widgets)
|
2021-09-12 16:49:59 +00:00
|
|
|
|
2021-09-03 16:56:57 +00:00
|
|
|
# Skybox
|
|
|
|
add_library(skybox lib/skybox.cpp)
|
2022-03-06 16:54:05 +00:00
|
|
|
# Skybox needs Mesh, Camera3D, and Qt6::Widgets
|
2021-09-03 16:56:57 +00:00
|
|
|
target_link_libraries(skybox PRIVATE mesh)
|
|
|
|
target_link_libraries(skybox PRIVATE camera3d)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(skybox PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
|
2021-09-03 16:56:57 +00:00
|
|
|
|
2021-09-12 16:49:59 +00:00
|
|
|
# Transform3D
|
|
|
|
add_library(transform3d lib/transform3D.cpp)
|
|
|
|
target_include_directories(transform3d PUBLIC lib/)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(transform3d PUBLIC Qt${QT_VERSION_MAJOR}::Widgets)
|
2021-09-12 16:49:59 +00:00
|
|
|
|
|
|
|
# Model
|
|
|
|
add_library(model lib/model.cpp)
|
|
|
|
target_include_directories(model PUBLIC lib/)
|
|
|
|
target_link_libraries(model PRIVATE assimp)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(model PUBLIC Qt${QT_VERSION_MAJOR}::OpenGL)
|
|
|
|
# Model library requires transform3d and Qt6::Widgets
|
2021-09-12 16:49:59 +00:00
|
|
|
target_link_libraries(model PUBLIC transform3d)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(model PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
|
2021-09-12 16:49:59 +00:00
|
|
|
|
2021-09-19 18:06:41 +00:00
|
|
|
# Scene
|
|
|
|
add_library(scene lib/scene.cpp)
|
|
|
|
target_include_directories(scene PUBLIC lib/)
|
|
|
|
target_link_libraries(scene PUBLIC model)
|
|
|
|
target_link_libraries(scene PUBLIC meshrenderer)
|
|
|
|
target_link_libraries(scene PUBLIC skybox)
|
|
|
|
target_link_libraries(scene PUBLIC texture)
|
2022-03-06 16:54:05 +00:00
|
|
|
target_link_libraries(scene PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
|
2021-09-19 18:06:41 +00:00
|
|
|
|
2021-09-12 16:49:59 +00:00
|
|
|
|
2021-09-03 16:56:57 +00:00
|
|
|
################################################################################
|
|
|
|
# Final Application
|
|
|
|
################################################################################
|
|
|
|
|
2021-09-12 16:49:59 +00:00
|
|
|
target_link_libraries(main-widget PRIVATE mesh)
|
2021-09-19 18:06:41 +00:00
|
|
|
target_link_libraries(main-widget PUBLIC scene)
|
2021-09-03 16:56:57 +00:00
|
|
|
|
|
|
|
# Link qtk executable to main main-widget library
|
|
|
|
target_link_libraries(qtk PUBLIC main-widget)
|