Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QML_ELEMENT support #99

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* text=auto
*.sh text eol=lf
*.yml text eol=lf
*.json text eol=lf
Makefile text eol=lf
Vagrantfile text eol=lf
4 changes: 0 additions & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ jobs:
matrix:
include:
- host_system: windows-2022
cl_version: "14.33"
qt_version: "6.3.0"
qt_arch: win64_msvc2019_64

- host_system: windows-2019
cl_version: "14.29"
qt_version: "6.2.4"
qt_arch: win64_msvc2019_64

Expand All @@ -89,8 +87,6 @@ jobs:

- name: Add msbuild to PATH
uses: ilammy/msvc-dev-cmd@v1
with:
toolset: '${{ matrix.cl_version }}'

- name: Git Checkout
uses: actions/checkout@v2
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/cmake-build-*/
/build*/
/.idea/
/.vscode/
/*.user
/*.autosave
59 changes: 59 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
cmake_minimum_required(VERSION 3.25)

project(Verdigris
VERSION 2.0
DESCRIPTION "Replace Qt moc with native C++"
HOMEPAGE_URL "https://github.com/woboq/verdigris"
LANGUAGES CXX
)

enable_testing()

find_package(Qt6 6.2 COMPONENTS Core Test REQUIRED)

add_subdirectory("src")
add_subdirectory("tools")
add_subdirectory("tutorial")
add_subdirectory("tests")
add_subdirectory("benchmarks")

set_source_files_properties(
"src/wobjectcpp.h"
"src/wobjectdefs.h"
"src/wobjectimpl.h"
"src/wqmlelement.h"
DIRECTORY
"benchmarks/qobject/"
PROPERTIES
SKIP_AUTOMOC ON
)

add_library(verdigris::verdigris ALIAS verdigris)
include(CMakePackageConfigHelpers)
configure_package_config_file("cmake/verdigrisConfig.cmake.in"
"verdigrisConfig.cmake"
INSTALL_DESTINATION verdigris/cmake
)
write_basic_package_version_file("verdigrisConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
include(GNUInstallDirs)
install(TARGETS verdigris
EXPORT verdigris_Targets
FILE_SET HEADERS
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/verdigris"
)
install(FILES
"${PROJECT_BINARY_DIR}/verdigrisConfig.cmake"
"${PROJECT_BINARY_DIR}/verdigrisConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/verdigris/cmake)
install(EXPORT verdigris_Targets
FILE "verdigrisTargets.cmake"
NAMESPACE verdigris::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/verdigris/cmake
)

set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.LGPLv3")
include(CPack)
38 changes: 38 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": 3,
"configurePresets": [
{
"name": "base",
"hidden": true,
"description": "Base for concrete configure presets",
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build/${presetName}"
},
{
"name": "msvc",
"description": "Preferred settings for MSVC 2022",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/DWIN32 /D_WINDOWS /EHsc /permissive- /Zc:__cplusplus /Zc:externConstexpr /Zc:inline /Zc:preprocessor /Zc:throwingNew /diagnostics:caret"
}
},
{
"name": "clang",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "--pedantic -Wall -Wextra -ftemplate-backtrace-limit=0 -Wno-gnu-zero-variadic-macro-arguments"
}
},
{
"name": "clang-libcpp",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "--stdlib=libc++ --pedantic -Wall -Wextra -ftemplate-backtrace-limit=0 -Wno-gnu-zero-variadic-macro-arguments",
"CMAKE_EXE_LINKER_FLAGS": "--stdlib=libc++"
}
},
{
"name": "gcc",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "--pedantic -Wall -Wextra -Wno-noexcept-type -Wno-address -ftemplate-backtrace-limit=0"
}
}
]
}
2 changes: 2 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

add_subdirectory("qobject")
11 changes: 11 additions & 0 deletions benchmarks/qobject/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

add_executable(qobject_bench
"main.cpp"
"object.cpp"
"object.h"
)
target_link_libraries(qobject_bench PRIVATE
verdigris
Qt6::Test
)
set_target_properties(qobject_bench PROPERTIES AUTOMOC ON)
4 changes: 4 additions & 0 deletions cmake/verdigrisConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")
26 changes: 26 additions & 0 deletions qbs/modules/wqmlelement/metatypes/metatypes.qbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import qbs.File

Module {
Depends { name: "Qt.core" }

Rule {
name: "Qt MetaTypes"
inputs: ["verdigris.metatypes"]
inputsFromDependencies: ["verdigris.metatypes"]
Artifact {
filePath: input.fileName + ".json"
fileTags: ["qt.core.metatypes"]
qbs.install: product.Qt.core.metaTypesInstallDir
qbs.installDir: product.Qt.core.metaTypesInstallDir
}
prepare: {
var cmd = new JavaScriptCommand();
cmd.description = "generating " + output.fileName + " from " + input.fileName;
cmd.highlight = "codegen";
cmd.sourceCode = function() {
File.copy(input.filePath, output.filePath);
}
return [cmd];
}
}
}
29 changes: 29 additions & 0 deletions qbs/modules/wqmlelement/objlibrary/objlibrary.qbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

Module {
additionalProductTypes: ["obj", "verdigris.metatypes"]

Depends { productTypes: ["metatypes-extractor"] }

Rule {
name: "Extract MetaTypes"
multiplex: true
inputs: ["obj"]
Artifact {
filePath: product.targetName.toLowerCase() + "_metatypes"
fileTags: ["verdigris.metatypes"]
}
explicitlyDependsOnFromDependencies: ["metatypes-extractor"]
prepare: {
var inputFilePaths = inputs.obj.map(function(a) {
return a.filePath;
});
var toolPath = explicitlyDependsOn["metatypes-extractor"][0].filePath;
var cmd = new Command(toolPath,
["--out=" + output.filePath].concat(inputFilePaths));
cmd.environment = product.environment;
cmd.description = "generating " + output.fileName;
cmd.highlight = "codegen";
return cmd;
}
}
}
19 changes: 19 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

add_library(verdigris INTERFACE)
target_sources(verdigris INTERFACE
FILE_SET HEADERS
FILES
"wobjectcpp.h"
"wobjectdefs.h"
"wobjectimpl.h"
"wqmlelement.h"
)
target_compile_features(verdigris INTERFACE
cxx_std_20
)
target_include_directories(verdigris INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(verdigris INTERFACE
Qt6::Core
)
Loading