diff --git a/CMakeLists.txt b/CMakeLists.txt index 48b8863..31c280b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_compile_options(/wd4131 /wd4127) endif() +message(STATUS "[Qtk]: Compiling with ${CMAKE_CXX_COMPILER_ID}") # Qtk build options option(QTK_DEBUG "Enable debugger" ON) @@ -46,11 +47,12 @@ list(APPEND CMAKE_PREFIX_PATH "${QT_DIR}") # Find Qt find_package(Qt6 COMPONENTS OpenGLWidgets) if (NOT Qt6_FOUND) - message(SEND_ERROR "Unable to find Qt6 at CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") - message(FATAL_ERROR "Specify path to Qt6 with `cmake -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x.x/gcc_64 -S /path/to/qtk -B /path/to/qtk/build && cmake --build /path/to/qtk/build -j $(nprocs)`") + message(SEND_ERROR "[Qtk] Error: Unable to find Qt6 at CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") + message(FATAL_ERROR "[Qtk] Error: Specify path to Qt6 with `cmake -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x.x/gcc_64 -S /path/to/qtk -B /path/to/qtk/build && cmake --build /path/to/qtk/build -j $(nprocs)`") endif() if (UPDATE_SUBMODULES) + message(STATUS "[Qtk]: Updating submodules...") include("${CMAKE_SOURCE_DIR}/cmake/include/git_submodule.cmake") submodule_update(extern/assimp/assimp/) add_subdirectory(extern/assimp/assimp) @@ -61,33 +63,35 @@ endif() # Qtk ################################################################################ -set(PUBLIC_HEADERS - src/mainwidget.h - src/abstractscene.h - src/camera3d.h - src/mesh.h - src/meshrenderer.h - src/model.h - src/object.h - src/skybox.h - src/texture.h - src/transform3D.h +set( + PUBLIC_HEADERS + src/mainwidget.h + src/abstractscene.h + src/camera3d.h + src/mesh.h + src/meshrenderer.h + src/model.h + src/object.h + src/skybox.h + src/texture.h + src/transform3D.h ) -set(SOURCE_FILES - src/mainwidget.cpp - src/abstractscene.cpp - src/camera3d.cpp - src/input.cpp - src/input.h - src/mesh.cpp - src/meshrenderer.cpp - src/model.cpp - src/object.cpp - src/qtkapi.h - src/skybox.cpp - src/texture.cpp - src/transform3D.cpp +set( + SOURCE_FILES + src/mainwidget.cpp + src/abstractscene.cpp + src/camera3d.cpp + src/input.cpp + src/input.h + src/mesh.cpp + src/meshrenderer.cpp + src/model.cpp + src/object.cpp + src/qtkapi.h + src/skybox.cpp + src/texture.cpp + src/transform3D.cpp ) include(GenerateExportHeader) @@ -108,6 +112,7 @@ elseif(ASSIMP_NEW_INTERFACE) endif() if(QTK_DEBUG) + message(STATUS "[Qtk]: Building with QTK_DEBUG=${QTK_DEBUG}") target_compile_definitions(qtk-widget PUBLIC QTK_DEBUG) endif() @@ -142,20 +147,19 @@ install(EXPORT qtk-export # Final Application ################################################################################ -file( - WRITE ${CMAKE_CURRENT_BINARY_DIR}/resources.h - "#ifndef QTK_RESOURCES_H\n" - "#define QTK_RESOURCES_H\n" - "#define QTK_RESOURCES_DIR \"${CMAKE_SOURCE_DIR}/resources\"\n" - "#endif\n" +set(QTK_RESOURCES "${CMAKE_SOURCE_DIR}/resources") +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/src/qtkresources.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/src/qtkresources.h" + @ONLY ) # Add our Qt resources.qrc file to our application set(QTK_APP_SOURCES app/main.cpp app/mainwindow.cpp app/mainwindow.h app/mainwindow.ui app/scene.cpp app/scene.h - app/resourcemanager.cpp app/resourcemanager.h - ${CMAKE_CURRENT_BINARY_DIR}/resources.h + app/resourcemanager.h + src/qtkresources.h.in ) qt6_add_big_resources(QTK_APP_SOURCES resources.qrc) diff --git a/app/resourcemanager.cpp b/app/resourcemanager.cpp deleted file mode 100644 index f17ce50..0000000 --- a/app/resourcemanager.cpp +++ /dev/null @@ -1,9 +0,0 @@ -/*############################################################################## -## Author: Shaun Reed ## -## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ## -## About: Manage files and resources used by qtk ## -## ## -## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## -##############################################################################*/ - -#include diff --git a/app/resourcemanager.h b/app/resourcemanager.h index b702720..df2f5d7 100644 --- a/app/resourcemanager.h +++ b/app/resourcemanager.h @@ -13,6 +13,8 @@ #ifndef QTK_RESOURCEMANAGER_H #define QTK_RESOURCEMANAGER_H +#include + typedef class ResourceManager { public: @@ -28,7 +30,7 @@ public: */ static std::string getPath(const std::string & path) { // Only construct qtk resource path if in qrc format; else return it as-is - return path[0] == ':' ? QTK_RESOURCES_DIR + path.substr(1) : path; + return path[0] == ':' ? QTK_RESOURCES + path.substr(1) : path; } } RM; diff --git a/cmake/include/git_submodule.cmake b/cmake/include/git_submodule.cmake index 59dfce1..c3d2b21 100644 --- a/cmake/include/git_submodule.cmake +++ b/cmake/include/git_submodule.cmake @@ -15,10 +15,9 @@ function(submodule_update _PATH) endif() if (NOT GIT_FOUND) - message(FATAL_ERROR "Error: No git executable found") + message(FATAL_ERROR "[Qtk] Error: No git executable found") endif() - message(STATUS "${_PATH}") execute_process( COMMAND ${GIT_EXECUTABLE} submodule update --init "${_PATH}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" @@ -26,6 +25,6 @@ function(submodule_update _PATH) ) if (NOT result EQUAL 0) - message(FATAL_ERROR "Error: Unable to update git submodule at ${_PATH}") + message(FATAL_ERROR "[Qtk] Error: Unable to update git submodule at ${_PATH}") endif() endfunction() diff --git a/src/qtkresources.h.in b/src/qtkresources.h.in new file mode 100644 index 0000000..b5ab997 --- /dev/null +++ b/src/qtkresources.h.in @@ -0,0 +1,2 @@ + +#define QTK_RESOURCES "@QTK_RESOURCES@"