Skip to content

Commit

Permalink
fix docs. fix naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Aug 1, 2024
1 parent 1b29314 commit ff16528
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
# bs
A project generation tool for library package modules and dependencies.

### Functions
* `bs_project(<major_version> <minor_version>)`
### Main functions
* `bs_init()`
* `bs_configure_packages(<package_rel_dir> [<used_package>...])`
* `bs_generate_package(<pkg_name> [<dependency_target>...])`

### Support functions
* `bs_truncate_path(<root_path> <full_path>)`
* `bs_copy_data(<relative_path>)`
* `bs_set_pedantic_flags(<pkg_name>)`
* `bs_copy_to_binary_dir(<relative_path>)`

### Typical usage:
```
cmake_minimum_required (VERSION 3.0.2)
list(APPEND CMAKE_MODULE_PATH <CMAKE_CURRENT_LIST_DIR>/cmake)
include(bs)
bs_project(<project name>)
bs_init()
set(PACKAGE_NAMES
logging
testing
)
# packages in folder "packages"
bs_configure_packages("packages" "${PACKAGE_NAMES}")
```

### Packages
Expand All @@ -25,33 +34,33 @@ Package interdependency is not managed and should be designed hierarchially by t
Your packages are expected to have a specific layout. See below.
All folders in a package are scanned recursively.

### Package folder layout of a package 'packagename'
package_name
### Package folder layout of a package 'pkg_name'
`<pkg_name>`
* include
* source
* tests
* CMakeLists.txt

include
* package_name (use the package name to add include path structure)
** further structure etc
* `<pkg_name>` (use a folder named <pkg_name> to add structure to the include path)
* `<pkg_name>/<further structure etc>`

source
* common (required for all portable translation units)
* other platform name
* `<other platform names>`

tests
* common (source folder for tests)
* data (test data folder accessed in tests with \"./tests/data\")
* data (test data folder accessed in tests with "./tests/data)

Platform specific packages are named as the following
`<package name><CONFIG_PLATFORM>`
and depend on the platform agnostic package <package name> by default
and depend on the platform agnostic package `<pkg_name>` by default

### Example package CMakeLists.txt file
```
cmake_minimum_required (VERSION 3.0.2)
project(<package name>)
project(<pkg_name>)
set(deps [<library targets>...])
bs_generate_package(tools \"\${deps}\")
bs_generate_package(tools "${deps}")
```
8 changes: 3 additions & 5 deletions cmake/bs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ function(bs_copy_to_binary_dir relative_path)
endfunction()

# bs main api
function(bs_project major_version minor_version)
function(bs_init)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 20 PARENT_SCOPE)
set(CXX_STANDARD_REQUIRED ON PARENT_SCOPE)
set(VERSION_MAJOR ${major_version} PARENT_SCOPE)
set(VERSION_MINOR ${minor_version} PARENT_SCOPE)
set(TEST_ROOT ${PROJECT_SOURCE_DIR} PARENT_SCOPE)
set(BS_ROOT_DIR ${PROJECT_SOURCE_DIR} PARENT_SCOPE)

# The platform folder must be identical to CONFIG_PLATFORM for platform source to be found
# This also affects the platform target name similarly
string(TOLOWER ${CMAKE_SYSTEM_NAME} platform_name)
set(BS_CONFIG_PLATFORM ${platform_name} PARENT_SCOPE)
endfunction()

function(bs_setup package_rel_dir used_packages)
function(bs_configure_packages package_rel_dir used_packages)
# add all package libraries directories

foreach(packageName ${used_packages})
Expand Down

0 comments on commit ff16528

Please sign in to comment.