@@ -8,9 +8,9 @@ Keeps the Primary Instance of your Application and kills each subsequent
88instances. It can (if enabled) spawn secondary (non-related to the primary)
99instances and can send data to the primary instance from secondary instances.
1010
11- ## Documentation
11+ # [ Documentation] ( https://itay-grudev.github.io/SingleApplication/ )
1212
13- You can find the full usage reference [ here] ( https://itay-grudev.github.io/SingleApplication/classSingleApplication.html ) .
13+ You can find the full usage reference and examples [ here] ( https://itay-grudev.github.io/SingleApplication/classSingleApplication.html ) .
1414
1515## Usage
1616
@@ -60,6 +60,50 @@ add_subdirectory(src/third-party/singleapplication)
6060target_link_libraries(${PROJECT_NAME} SingleApplication::SingleApplication)
6161```
6262
63+ Directly including this repository as a Git submodule, or even just a shallow copy of the
64+ source code into new projects might not be ideal when using CMake.
65+ Another option is using CMake's ` FetchContent ` module, available since version ` 3.11 ` .
66+ ``` cmake
67+
68+ # Define the minumun CMake version, as an example 3.24
69+ cmake_minimum_required(VERSION 3.24)
70+
71+ # Include the module
72+ include(FetchContent)
73+
74+ # If using Qt6, override DEFAULT_MAJOR_VERSION
75+ set(QT_DEFAULT_MAJOR_VERSION 6 CACHE STRING "Qt version to use, defaults to 6")
76+
77+ # Set QAPPLICATION_CLASS
78+ set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
79+
80+
81+ # Declare how is the source going to be obtained
82+ FetchContent_Declare(
83+ SingleApplication
84+ GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication
85+ GIT_TAG master
86+ #GIT_TAG e22a6bc235281152b0041ce39d4827b961b66ea6
87+ )
88+
89+ # Fetch the repository and make it available to the build
90+ FetchContent_MakeAvailable(SingleApplication)
91+
92+ # Then simply use find_package as usual
93+ find_package(SingleApplication)
94+
95+ # Finally add it to the target_link_libraries() section
96+ target_link_libraries(ClientePOS PRIVATE
97+ Qt${QT_VERSION_MAJOR}::Widgets
98+ Qt${QT_VERSION_MAJOR}::Network
99+ Qt${QT_VERSION_MAJOR}::Sql
100+
101+ SingleApplication::SingleApplication
102+ )
103+
104+ ```
105+
106+
63107The library sets up a ` QLocalServer ` and a ` QSharedMemory ` block. The first
64108instance of your Application is your Primary Instance. It would check if the
65109shared memory block exists and if not it will start a ` QLocalServer ` and listen
@@ -168,6 +212,11 @@ instances running.
168212
169213## License
170214
171- This library and it's supporting documentation are released under
172- ` The MIT License (MIT) ` with the exception of the Qt calculator examples which
173- is distributed under the BSD license.
215+ This library and it's supporting documentation, with the exception of the Qt
216+ calculator examples which is distributed under the BSD license, are released
217+ under the terms of ` The MIT License (MIT) ` with an extra condition, that:
218+
219+ ``` txt
220+ Permission is not granted to use this software or any of the associated files
221+ as sample data for the purposes of building machine learning models.
222+ ```
0 commit comments