Use configure_file to set QTK_RESOURCES
This commit is contained in:
parent
dfffd14d5b
commit
6cdf906065
|
@ -13,61 +13,21 @@ jobs:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.3.1/gcc_64/;../assimp"
|
cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.3.1/gcc_64/"
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
cmake: -DCMAKE_PREFIX_PATH="D:/a/qtk/qtk/Qt/6.3.1/mingw81_64/;../assimp" -DASSIMP_NEW_INTERFACE=on
|
cmake: -DCMAKE_PREFIX_PATH="D:/a/qtk/qtk/Qt/6.3.1/mingw81_64/"
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.3.1/gcc_64/;../assimp" -DASSIMP_NEW_INTERFACE=on
|
cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.3.1/gcc_64/"
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Clone Assimp
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
repository: 'assimp/assimp'
|
|
||||||
path: 'assimp'
|
|
||||||
|
|
||||||
- name: Build Assimp
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
pwd
|
|
||||||
ls
|
|
||||||
cmake -S assimp/ -B assimp/build/ -DCMAKE_INSTALL_PREFIX=../assimp && cmake --build assimp/build
|
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
uses: jurplel/install-qt-action@v2
|
uses: jurplel/install-qt-action@v2
|
||||||
with:
|
with:
|
||||||
version: '6.3.1'
|
version: '6.3.1'
|
||||||
|
|
||||||
# - name: Install Assimp Linux
|
|
||||||
# if: matrix.os == 'ubuntu-latest'
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# sudo apt install libassimp-dev -y
|
|
||||||
#
|
|
||||||
# - name: Install Assimp MacOS
|
|
||||||
# if: matrix.os == 'macos-latest'
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# brew install assimp
|
|
||||||
#
|
|
||||||
# - name: Install Assimp Windows
|
|
||||||
# if: matrix.os == 'windows-latest'
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# git clone https://github.com/Microsoft/vcpkg.git
|
|
||||||
# cd vcpkg
|
|
||||||
# ./bootstrap-vcpkg.sh
|
|
||||||
# ./vcpkg integrate install
|
|
||||||
# vcpkg install assimp
|
|
||||||
|
|
||||||
- name: Install Assimp MacOS
|
|
||||||
if: matrix.os == 'macos-latest'
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
brew install assimp
|
|
||||||
|
|
||||||
- name: Build Qtk
|
- name: Build Qtk
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -19,16 +19,21 @@ set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
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
|
# Qtk build options
|
||||||
option(QTK_DEBUG "Enable debugger" ON)
|
option(QTK_DEBUG "Enable debugger" ON)
|
||||||
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
||||||
option(UPDATE_SUBMODULES "Update external project (assimp) git submodule" ON)
|
|
||||||
|
|
||||||
# Qt options
|
# Qt options
|
||||||
set(QT_DIR "$ENV{HOME}/Code/Clones/Qt/6.3.1/gcc_64/" CACHE PATH "Path to Qt6")
|
set(QT_DIR "$ENV{HOME}/Code/Clones/Qt/6.3.1/gcc_64/" CACHE PATH "Path to Qt6")
|
||||||
|
|
||||||
# Options for bringing your own assimp installation; Otherwise not needed
|
# Options for bringing your own assimp installation; Otherwise not needed
|
||||||
set(ASSIMP_DIR "" CACHE PATH "Path to local installation of assimp")
|
# + If assimp is available system-wide we can just set UPDATE_SUBMODULES OFF
|
||||||
|
option(UPDATE_SUBMODULES "Update external project (assimp) git submodule" ON)
|
||||||
option(ASSIMP_NEW_INTERFACE "Use the assimp::assimp interface (WIN / OSX)" OFF)
|
option(ASSIMP_NEW_INTERFACE "Use the assimp::assimp interface (WIN / OSX)" OFF)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -42,34 +47,24 @@ 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)
|
||||||
else()
|
|
||||||
if (ASSIMP_DIR)
|
|
||||||
message(STATUS "Using custom ASSIMP_DIR: ${ASSIMP_DIR}")
|
|
||||||
list(APPEND CMAKE_PREFIX_PATH "${ASSIMP_DIR}")
|
|
||||||
endif()
|
endif()
|
||||||
find_package(assimp REQUIRED)
|
|
||||||
if (assimp_FOUND)
|
|
||||||
message(STATUS "Found assimp: ${assimp_DIR}")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Could not find assimp at: ${CMAKE_PREFIX_PATH}")
|
|
||||||
endif()
|
|
||||||
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
|
||||||
|
@ -82,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
|
||||||
|
@ -101,7 +97,6 @@ set(SOURCE_FILES
|
||||||
include(GenerateExportHeader)
|
include(GenerateExportHeader)
|
||||||
qt_add_library(qtk-widget STATIC ${PUBLIC_HEADERS} ${SOURCE_FILES})
|
qt_add_library(qtk-widget STATIC ${PUBLIC_HEADERS} ${SOURCE_FILES})
|
||||||
target_include_directories(qtk-widget PRIVATE src/ app/)
|
target_include_directories(qtk-widget PRIVATE src/ app/)
|
||||||
generate_export_header(qtk-widget)
|
|
||||||
|
|
||||||
set_target_properties(qtk-widget PROPERTIES
|
set_target_properties(qtk-widget PROPERTIES
|
||||||
PUBLIC_HEADER "${PUBLIC_HEADERS}"
|
PUBLIC_HEADER "${PUBLIC_HEADERS}"
|
||||||
|
@ -110,13 +105,14 @@ set_target_properties(qtk-widget PROPERTIES
|
||||||
|
|
||||||
target_link_libraries(qtk-widget PUBLIC Qt6::OpenGLWidgets)
|
target_link_libraries(qtk-widget PUBLIC Qt6::OpenGLWidgets)
|
||||||
|
|
||||||
if ((UPDATE_SUBMODULES AND NOT ASSIMP_DIR) OR NOT ASSIMP_NEW_INTERFACE)
|
if (UPDATE_SUBMODULES OR NOT ASSIMP_NEW_INTERFACE)
|
||||||
target_link_libraries(qtk-widget PRIVATE assimp)
|
target_link_libraries(qtk-widget PUBLIC assimp)
|
||||||
elseif(ASSIMP_NEW_INTERFACE)
|
elseif(ASSIMP_NEW_INTERFACE)
|
||||||
target_link_libraries(qtk-widget PRIVATE assimp::assimp)
|
target_link_libraries(qtk-widget PUBLIC assimp::assimp)
|
||||||
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()
|
||||||
|
|
||||||
|
@ -126,6 +122,7 @@ if(WIN32)
|
||||||
target_link_libraries(qtk-widget PUBLIC OpenGL::GL)
|
target_link_libraries(qtk-widget PUBLIC OpenGL::GL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
generate_export_header(qtk-widget)
|
||||||
# Install files
|
# Install files
|
||||||
install(TARGETS qtk-widget
|
install(TARGETS qtk-widget
|
||||||
# Associate qtk-widget target with qtk-export
|
# Associate qtk-widget target with qtk-export
|
||||||
|
@ -150,14 +147,19 @@ install(EXPORT qtk-export
|
||||||
# Final Application
|
# 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
|
# 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)
|
||||||
|
|
||||||
|
@ -192,7 +194,7 @@ if(WIN32)
|
||||||
endif()
|
endif()
|
||||||
if(MSVC AND TARGET Qt6::qmake)
|
if(MSVC AND TARGET Qt6::qmake)
|
||||||
set(VSUSER_FILE ${CMAKE_CURRENT_BINARY_DIR}/qtk-main.vcxproj.user)
|
set(VSUSER_FILE ${CMAKE_CURRENT_BINARY_DIR}/qtk-main.vcxproj.user)
|
||||||
file(TO_NATIVE_PATH "${ASSIMP_INSTALL_DIR}/bin" assimp_bin)
|
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/extern/assimp/assimp/bin" assimp_bin)
|
||||||
file(WRITE ${VSUSER_FILE} "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
file(WRITE ${VSUSER_FILE} "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||||
file(APPEND ${VSUSER_FILE} "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n")
|
file(APPEND ${VSUSER_FILE} "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n")
|
||||||
file(APPEND ${VSUSER_FILE} " <PropertyGroup>\n")
|
file(APPEND ${VSUSER_FILE} " <PropertyGroup>\n")
|
||||||
|
|
|
@ -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>
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <resources.h>
|
#include <src/qtkresources.h>
|
||||||
|
|
||||||
#ifndef QTK_RESOURCEMANAGER_H
|
#ifndef QTK_RESOURCEMANAGER_H
|
||||||
#define QTK_RESOURCEMANAGER_H
|
#define QTK_RESOURCEMANAGER_H
|
||||||
|
@ -28,7 +28,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,2 @@
|
||||||
|
|
||||||
|
#define QTK_RESOURCES "@QTK_RESOURCES@"
|
Loading…
Reference in New Issue