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")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
add_compile_options(/wd4131 /wd4127)
|
add_compile_options(/wd4131 /wd4127)
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "[Qtk]: Compiling with ${CMAKE_CXX_COMPILER_ID}")
|
||||||
|
|
||||||
# Qtk build options
|
# Qtk build options
|
||||||
option(QTK_DEBUG "Enable debugger" ON)
|
option(QTK_DEBUG "Enable debugger" ON)
|
||||||
|
@ -46,11 +47,12 @@ list(APPEND CMAKE_PREFIX_PATH "${QT_DIR}")
|
||||||
# Find Qt
|
# Find Qt
|
||||||
find_package(Qt6 COMPONENTS OpenGLWidgets)
|
find_package(Qt6 COMPONENTS OpenGLWidgets)
|
||||||
if (NOT Qt6_FOUND)
|
if (NOT Qt6_FOUND)
|
||||||
message(SEND_ERROR "Unable to find Qt6 at CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
|
message(SEND_ERROR "[Qtk] 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(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()
|
endif()
|
||||||
|
|
||||||
if (UPDATE_SUBMODULES)
|
if (UPDATE_SUBMODULES)
|
||||||
|
message(STATUS "[Qtk]: Updating submodules...")
|
||||||
include("${CMAKE_SOURCE_DIR}/cmake/include/git_submodule.cmake")
|
include("${CMAKE_SOURCE_DIR}/cmake/include/git_submodule.cmake")
|
||||||
submodule_update(extern/assimp/assimp/)
|
submodule_update(extern/assimp/assimp/)
|
||||||
add_subdirectory(extern/assimp/assimp)
|
add_subdirectory(extern/assimp/assimp)
|
||||||
|
@ -61,7 +63,8 @@ endif()
|
||||||
# Qtk
|
# Qtk
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
set(PUBLIC_HEADERS
|
set(
|
||||||
|
PUBLIC_HEADERS
|
||||||
src/mainwidget.h
|
src/mainwidget.h
|
||||||
src/abstractscene.h
|
src/abstractscene.h
|
||||||
src/camera3d.h
|
src/camera3d.h
|
||||||
|
@ -74,7 +77,8 @@ set(PUBLIC_HEADERS
|
||||||
src/transform3D.h
|
src/transform3D.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(
|
||||||
|
SOURCE_FILES
|
||||||
src/mainwidget.cpp
|
src/mainwidget.cpp
|
||||||
src/abstractscene.cpp
|
src/abstractscene.cpp
|
||||||
src/camera3d.cpp
|
src/camera3d.cpp
|
||||||
|
@ -108,6 +112,7 @@ elseif(ASSIMP_NEW_INTERFACE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(QTK_DEBUG)
|
if(QTK_DEBUG)
|
||||||
|
message(STATUS "[Qtk]: Building with QTK_DEBUG=${QTK_DEBUG}")
|
||||||
target_compile_definitions(qtk-widget PUBLIC QTK_DEBUG)
|
target_compile_definitions(qtk-widget PUBLIC QTK_DEBUG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -142,20 +147,19 @@ install(EXPORT qtk-export
|
||||||
# Final Application
|
# Final Application
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
file(
|
set(QTK_RESOURCES "${CMAKE_SOURCE_DIR}/resources")
|
||||||
WRITE ${CMAKE_CURRENT_BINARY_DIR}/resources.h
|
configure_file(
|
||||||
"#ifndef QTK_RESOURCES_H\n"
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/qtkresources.h.in"
|
||||||
"#define QTK_RESOURCES_H\n"
|
"${CMAKE_CURRENT_BINARY_DIR}/src/qtkresources.h"
|
||||||
"#define QTK_RESOURCES_DIR \"${CMAKE_SOURCE_DIR}/resources\"\n"
|
@ONLY
|
||||||
"#endif\n"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add our Qt resources.qrc file to our application
|
# Add our Qt resources.qrc file to our application
|
||||||
set(QTK_APP_SOURCES app/main.cpp
|
set(QTK_APP_SOURCES app/main.cpp
|
||||||
app/mainwindow.cpp app/mainwindow.h app/mainwindow.ui
|
app/mainwindow.cpp app/mainwindow.h app/mainwindow.ui
|
||||||
app/scene.cpp app/scene.h
|
app/scene.cpp app/scene.h
|
||||||
app/resourcemanager.cpp app/resourcemanager.h
|
app/resourcemanager.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/resources.h
|
src/qtkresources.h.in
|
||||||
)
|
)
|
||||||
qt6_add_big_resources(QTK_APP_SOURCES resources.qrc)
|
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
|
# Link qtk-main executable to main qtk-widget library
|
||||||
target_link_libraries(qtk-main PRIVATE qtk-widget)
|
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
|
set_target_properties(qtk-main PROPERTIES
|
||||||
WIN32_EXECUTABLE TRUE
|
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
|
#ifndef QTK_RESOURCEMANAGER_H
|
||||||
#define QTK_RESOURCEMANAGER_H
|
#define QTK_RESOURCEMANAGER_H
|
||||||
|
|
||||||
|
#include <src/qtkresources.h>
|
||||||
|
|
||||||
typedef class ResourceManager {
|
typedef class ResourceManager {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -28,7 +30,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static std::string getPath(const std::string & path) {
|
static std::string getPath(const std::string & path) {
|
||||||
// Only construct qtk resource path if in qrc format; else return it as-is
|
// 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;
|
} RM;
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,9 @@ function(submodule_update _PATH)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT GIT_FOUND)
|
if (NOT GIT_FOUND)
|
||||||
message(FATAL_ERROR "Error: No git executable found")
|
message(FATAL_ERROR "[Qtk] Error: No git executable found")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "${_PATH}")
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${GIT_EXECUTABLE} submodule update --init "${_PATH}"
|
COMMAND ${GIT_EXECUTABLE} submodule update --init "${_PATH}"
|
||||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
|
@ -26,6 +25,6 @@ function(submodule_update _PATH)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT result EQUAL 0)
|
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()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
#define QTK_RESOURCES "@QTK_RESOURCES@"
|
Loading…
Reference in New Issue