Skip to content

Commit 892cd38

Browse files
authored
Merge pull request #11 - system recognition mprovements
- Add tests, - fix small bugs found by added tests, - improve stability and readability, - Remove lsb-release, use CMAKE_* variables to determine architecture and OS.
2 parents 290f60d + 9362789 commit 892cd38

File tree

135 files changed

+8016
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+8016
-109
lines changed

.github/workflows/tests.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- '*'
10+
workflow_dispatch:
11+
12+
env:
13+
CMLIB_VERSION: 1.0.0
14+
15+
jobs:
16+
test_linux:
17+
strategy:
18+
matrix:
19+
image: [
20+
"test_debian:bullseye",
21+
"test_debian:trixie",
22+
"test_debian:bookworm",
23+
"test_ubuntu:2004",
24+
"test_ubuntu:2204",
25+
"test_ubuntu:2404",
26+
"test_fedora:41",
27+
"test_fedora:42"
28+
]
29+
30+
runs-on: ubuntu-latest
31+
container:
32+
image: ghcr.io/cmakelib/${{ matrix.image }}
33+
steps:
34+
- uses: actions/checkout@v4
35+
with:
36+
submodules: recursive
37+
- name: Run tests
38+
run: |
39+
git config --global --add safe.directory "$(pwd)"
40+
git remote set-url origin "${{ github.server_url }}/${{ github.repository }}"
41+
git clone --branch "v${CMLIB_VERSION}" https://github.com/cmakelib/cmakelib.git
42+
export CMLIB_DIR=$(pwd)/cmakelib
43+
cd test/ && cmake .
44+
45+
test_macos:
46+
runs-on: macos-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
submodules: recursive
51+
- name: Run tests
52+
run: |
53+
git config --global --add safe.directory "$(pwd)"
54+
git remote set-url origin "${{ github.server_url }}/${{ github.repository }}"
55+
git clone --branch "v${CMLIB_VERSION}" https://github.com/cmakelib/cmakelib.git
56+
export CMLIB_DIR=$(pwd)/cmakelib
57+
cd test/ && cmake .
58+
59+
test_windows:
60+
runs-on: windows-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
with:
64+
submodules: recursive
65+
- name: Run tests
66+
run: |
67+
git config --global --add safe.directory "$(pwd)"
68+
git remote set-url origin "${{ github.server_url }}/${{ github.repository }}"
69+
git clone --branch "v$Env:CMLIB_VERSION" https://github.com/cmakelib/cmakelib.git
70+
$Env:CMLIB_DIR=$(Join-Path -Path $(Get-Location).Path -ChildPath "cmakelib")
71+
cd test/ && cmake .

CMDEFConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FinDBASEDEF.cmake")
2+
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindCMDEF.cmake")

FindCMDEF.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# - include all CMDEF modules
1010
#
1111

12-
CMAKE_MINIMUM_REQUIRED(VERSION 3.21 FATAL_ERROR)
12+
CMAKE_MINIMUM_REQUIRED(VERSION 3.22 FATAL_ERROR)
1313

1414
SET(CMDEF_PACKAGE_NAME "CMDEF")
1515

@@ -30,5 +30,7 @@ INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_LINK_OPTION.cmake)
3030
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_INSTALL.cmake)
3131
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_PACKAGE.cmake)
3232

33+
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_CLEANUP.cmake)
34+
3335
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_HELPER.cmake)
3436

README.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,59 @@
11

2-
# CMake-lib Basedef component
2+
# CMake-lib Definition Framework Component
33

4-
CMake-lib provides consistent setting for built environment.
4+
Linux: ![buildbadge_github], Windows: ![buildbadge_github], Mac OS: ![buildbadge_github]
5+
6+
CMDEF aka **CMake-lib Definition Framework**
7+
8+
CMake-lib provides consistent settings for build environment.
59
It simplifies and maintains built option, libraries and executables.
610

711
## Requirements
812

9-
- [CMLIB] library installed
13+
CMDEF is intended to be used thru [CMLIB].
14+
15+
CMDEF is not supposed to be used separately.
16+
17+
To use the library install [CMLIB] and call `FIND_PACKAGE(CMLIB COMPONENTS CMDEF)`
1018

1119
## General
1220

1321
The library is not mainly intended for extending CMake functionality.
1422

1523
It's set of wrappers and helpers which enables easily use of existing CMake
16-
features.
24+
features in a more standardised manner across multiple projects.
1725

1826
### Definition of Main target
1927

2028
Each CMake project has one main target - the target for which the project is
2129
created, compiled, ...
2230

23-
For example we have CMake project for building chrome browser.
24-
Browser is represented by one executable called `chrome`. That executable
31+
For example - CMake project for building chrome browser.
32+
Browser is represented by the executable called `chrome`. The executable
2533
must have own target in CMake project.
2634

2735
By that target other project properties are referenced - installer name, application name, documentation etc.
28-
We call this type of target as 'main target' (the 'object' for which we
29-
create the CMake project)
36+
This type of target is called 'main target' (the 'object' for which the CMake project is created).
3037

31-
In the library the 'main target' is represented by MAIN_TARGET variable/parameter for macros/functions
38+
The library 'main target' is represented by LIBRARY_GROUP argument with suffix added according to a library type created.
3239

3340
## Usage
3441

35-
Let GIT_URI be a GIT URI of this repository.
36-
42+
```cmake
3743
FIND_PACKAGE(CMLIB COMPONENTS CMDEF)
44+
```
3845

3946
### Set build defaults
4047

41-
CMake-lib sets and maintains build/link flags and global wide definitions
48+
CMake-lib sets and maintains build and link flags and global wide definitions.
4249

4350
Component workflow
4451

4552
- reset CMake default build flags by `CMDEF_CLEANUP`
4653
- set default build and link options by `CMDEF_COMPILE_OPTIONS`, `CMDEF_LINK_OPTIONS`
47-
- set compile definitions by `CMDEF_COMPIE_DEFINITIONS`
54+
- set compile definitions by `CMDEF_COMPILE_DEFINITIONS`
4855

49-
examples can be found at [example] directory
56+
examples can be found at [example] directory.
5057

5158
## Function list
5259

@@ -55,7 +62,7 @@ Each entry in list represents one feature for CMake.
5562
Most of the functions are just wrappers which enclosures base feature of
5663
CMake.
5764

58-
Detailed documentation for each function can be found at appropriate module.
65+
Detailed documentation for each function can be found at the appropriate module.
5966

6067
- [CMDEF_ADD_LIBRARY.cmake]
6168
- [CMDEF_ADD_EXECUTABLE.cmake]
@@ -67,13 +74,15 @@ Detailed documentation for each function can be found at appropriate module.
6774
- [CMDEF_LINK_OPTION.cmake]
6875
- [CMDEF_PACKAGE.cmake]
6976

70-
## Config Variables
77+
## Documentation
78+
79+
Every function has a comprehensive documentation written as part of the function definition.
7180

72-
Configuration variables detailed desc. for the library is located at [doc/CacheVariables.md]
81+
Context documentation is located at [doc/README.md]
7382

7483
## Coding standards
7584

76-
- We use Uppercase for all keywords and global variables
85+
- The uppercase letters are used for all keywords and global variables
7786
- Each helper function must begin with '_'
7887

7988
[CMLIB]: https://github.com/cmakelib/cmakelib
@@ -88,4 +97,7 @@ Configuration variables detailed desc. for the library is located at [doc/CacheV
8897
[CMDEF_LINK_OPTION.cmake]: system_modules/CMDEF_LINK_OPTION.cmake
8998
[CMDEF_PACKAGE.cmake]: system_modules/CMDEF_PACKAGE.cmake
9099
[doc/CacheVariables.md]: doc/CacheVariables.md
100+
[doc/README.md]: doc/README.md
91101
[example]: example/
102+
103+
[buildbadge_github]: https://github.com/cmakelib/cmakelib-component-cmdef/actions/workflows/tests.yml/badge.svg

doc/CacheVariables.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# CMDEf cache variables
2+
# CMDEF cache variables
33

44
Each section represent one Cache variable used in CMDEF.
55

@@ -31,10 +31,10 @@ It tries to set the variable in the following order
3131

3232
## CMDEF_BUILD_TYPE_CMAKE_BUILD_TYPE_OVERRIDE:BOOL=\<conditional>
3333

34-
Indicate if the CMAKE_BUILD_TYPE is overriden by CMDEF library.
34+
Indicate if the CMAKE_BUILD_TYPE is overridden by CMDEF library.
3535

3636
- If the CMAKE_BUILD_TYPE is not set the CMDEF try to set the CMAKE_BUILD_TYPE variable
37-
to the predefined value stored in CMDEF_BUILD_TYPE_DEFAULT variable. In this case the vairable is set to ON.
37+
to the predefined value stored in CMDEF_BUILD_TYPE_DEFAULT variable. In this case the variable is set to ON.
3838
- If the CMAKE_BUILD_TYPE is set explicitly the variable is set to OFF.
3939

4040
## CMDEF_BUILD_TYPE_DEFAULT:STRING=Debug
@@ -43,7 +43,7 @@ Default build type if CMAKE_BUILD_TYPE is not specified.
4343

4444
## CMDEF_BUILD_TYPE_LIST:STRING,LIST=\<conditional>
4545

46-
List of the suported byuld types. CMAKE_BUILD_TYPE must hold exactly one value from this list.
46+
List of the supported build types. CMAKE_BUILD_TYPE must hold exactly one value from this list.
4747

4848
Type: String, List
4949

@@ -67,7 +67,7 @@ It tries to set the variable in the following order
6767
1. filled from ENV variable CMDEF_DISTRO_ID if defined
6868
1. auto filled by CMDEF library (by `lsb_release` utility)
6969

70-
## CMDEF_DISTRO_VERSION_ID:STRING=\<conditional\>
70+
## CMDEF_DISTRO_VERSION_ID:STRING=\<conditional>
7171

7272
Distribution version ID (eg for debian bullseye: 11, ...). It always holds lowercase value...
7373

doc/PackageChain.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CMDEF_ADD_EXECUTABLE(
5050

5151
Configure installation of a target, that will export it and create the target's `.cmake` file.
5252

53-
`NAMESPACE` is **required** when using the whole chain and it must be **equal** to the name of the **main target**.
53+
`NAMESPACE` is **optional** but **recommended** when using the whole chain. When specified, it must be **equal** to the name of the **main target** and end with `::`. If using `CMDEF_PACKAGE`, the namespace consistency is validated automatically.
5454
> **main target** - the 'object' for which we create the CMake project. It relates to CMDEF_PACKAGE
5555
5656
#### Example
@@ -106,7 +106,7 @@ make install # Install cmake files, mylib-shared.so and myexecutable to <instal
106106
cpack # Create archive libmylib-shared-dev_1.0.0_<architecture>.zip
107107
```
108108

109-
> Note that when `CMAKE_BUILD_TYPE=Debug`, the libraries and executables **OUTPUT_NAME** will have a suffix `d` added to them.
109+
> Note that when `CMAKE_BUILD_TYPE=Debug`, the libraries and executables **OUTPUT_NAME** will have a debug suffix added to them (controlled by `CMDEF_EXECUTABLE_NAME_DEBUG_SUFFIX`, typically `d`).
110110
111111
The created package has the following structure:
112112

doc/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# Detailed Documentation for CMDEF Component
3+
4+
This directory contains detailed documentation for the CMDEF component of the CMake-lib library.
5+
6+
## Documentation Files
7+
8+
- [CacheVariables.md](CacheVariables.md): Describes all cache variables used by the CMDEF component.
9+
- [PackageChain.md](PackageChain.md): Explains the package chain workflow and functions provided by CMDEF.

example/executable/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ PROJECT(${CMAKE_PROJECT_NAME})
1414
FIND_PACKAGE(CMLIB COMPONENTS CMDEF)
1515

1616

17+
CMDEF_CLEANUP()
1718

1819
#
1920
# Add Definitions for each build type globally
@@ -36,7 +37,7 @@ IF(CMDEF_OS_LINUX)
3637
)
3738
ELSEIF(CMDEF_OS_WINDOWS)
3839
CMDEF_COMPILE_OPTIONS(
39-
ALL /wd4996 # Disable deprectation warning on Windows OS
40+
ALL /wd4996 # Disable deprecation warning on Windows OS
4041
)
4142
ENDIF()
4243

@@ -53,7 +54,7 @@ CMDEF_ADD_EXECUTABLE(
5354

5455
CMDEF_COMPILE_DEFINITIONS_TARGET(
5556
TARGET executable
56-
VISIBLITY PUBLIC
57+
VISIBILITY PUBLIC
5758
ALL RETURN_CODE=245
5859
DEBUG RETURN_CODE_DEBUG=1000
5960
RELEASE RETURN_CODE_RELEASE=2020
@@ -66,7 +67,7 @@ CMDEF_COMPILE_DEFINITIONS_TARGET(
6667
ADD_EXECUTABLE(cmake_executable main.c)
6768
CMDEF_COMPILE_DEFINITIONS_TARGET(
6869
TARGET cmake_executable
69-
VISIBLITY PRIVATE
70+
VISIBILITY PRIVATE
7071
ALL RETURN_CODE=255
7172
DEBUG RETURN_CODE_DEBUG=10000
7273
RELEASE RETURN_CODE_RELEASE=20200
@@ -93,4 +94,4 @@ CMDEF_PACKAGE(
9394
# Just choose generator and include CPack
9495
#
9596
SET(CPACK_GENERATOR ZIP)
96-
INCLUDE(CPack)
97+
INCLUDE(CPack)

example/library-interface/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ CMDEF_INSTALL(TARGET testlink-executable NAMESPACE testlib-shared::)
104104
#
105105
CMDEF_COMPILE_OPTIONS_TARGET(
106106
TARGET testlib-shared
107-
VISIBLITY PUBLIC
107+
VISIBILITY PUBLIC
108108
DEBUG -Wall
109109
)
110110

example/library-interface/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @brief Test exacutable to test all defined symbols are linked correctly
2+
* @brief Test executable to test all defined symbols are linked correctly
33
*/
44

55
#include <testlib/printAllMessages.hpp>

0 commit comments

Comments
 (0)