Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7c92895
TYPO in FATAL_ERROR message
koudis Jan 21, 2025
830aae0
Remove obsolete documentation.
koudis Jan 21, 2025
c3b28ae
Forgotten include of CMDEF_CLEANUP
koudis Jan 21, 2025
99363f1
TYPO
koudis Jan 21, 2025
e201587
Update TYPOS
koudis Jan 22, 2025
2803091
Reapply "Remove explicit need of uname and lsb_release file"
koudis Apr 11, 2025
79b2a25
Make use `uname -m` again to detect processor architecture
koudis Apr 12, 2025
7354f36
First tests initialized
koudis Apr 12, 2025
f844cb0
Context documentation updated
koudis Jun 16, 2025
0631468
Merge pull request #10 from cmakelib/jan_kubalek/lsb_release_remove
koudis Jun 16, 2025
da2ddd6
tests - handle cache variables properly
koudis Jun 16, 2025
356a888
Merge remote-tracking branch 'origin/jan_kubalek/remove_lsbrelease_ag…
koudis Jun 16, 2025
3a7563a
Repair Link requirements
koudis Jun 16, 2025
fb8cc7b
remove unused test files
koudis Jun 16, 2025
cb0875f
Update condition to match prefix correctly
koudis Jun 16, 2025
e4024a5
Update required CMake to 3.22
koudis Jun 17, 2025
fa399e4
Add github ci/cd fir GNU/Linux
koudis Jun 17, 2025
5f95cd8
Github ci/cd - add macos
koudis Jun 17, 2025
b2cb814
github ci/cd update
koudis Jun 17, 2025
664be3a
Update
koudis Jun 17, 2025
5457d22
Github ci/cd - windows
koudis Jun 17, 2025
563fceb
Update
koudis Jun 17, 2025
18fd5cf
TYPOs in system detection
koudis Jun 17, 2025
df6d517
Mac OSX bundle fix
koudis Jun 17, 2025
c561b66
Add github ci/cd for GNU/Linux
koudis Jun 17, 2025
b9dd501
TYPOs in system detection
koudis Jun 17, 2025
9e3977b
Mac OSX bundle fix
koudis Jun 17, 2025
2db7e4d
Set correct Windows flags
koudis Jun 17, 2025
ffa84ba
Merge remote-tracking branch 'origin/jan_kubalek/remove_lsbrelease_ag…
koudis Jun 17, 2025
149d0fb
Use Proper tests for Executable.
koudis Jun 17, 2025
a74f709
ADD_LIBRARY test fixes
koudis Jun 17, 2025
b3e7e44
CMDEF_ADD_LIBRARY update
koudis Jun 17, 2025
48f1477
Update tests for ADD_EXECUTABLE and PACKAGE
koudis Jun 17, 2025
79e6a3f
Documentation, readme, bugfix
koudis Jun 17, 2025
a368df8
POSIX
koudis Jun 17, 2025
0306459
Update tests cases.
koudis Jun 18, 2025
96c5e47
Update win32
koudis Jun 18, 2025
6e19bde
Remove test resource file
koudis Jun 20, 2025
60ce31e
Simplify and update documentation, TYPOs
koudis Jun 20, 2025
64a38fb
Use CMAKE_SYSTEM_NAME instead of CMAKE_HOST_INFO macros
koudis Jul 2, 2025
7795692
DEPENDENCY - Transitive Dependency warning
koudis Jul 10, 2025
c41852d
TYPOS in documentation and better messages
koudis Jul 11, 2025
d8c6954
Update warnings tests
koudis Jul 11, 2025
9e1126e
Remove unnecessary __ in function argument
koudis Jul 11, 2025
b307fd8
CI/CD update
koudis Jul 12, 2025
51accc2
GitHub Actions update
koudis Jul 13, 2025
100f9f6
Update to version 1.0.0
koudis Jul 15, 2025
f4c1e9b
FIX - update version in windows
koudis Jul 15, 2025
316dabc
Remove forgotten dump variables
koudis Jul 15, 2025
b35ecc7
CI/CD - fix typos and update checkout
koudis Jul 15, 2025
9362789
Update main README to reflect the library usage
koudis Jul 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- '*'
workflow_dispatch:

env:
CMLIB_VERSION: 1.0.0

jobs:
test_linux:
strategy:
matrix:
image: [
"test_debian:bullseye",
"test_debian:trixie",
"test_debian:bookworm",
"test_ubuntu:2004",
"test_ubuntu:2204",
"test_ubuntu:2404",
"test_fedora:41",
"test_fedora:42"
]

runs-on: ubuntu-latest
container:
image: ghcr.io/cmakelib/${{ matrix.image }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run tests
run: |
git config --global --add safe.directory "$(pwd)"
git remote set-url origin "${{ github.server_url }}/${{ github.repository }}"
git clone --branch "v${CMLIB_VERSION}" https://github.com/cmakelib/cmakelib.git
export CMLIB_DIR=$(pwd)/cmakelib
cd test/ && cmake .

test_macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run tests
run: |
git config --global --add safe.directory "$(pwd)"
git remote set-url origin "${{ github.server_url }}/${{ github.repository }}"
git clone --branch "v${CMLIB_VERSION}" https://github.com/cmakelib/cmakelib.git
export CMLIB_DIR=$(pwd)/cmakelib
cd test/ && cmake .

test_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run tests
run: |
git config --global --add safe.directory "$(pwd)"
git remote set-url origin "${{ github.server_url }}/${{ github.repository }}"
git clone --branch "v$Env:CMLIB_VERSION" https://github.com/cmakelib/cmakelib.git
$Env:CMLIB_DIR=$(Join-Path -Path $(Get-Location).Path -ChildPath "cmakelib")
cd test/ && cmake .
2 changes: 1 addition & 1 deletion CMDEFConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FinDBASEDEF.cmake")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindCMDEF.cmake")
4 changes: 3 additions & 1 deletion FindCMDEF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# - include all CMDEF modules
#

CMAKE_MINIMUM_REQUIRED(VERSION 3.21 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 3.22 FATAL_ERROR)

SET(CMDEF_PACKAGE_NAME "CMDEF")

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

INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_CLEANUP.cmake)

INCLUDE(${CMAKE_CURRENT_LIST_DIR}/system_modules/CMDEF_HELPER.cmake)

48 changes: 30 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@

# CMake-lib Basedef component
# CMake-lib Definition Framework Component

CMake-lib provides consistent setting for built environment.
Linux: ![buildbadge_github], Windows: ![buildbadge_github], Mac OS: ![buildbadge_github]

CMDEF aka **CMake-lib Definition Framework**

CMake-lib provides consistent settings for build environment.
It simplifies and maintains built option, libraries and executables.

## Requirements

- [CMLIB] library installed
CMDEF is intended to be used thru [CMLIB].

CMDEF is not supposed to be used separately.

To use the library install [CMLIB] and call `FIND_PACKAGE(CMLIB COMPONENTS CMDEF)`

## General

The library is not mainly intended for extending CMake functionality.

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

### Definition of Main target

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

For example we have CMake project for building chrome browser.
Browser is represented by one executable called `chrome`. That executable
For example - CMake project for building chrome browser.
Browser is represented by the executable called `chrome`. The executable
must have own target in CMake project.

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

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

## Usage

Let GIT_URI be a GIT URI of this repository.

```cmake
FIND_PACKAGE(CMLIB COMPONENTS CMDEF)
```

### Set build defaults

CMake-lib sets and maintains build/link flags and global wide definitions
CMake-lib sets and maintains build and link flags and global wide definitions.

Component workflow

- reset CMake default build flags by `CMDEF_CLEANUP`
- set default build and link options by `CMDEF_COMPILE_OPTIONS`, `CMDEF_LINK_OPTIONS`
- set compile definitions by `CMDEF_COMPIE_DEFINITIONS`
- set compile definitions by `CMDEF_COMPILE_DEFINITIONS`

examples can be found at [example] directory
examples can be found at [example] directory.

## Function list

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

Detailed documentation for each function can be found at appropriate module.
Detailed documentation for each function can be found at the appropriate module.

- [CMDEF_ADD_LIBRARY.cmake]
- [CMDEF_ADD_EXECUTABLE.cmake]
Expand All @@ -67,13 +74,15 @@ Detailed documentation for each function can be found at appropriate module.
- [CMDEF_LINK_OPTION.cmake]
- [CMDEF_PACKAGE.cmake]

## Config Variables
## Documentation

Every function has a comprehensive documentation written as part of the function definition.

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

## Coding standards

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

[CMLIB]: https://github.com/cmakelib/cmakelib
Expand All @@ -88,4 +97,7 @@ Configuration variables detailed desc. for the library is located at [doc/CacheV
[CMDEF_LINK_OPTION.cmake]: system_modules/CMDEF_LINK_OPTION.cmake
[CMDEF_PACKAGE.cmake]: system_modules/CMDEF_PACKAGE.cmake
[doc/CacheVariables.md]: doc/CacheVariables.md
[doc/README.md]: doc/README.md
[example]: example/

[buildbadge_github]: https://github.com/cmakelib/cmakelib-component-cmdef/actions/workflows/tests.yml/badge.svg
10 changes: 5 additions & 5 deletions doc/CacheVariables.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# CMDEf cache variables
# CMDEF cache variables

Each section represent one Cache variable used in CMDEF.

Expand Down Expand Up @@ -31,10 +31,10 @@ It tries to set the variable in the following order

## CMDEF_BUILD_TYPE_CMAKE_BUILD_TYPE_OVERRIDE:BOOL=\<conditional>

Indicate if the CMAKE_BUILD_TYPE is overriden by CMDEF library.
Indicate if the CMAKE_BUILD_TYPE is overridden by CMDEF library.

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

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

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

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

Type: String, List

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

## CMDEF_DISTRO_VERSION_ID:STRING=\<conditional\>
## CMDEF_DISTRO_VERSION_ID:STRING=\<conditional>

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

Expand Down
4 changes: 2 additions & 2 deletions doc/PackageChain.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ CMDEF_ADD_EXECUTABLE(

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

`NAMESPACE` is **required** when using the whole chain and it must be **equal** to the name of the **main target**.
`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.
> **main target** - the 'object' for which we create the CMake project. It relates to CMDEF_PACKAGE

#### Example
Expand Down Expand Up @@ -106,7 +106,7 @@ make install # Install cmake files, mylib-shared.so and myexecutable to <instal
cpack # Create archive libmylib-shared-dev_1.0.0_<architecture>.zip
```

> Note that when `CMAKE_BUILD_TYPE=Debug`, the libraries and executables **OUTPUT_NAME** will have a suffix `d` added to them.
> 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`).

The created package has the following structure:

Expand Down
9 changes: 9 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# Detailed Documentation for CMDEF Component

This directory contains detailed documentation for the CMDEF component of the CMake-lib library.

## Documentation Files

- [CacheVariables.md](CacheVariables.md): Describes all cache variables used by the CMDEF component.
- [PackageChain.md](PackageChain.md): Explains the package chain workflow and functions provided by CMDEF.
9 changes: 5 additions & 4 deletions example/executable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PROJECT(${CMAKE_PROJECT_NAME})
FIND_PACKAGE(CMLIB COMPONENTS CMDEF)


CMDEF_CLEANUP()

#
# Add Definitions for each build type globally
Expand All @@ -36,7 +37,7 @@ IF(CMDEF_OS_LINUX)
)
ELSEIF(CMDEF_OS_WINDOWS)
CMDEF_COMPILE_OPTIONS(
ALL /wd4996 # Disable deprectation warning on Windows OS
ALL /wd4996 # Disable deprecation warning on Windows OS
)
ENDIF()

Expand All @@ -53,7 +54,7 @@ CMDEF_ADD_EXECUTABLE(

CMDEF_COMPILE_DEFINITIONS_TARGET(
TARGET executable
VISIBLITY PUBLIC
VISIBILITY PUBLIC
ALL RETURN_CODE=245
DEBUG RETURN_CODE_DEBUG=1000
RELEASE RETURN_CODE_RELEASE=2020
Expand All @@ -66,7 +67,7 @@ CMDEF_COMPILE_DEFINITIONS_TARGET(
ADD_EXECUTABLE(cmake_executable main.c)
CMDEF_COMPILE_DEFINITIONS_TARGET(
TARGET cmake_executable
VISIBLITY PRIVATE
VISIBILITY PRIVATE
ALL RETURN_CODE=255
DEBUG RETURN_CODE_DEBUG=10000
RELEASE RETURN_CODE_RELEASE=20200
Expand All @@ -93,4 +94,4 @@ CMDEF_PACKAGE(
# Just choose generator and include CPack
#
SET(CPACK_GENERATOR ZIP)
INCLUDE(CPack)
INCLUDE(CPack)
2 changes: 1 addition & 1 deletion example/library-interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ CMDEF_INSTALL(TARGET testlink-executable NAMESPACE testlib-shared::)
#
CMDEF_COMPILE_OPTIONS_TARGET(
TARGET testlib-shared
VISIBLITY PUBLIC
VISIBILITY PUBLIC
DEBUG -Wall
)

Expand Down
2 changes: 1 addition & 1 deletion example/library-interface/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @brief Test exacutable to test all defined symbols are linked correctly
* @brief Test executable to test all defined symbols are linked correctly
*/

#include <testlib/printAllMessages.hpp>
Expand Down
2 changes: 1 addition & 1 deletion example/library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CMDEF_ADD_LIBRARY(
#
CMDEF_COMPILE_OPTIONS_TARGET(
TARGET testlib-shared
VISIBLITY PUBLIC
VISIBILITY PUBLIC
DEBUG -Wall
)

Expand Down
2 changes: 1 addition & 1 deletion system_modules/CMDEF_ADD_EXECUTABLE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ FUNCTION(CMDEF_ADD_EXECUTABLE)
IF(CMDEF_OS_WINDOWS AND __WIN32)
SET(exec_flag WIN32)
ELSEIF(CMDEF_OS_MACOS AND __MACOS_BUNDLE)
SET(exec_flag MACOS_BUNDLE)
SET(exec_flag MACOSX_BUNDLE)
ENDIF()

SET(output_name ${__TARGET})
Expand Down
6 changes: 3 additions & 3 deletions system_modules/CMDEF_ADD_LIBRARY.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMDEF_RESOURCE.cmake)
# SOURCES - all c/cpp/h/hpp files will be added as source to given target.
#
# SOURCE_BASE_DIRECTORY - INTERFACE library only. Only for installation.
# It is base directory for all source files.
# If defined, source files will be installed with relative path from this directory.
# Else, source files will be installed directly in CMDEF_SOURCE_INSTALL_DIR
# It is base directory for all source files.
# If defined, source files specified by SOURCES will be installed with relative path respective to SOURCE_BASE_DIRECTORY.
# Else, source files specified by SOURCES will be installed directly into CMDEF_SOURCE_INSTALL_DIR.
#
# [Custom properties]
# CMDEF_LIBRARY - property which mark library as "created by CMDEF_ADD_LIBRARY"
Expand Down
4 changes: 2 additions & 2 deletions system_modules/CMDEF_BUILD_TYPE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SET(CMDEF_BUILD_TYPE_DEFAULT "Debug"
MACRO(_CMDEF_BUILD_TYPE_SET_CMAKE_BUILD_TYPE_OVERRIDE opt ${ARGN})
SET(CMDEF_BUILD_TYPE_CMAKE_BUILD_TYPE_OVERRIDE ${opt}
CACHE BOOL
"ON if the CMAKE_BUILD_TYPE is overriden by CMDEF, OFF otherwise"
"ON if the CMAKE_BUILD_TYPE is overridden by CMDEF, OFF otherwise"
${ARGN}
)
ENDMACRO()
Expand Down Expand Up @@ -65,7 +65,7 @@ UNSET(all_find)


##
# Initialize CMake veriables according to CMDEF definitions
# Initialize CMake variables according to CMDEF definitions
#
# <function>(
# )
Expand Down
Loading
Loading