Skip to content

Commit

Permalink
Add static QRC support building (cneben#93)
Browse files Browse the repository at this point in the history
Added new option -DBUILD_STATIC_QRC that enables static QRC linking that make possible run tests without installing library.
  • Loading branch information
winterheart committed Dec 17, 2019
1 parent 397e4b6 commit 97a7ac5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_subdirectory(QuickContainers)
add_subdirectory(src)

option(BUILD_SAMPLES "Build the samples" TRUE)
option(BUILD_STATIC_QRC "Build *.qrc resources statically" FALSE)
option(DEPLOY "Use windeployqt on Windows" FALSE)

if (${BUILD_SAMPLES})
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ QuickQanava could be used with either _qmake_ or _CMake_ build configuration sys

| qmake | cmake |
| :---: | :---: |
| Static build, no QML module, all resources are linked statically trough QRC | Installable or embedable, QuickQanava is loaded using a QML module that need to be installed |
| Static build, no QML module, all resources are linked statically trough QRC | Installable or embedable, QuickQanava is loaded using a QML module that need to be installed, resources can be linked statically trough QRC |


Using qmake (**preferred and supported way of integrating QuickQanava**):
Expand Down Expand Up @@ -133,18 +133,18 @@ $ mkdir build
$ cd build

# IF QT_DIR IS CONFIGURED AND QMAKE IN PATH
$ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SAMPLES=TRUE ..
$ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SAMPLES=TRUE -DBUILD_STATIC_QRC=TRUE ..

# IF QT DIR IS NOT CONFIGURED, CONFIGURE KIT MANUALLY
$ cmake -DCMAKE_PREFIX_PATH="/home/b/Qt/5.11.0/gcc_64" -DQT_QMAKE_EXECUTABLE="/home/b/Qt/5.11.0/gcc_64/bin/qmake" -DBUILD_SAMPLES=TRUE ../QuickQanava/
$ cmake -DCMAKE_PREFIX_PATH="/home/b/Qt/5.11.0/gcc_64" -DQT_QMAKE_EXECUTABLE="/home/b/Qt/5.11.0/gcc_64/bin/qmake" -DBUILD_SAMPLES=TRUE -DBUILD_STATIC_QRC=TRUE ../QuickQanava/

$ cmake --build .
# Then run the samples in ./samples

# Eventually make install
```

Detailled instructions: [Installation](http://cneben.github.io/QuickQanava/installation/index.html)
Detailed instructions: [Installation](http://cneben.github.io/QuickQanava/installation/index.html)

Note that a previously installed "QML plugin" version of QuickQanava might interfere with a fully static build using direct .pri inclusion. Typical error message looks like:

Expand Down
11 changes: 9 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ set (qan_plugin_files
set(CMAKE_AUTOMOC ON)
qt5_wrap_cpp(qan_source_files, qan_header_files)
set(CMAKE_AUTORCC ON)
list(APPEND RESOURCES QuickQanava_plugin.qrc)

if(BUILD_STATIC_QRC)
list(APPEND RESOURCES QuickQanava_static.qrc)
else()
list(APPEND RESOURCES QuickQanava_plugin.qrc)
endif(BUILD_STATIC_QRC)

set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:QT_QML_DEBUG>)

Expand Down Expand Up @@ -98,7 +103,9 @@ install(TARGETS QuickQanava

set(CMAKE_INCLUDE_CURRENT_DIR ON)
target_link_libraries(QuickQanava PUBLIC GTpo QuickContainers Qt5::Core Qt5::Gui Qt5::QuickControls2)

if(BUILD_STATIC_QRC)
target_compile_definitions(QuickQanava PUBLIC -DQUICKQANAVA_STATIC)
endif(BUILD_STATIC_QRC)

# Configure QuickQanava QML module plugin #####################################
set(PLUGIN_TARGET "quickqanavaplugin")
Expand Down

0 comments on commit 97a7ac5

Please sign in to comment.