Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
IHTACMakeCommon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IHTA
CMake
IHTACMakeCommon
Commits
46976e4f
Commit
46976e4f
authored
2 years ago
by
Pascal Palenda
Browse files
Options
Downloads
Patches
Plain Diff
Add example useage to README
parent
0e7728ef
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+72
-0
72 additions, 0 deletions
README.md
with
72 additions
and
0 deletions
README.md
+
72
−
0
View file @
46976e4f
...
...
@@ -15,6 +15,78 @@ A collection of CMake helper functions and tools that are common to all IHTA C++
-
`ihta_add_test`
: Adds a unit test executable target including downloading the dependencies, CTest registration and optional code coverage.
-
`build_doc`
: Builds doxygen documentation with nice styling.
## Usage
Here is an example of the usage:
```
cmake
cmake_minimum_required
(
VERSION 3.20
)
# optionally disable code coverage
set
(
IHTA_COMMON_ENABLE_CODE_COVERAGE ON
)
include
(
FetchContent
)
FetchContent_Declare
(
IHTACMakeCommon
GIT_REPOSITORY https://git.rwth-aachen.de/ihta/cmake/ihtacmakecommon.git
GIT_TAG main
)
FetchContent_MakeAvailable
(
IHTACMakeCommon
)
init_project
()
project
(
AwesomeProjectName
LANGUAGES CXX C
VERSION 1.0.0
)
CPMAddPackage
(
"gh:gabime/spdlog@1.8.2"
)
# Add the library target with unit test
ihta_add_library
(
NAME
${
PROJECT_NAME
}
SOURCES include/project.h src/project.cpp
NAMESPACE IHTA
IDE_FOLDER
${
PROJECT_NAME
}
LIBRARY_TYPE STATIC
TEST_INTERNALS
OUT_LIB LIB_TARGET
OUT_TEST TEST_TARGET
TEST_SOURCES test/test.cpp
)
# Add external library link to library
target_link_libraries
(
${
LIB_TARGET
}
PRIVATE spdlog
)
# Add external library link to unit test
target_link_libraries
(
${
TEST_TARGET
}
PRIVATE OtherExternalLibrary
)
# Install & export
packageProject
(
NAME
${
PROJECT_NAME
}
VERSION
${
PROJECT_VERSION
}
BINARY_DIR
${
PROJECT_BINARY_DIR
}
INCLUDE_DIR
${
PROJECT_SOURCE_DIR
}
/include
INCLUDE_DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
DEPENDENCIES
"ExternalLibrary"
COMPATIBILITY ExactVersion
NAMESPACE IHTA
DISABLE_VERSION_SUFFIX YES
VERSION_HEADER
"AwesomeProjectName_version.h"
EXPORT_HEADER
"AwesomeProjectName_export.h"
)
# Needed so the object library knows the location of the generated headers from packageProject.
target_include_directories
(
${
LIB_TARGET
}
PUBLIC
"$<BUILD_INTERFACE:
${
PROJECT_BINARY_DIR
}
/PackageProjectInclude>"
)
target_include_directories
(
${
TEST_TARGET
}
PUBLIC
"$<BUILD_INTERFACE:
${
PROJECT_BINARY_DIR
}
/PackageProjectInclude>"
)
build_doc
(
ADD_DEV_SECTION OFF
README_MAINPAGE
${
CMAKE_CURRENT_SOURCE_DIR
}
/README.md
SOURCES
"include"
"src"
"docs"
)
```
## References
-
[
cpp_coverage
](
https://github.com/ekcoh/cpp-coverage/blob/master/cmake/cpp_coverage.cmake
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment