This is a template project which contains the configuration of the following external libraries:
- opencv (https://github.com/opencv/opencv.git)
- opencv_contrib (https://github.com/opencv/opencv_contrib.git)
- opengl
- fltk (https://github.com/fltk/fltk)
- glad (https://github.com/Dav1dde/glad)
- glm (https://github.com/g-truc/glm)
Additional for testing:
- googletest (https://github.com/google/googletest.git)
- nlohmann_json (https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent)
The project consists of a main application, a template library and its test application. You just have to create your own project out of this template, import it in your IDE and start the cmake configuration process. Then you're able to run your application. There is no need to install or build the external libs separately.
Opencv will build at cmake-configuration time and it will take a while. For more information
have a look at
https://github.com/LukasSeglias/CMake-OpenCV-from-sources and/or
OpenCV + Visual Studio + CMake = Adventure time
This template is especially for computer graphics and computer perception/vision projects.
Naturally, the template can be adapted for other projects also.
The layout explained in detail:
.
├── app # Main project (may delete this folder if the project is a pure-library project)
.
└── src # Source files of the main project
├── cmake # Custom cmake files
├── ... # Not necessary for build purposes
├── ext # External libraries
├── lib # Custom libraries
.
└── custom_lib # A library
.
├── include # Public header files of the library
└── src # Source files of the library
└── test # Automated tests
.
├── ext # External libraries for test purposes only
└── custom_lib # Test project for "custom_lib"
.
├── resources # Contains resources for tests (eg. description of inputs)
└── src # Source files of the test application
There are three interesting targets:
- template_lib (The template library)
- template_lib_test (The test target for the template library)
- app (The main application which uses the target template_lib)
- Rename or remove the targets (there are TODOs in the corresponding CMake-Files "TODO: Rename")
- Let CMake configure.
- Run your main or test application
- Add your own lib-targets and test-applications
- Docker
Have a look at lib/template_lib/. You will find a Doxyfile to describe the documentation of that library. To create the documentation just build the target 'doxygen' or navigate in a console of your choice to the folder doxygen and execute:
docker-compose up
The output will be stored in 'doxygen_output/'.
If you want to build the documentation of another library, just edit the environment variable 'LIBRARY' doxygen/.env (this is the name of the folder of the library, eg. template_lib). You can also change the language to generate there.
- Docker
There is already a built in approach to generate a project documentation with
latex and docker. The necessary folders for this are "doc" and "doc_source".
If you don't need a documentation pdf you can delete these two folders, don't forget to
remove the 'add_subdirectory' in CMakeLists.txt, otherwise
read the next few lines.
You don't have to do much, just install docker on your system and navigate inside a console of your choice to
the folder doc_source and execute:
docker-compose up
or just use the target 'document' and build it. This command generates and stores your pdf in doc/document/en/document.pdf. If you wan't to change the language, just navigate to doc_source/.env and change the "LANGUAGE" environment variable to "de" for example. Note that you must provide a language folder inside doc_source/tex/document/ where the language specific latex-files are stored. Inside this environment file, you can also change the document to be created if you have more than one. The environment you have to change is "DOCUMENT". Just write the name of the top-level folder there, at the moment this is document.
There is an example layout provided, but you can change this as you want, just keep in mind
that there is a restriction with subdirectories. You can add just one subdirectory inside your language specific folder for
a chapter so you can't add another subdirectory in doc_source/tex/document/en/chapter_01 for example
(however, a resource folder is allowed).
You can duplicate the directory doc_source/tex/document/ and give it another name.
Then you can change the name inside the doc_source/.env file to build this document.
The resulting file will be stored inside "doc///.pdf".
Note that there are much files generated, just copy and paste the doc/document/.gitignore
file to your new directory "doc/".
You are able to provide your own latex libraries, just put them directly inside doc_source/tex/latex_files. Have a look at the text document there if you need some more info a_latex_file.txt. During build-time, all the files will be copied to your directory where your main tex file is stored and will be automatically deleted from there after the build, so don't worry if there appear and disappear some files magically.
The libraries are intent to be shared-build, there is no static build available right now. The libs are moved to the correct place automatically after each build.
The project runs on the following platforms:
- Windows 10
Tested IDEs:
- CLion
- Visual Studio 2019
I tried to follow the latest cmake recommendations. If there is any potential for improvement (eg. testing and fixing for linux platforms), feel free to contribute.
As mentioned before, the folder "app" has to be deleted if the project is a pure-library project. Additionally, the options in the main CMakeLists have to be renamed with the correct prefix. The following Code-Snippet shows the recommended usage in external projects.
include(FetchContent)
option(ANY_PREFIX_BUILD_TEST "" OFF)
option(ANY_PREFIX_BUILD_DOCUMENTATION "" OFF)
option(ANY_PREFIX_BUILD_CODE_DOCUMENTATION "" OFF)
option(ANY_PREFIX_BUILD_EXT_LIBS "" OFF)
FetchContent_Declare(
any_library
GIT_REPOSITORY https://github.com/LucaRitz/any-library
GIT_TAG main
)
FetchContent_MakeAvailable(any_library)
unset(ANY_PREFIX_BUILD_TEST)
unset(ANY_PREFIX_BUILD_DOCUMENTATION)
unset(ANY_PREFIX_BUILD_CODE_DOCUMENTATION)
unset(ANY_PREFIX_BUILD_EXT_LIBS)