Use configure_file to set QTK_RESOURCES
This commit is contained in:
parent
e775757015
commit
970e548cef
|
@ -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)
|
||||
|
||||
|
@ -164,6 +168,7 @@ target_include_directories(qtk-main PRIVATE src/ app/)
|
|||
|
||||
# Link qtk-main executable to main qtk-widget library
|
||||
target_link_libraries(qtk-main PRIVATE qtk-widget)
|
||||
#target_include_directories(qtk-main PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/)
|
||||
|
||||
set_target_properties(qtk-main PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
|
|
|
@ -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 <resourcemanager.h>
|
|
@ -13,6 +13,8 @@
|
|||
#ifndef QTK_RESOURCEMANAGER_H
|
||||
#define QTK_RESOURCEMANAGER_H
|
||||
|
||||
#include <src/qtkresources.h>
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
|
||||
#define QTK_RESOURCES "@QTK_RESOURCES@"
|
Loading…
Reference in New Issue