From f4b55ec0f5550460a1f0c87758fdfa031a7354d9 Mon Sep 17 00:00:00 2001 From: Edward Nolan Date: Mon, 29 Sep 2025 11:08:40 -0400 Subject: [PATCH 1/6] WIP Draft: Convert exemplar into an INTERFACE library This commit eliminates the src/ directory, moving beman.examplar-config.cmake.in into the top level directory, moving the contents of src/beman/exemplar/CMakeLists.txt into the top level CMakeLists.txt, removing identity.cpp, and changing beman.exemplar from STATIC/SHARED into INTERFACE. This commit is currently just intended to be a jumping-off point for discussion. What I would like to do if we are okay with this direction is to preserve the option for users to create STATIC/SHARED libraries by configuring cookiecutter differently. That feature is not present yet here. --- CMakeLists.txt | 19 ++++++++++++++++-- ...cmake.in => beman.exemplar-config.cmake.in | 0 .../CMakeLists.txt | 19 ++++++++++++++++-- ...ookiecutter.project_name}}-config.cmake.in | 0 .../CMakeLists.txt | 20 ------------------- .../identity.cpp | 3 --- src/beman/exemplar/CMakeLists.txt | 20 ------------------- src/beman/exemplar/identity.cpp | 3 --- 8 files changed, 34 insertions(+), 50 deletions(-) rename src/beman/exemplar/beman.exemplar-config.cmake.in => beman.exemplar-config.cmake.in (100%) rename cookiecutter/{{cookiecutter.project_name}}/{src/beman/{{cookiecutter.project_name}} => }/beman.{{cookiecutter.project_name}}-config.cmake.in (100%) delete mode 100644 cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/CMakeLists.txt delete mode 100644 cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/identity.cpp delete mode 100644 src/beman/exemplar/CMakeLists.txt delete mode 100644 src/beman/exemplar/identity.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c098765d..4fd233ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,9 +24,24 @@ option( ${PROJECT_IS_TOP_LEVEL} ) -include(CTest) +add_library(beman.exemplar INTERFACE) +add_library(beman::exemplar ALIAS beman.exemplar) + +target_sources( + beman.exemplar + PUBLIC + FILE_SET HEADERS + BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/include/beman/exemplar/identity.hpp" +) + +set_target_properties(beman.exemplar PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON) -add_subdirectory(src/beman/exemplar) +find_package(beman-install-library REQUIRED) +beman_install_library(beman.exemplar) + +include(CTest) if(BEMAN_EXEMPLAR_BUILD_TESTS) add_subdirectory(tests/beman/exemplar) diff --git a/src/beman/exemplar/beman.exemplar-config.cmake.in b/beman.exemplar-config.cmake.in similarity index 100% rename from src/beman/exemplar/beman.exemplar-config.cmake.in rename to beman.exemplar-config.cmake.in diff --git a/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt b/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt index dcad0c2c..b0f73063 100644 --- a/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt +++ b/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt @@ -24,9 +24,24 @@ option( ${PROJECT_IS_TOP_LEVEL} ) -include(CTest) +add_library(beman.{{cookiecutter.project_name}} INTERFACE) +add_library(beman::{{cookiecutter.project_name}} ALIAS beman.{{cookiecutter.project_name}}) + +target_sources( + beman.{{cookiecutter.project_name}} + PUBLIC + FILE_SET HEADERS + BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/include/beman/{{cookiecutter.project_name}}/identity.hpp" +) + +set_target_properties(beman.{{cookiecutter.project_name}} PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON) -add_subdirectory(src/beman/{{cookiecutter.project_name}}) +find_package(beman-install-library REQUIRED) +beman_install_library(beman.{{cookiecutter.project_name}}) + +include(CTest) if(BEMAN_{{cookiecutter.project_name.upper()}}_BUILD_TESTS) add_subdirectory(tests/beman/{{cookiecutter.project_name}}) diff --git a/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/beman.{{cookiecutter.project_name}}-config.cmake.in b/cookiecutter/{{cookiecutter.project_name}}/beman.{{cookiecutter.project_name}}-config.cmake.in similarity index 100% rename from cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/beman.{{cookiecutter.project_name}}-config.cmake.in rename to cookiecutter/{{cookiecutter.project_name}}/beman.{{cookiecutter.project_name}}-config.cmake.in diff --git a/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/CMakeLists.txt b/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/CMakeLists.txt deleted file mode 100644 index ba64430a..00000000 --- a/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -add_library(beman.{{cookiecutter.project_name}}) -add_library(beman::{{cookiecutter.project_name}} ALIAS beman.{{cookiecutter.project_name}}) - -target_sources(beman.{{cookiecutter.project_name}} PRIVATE identity.cpp) - -target_sources( - beman.{{cookiecutter.project_name}} - PUBLIC - FILE_SET HEADERS - BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../include" - FILES - "${CMAKE_CURRENT_SOURCE_DIR}/../../../include/beman/{{cookiecutter.project_name}}/identity.hpp" -) - -set_target_properties(beman.{{cookiecutter.project_name}} PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON) - -find_package(beman-install-library REQUIRED) -beman_install_library(beman.{{cookiecutter.project_name}}) diff --git a/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/identity.cpp b/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/identity.cpp deleted file mode 100644 index 1d076c7a..00000000 --- a/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/identity.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#include diff --git a/src/beman/exemplar/CMakeLists.txt b/src/beman/exemplar/CMakeLists.txt deleted file mode 100644 index 14d9f70e..00000000 --- a/src/beman/exemplar/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -add_library(beman.exemplar) -add_library(beman::exemplar ALIAS beman.exemplar) - -target_sources(beman.exemplar PRIVATE identity.cpp) - -target_sources( - beman.exemplar - PUBLIC - FILE_SET HEADERS - BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../include" - FILES - "${CMAKE_CURRENT_SOURCE_DIR}/../../../include/beman/exemplar/identity.hpp" -) - -set_target_properties(beman.exemplar PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON) - -find_package(beman-install-library REQUIRED) -beman_install_library(beman.exemplar) diff --git a/src/beman/exemplar/identity.cpp b/src/beman/exemplar/identity.cpp deleted file mode 100644 index 21ef59d5..00000000 --- a/src/beman/exemplar/identity.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#include From 71e97d99930a8db93405f32a1cffb4b463979097 Mon Sep 17 00:00:00 2001 From: wusatosi <26424577+wusatosi@users.noreply.github.com> Date: Sun, 23 Nov 2025 17:42:14 -0800 Subject: [PATCH 2/6] remove dynamic CI config --- .github/workflows/ci_tests.yml | 4 ++-- .../.github/workflows/ci_tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 4ae60bf0..a6c0352f 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -43,7 +43,7 @@ jobs: { "stdlibs": ["libstdc++"], "tests": [ "Debug.Default", "Release.Default", "Release.TSan", - "Release.MaxSan", "Debug.Werror", "Debug.Dynamic", + "Release.MaxSan", "Debug.Werror", "Debug.Coverage" ] } @@ -78,7 +78,7 @@ jobs: { "stdlibs": ["libstdc++", "libc++"], "tests": [ "Debug.Default", "Release.Default", "Release.TSan", - "Release.MaxSan", "Debug.Werror", "Debug.Dynamic" + "Release.MaxSan", "Debug.Werror" ] } ] diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml index 4ae60bf0..a6c0352f 100644 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml +++ b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml @@ -43,7 +43,7 @@ jobs: { "stdlibs": ["libstdc++"], "tests": [ "Debug.Default", "Release.Default", "Release.TSan", - "Release.MaxSan", "Debug.Werror", "Debug.Dynamic", + "Release.MaxSan", "Debug.Werror", "Debug.Coverage" ] } @@ -78,7 +78,7 @@ jobs: { "stdlibs": ["libstdc++", "libc++"], "tests": [ "Debug.Default", "Release.Default", "Release.TSan", - "Release.MaxSan", "Debug.Werror", "Debug.Dynamic" + "Release.MaxSan", "Debug.Werror" ] } ] From 3019cff1dd545387b163a69b8546cd361db9f07c Mon Sep 17 00:00:00 2001 From: wusatosi <26424577+wusatosi@users.noreply.github.com> Date: Sun, 23 Nov 2025 17:51:41 -0800 Subject: [PATCH 3/6] update README to reflect new dir structure --- README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 85a1cb22..c70acec8 100644 --- a/README.md +++ b/README.md @@ -312,7 +312,6 @@ cmake -B build -S . -DCMAKE_CXX_STANDARD=20 -DBEMAN_EXEMPLAR_BUILD_TESTS=OFF Enable building examples. Default: ON. Values: { ON, OFF }. - #### `BEMAN_EXEMPLAR_INSTALL_CONFIG_FILE_PACKAGE` Enable installing the CMake config file package. Default: ON. @@ -377,11 +376,9 @@ This will generate the following directory structure at `/opt/beman`. │ └── exemplar │ └── identity.hpp └── lib - ├── cmake - │   └── beman.exemplar - │   ├── beman.exemplar-config-version.cmake - │   ├── beman.exemplar-config.cmake - │   ├── beman.exemplar-targets-debug.cmake - │   └── beman.exemplar-targets.cmake - └── libbeman.exemplar.a + └── cmake + └── beman.exemplar + ├── beman.exemplar-config-version.cmake + ├── beman.exemplar-config.cmake + └── beman.exemplar-targets.cmake ``` From e0141a18852a35100d708e8bd1c0ced11eeedafc Mon Sep 17 00:00:00 2001 From: wusatosi <26424577+wusatosi@users.noreply.github.com> Date: Sun, 23 Nov 2025 17:58:18 -0800 Subject: [PATCH 4/6] update cookiecutter --- README.md | 5 ++--- .../{{cookiecutter.project_name}}/README.md | 20 ++++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c70acec8..3b487f39 100644 --- a/README.md +++ b/README.md @@ -357,10 +357,9 @@ any libraries or executables that include `beman.exemplar` headers. target_link_libraries(yourlib PUBLIC beman::exemplar) ``` -### Produce beman.exemplar static library +### Produce beman.exemplar library -You can include exemplar's headers locally -by producing a static `libbeman.exemplar.a` library. +You can install exemplar's headers locally by: ```bash cmake --workflow --preset gcc-release diff --git a/cookiecutter/{{cookiecutter.project_name}}/README.md b/cookiecutter/{{cookiecutter.project_name}}/README.md index 874ca814..01ea9ff9 100644 --- a/cookiecutter/{{cookiecutter.project_name}}/README.md +++ b/cookiecutter/{{cookiecutter.project_name}}/README.md @@ -312,7 +312,6 @@ cmake -B build -S . -DCMAKE_CXX_STANDARD=20 -DBEMAN_{{cookiecutter.project_name. Enable building examples. Default: ON. Values: { ON, OFF }. - #### `BEMAN_{{cookiecutter.project_name.upper()}}_INSTALL_CONFIG_FILE_PACKAGE` Enable installing the CMake config file package. Default: ON. @@ -358,10 +357,9 @@ any libraries or executables that include `beman.{{cookiecutter.project_name}}` target_link_libraries(yourlib PUBLIC beman::{{cookiecutter.project_name}}) ``` -### Produce beman.{{cookiecutter.project_name}} static library +### Produce beman.{{cookiecutter.project_name}} library -You can include {{cookiecutter.project_name}}'s headers locally -by producing a static `libbeman.{{cookiecutter.project_name}}.a` library. +You can install {{cookiecutter.project_name}}'s headers locally by: ```bash cmake --workflow --preset gcc-release @@ -374,14 +372,12 @@ This will generate the following directory structure at `/opt/beman`. /opt/beman ├── include │ └── beman -│ └── {{cookiecutter.project_name}} +│ └── exemplar │ └── identity.hpp └── lib - ├── cmake - │   └── beman.{{cookiecutter.project_name}} - │   ├── beman.{{cookiecutter.project_name}}-config-version.cmake - │   ├── beman.{{cookiecutter.project_name}}-config.cmake - │   ├── beman.{{cookiecutter.project_name}}-targets-debug.cmake - │   └── beman.{{cookiecutter.project_name}}-targets.cmake - └── libbeman.{{cookiecutter.project_name}}.a + └── cmake + └── beman.exemplar + ├── beman.exemplar-config-version.cmake + ├── beman.exemplar-config.cmake + └── beman.exemplar-targets.cmake ``` From bf74f21698585291a9737539bde11f7a476fface Mon Sep 17 00:00:00 2001 From: wusatosi <26424577+wusatosi@users.noreply.github.com> Date: Sun, 23 Nov 2025 19:20:51 -0800 Subject: [PATCH 5/6] update file tree --- cookiecutter/{{cookiecutter.project_name}}/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cookiecutter/{{cookiecutter.project_name}}/README.md b/cookiecutter/{{cookiecutter.project_name}}/README.md index 01ea9ff9..b4035717 100644 --- a/cookiecutter/{{cookiecutter.project_name}}/README.md +++ b/cookiecutter/{{cookiecutter.project_name}}/README.md @@ -372,12 +372,12 @@ This will generate the following directory structure at `/opt/beman`. /opt/beman ├── include │ └── beman -│ └── exemplar +│ └── {{cookiecutter.project_name}} │ └── identity.hpp └── lib └── cmake - └── beman.exemplar - ├── beman.exemplar-config-version.cmake - ├── beman.exemplar-config.cmake - └── beman.exemplar-targets.cmake + └── beman.{{cookiecutter.project_name}} + ├── beman.{{cookiecutter.project_name}}-config-version.cmake + ├── beman.{{cookiecutter.project_name}}-config.cmake + └── beman.{{cookiecutter.project_name}}-targets.cmake ``` From 36dd20fba7c00bbaa891e13544e3c623d20fafb9 Mon Sep 17 00:00:00 2001 From: wusatosi <26424577+wusatosi@users.noreply.github.com> Date: Sun, 23 Nov 2025 20:57:37 -0800 Subject: [PATCH 6/6] update cookie cutter to allow production of both interface and static library --- README.md | 4 +-- cookiecutter/check_cookiecutter.sh | 3 ++- cookiecutter/cookiecutter.json | 7 ++--- cookiecutter/hooks/post_gen_project.py | 19 +++++++++++++ .../.github/workflows/ci_tests.yml | 6 +++-- .../.github/workflows/pre-commit-update.yml | 3 +++ .../CMakeLists.txt | 4 +++ .../{{cookiecutter.project_name}}/README.md | 27 +++++++++++++++++-- .../CMakeLists.txt | 20 ++++++++++++++ ...ookiecutter.project_name}}-config.cmake.in | 0 .../identity.cpp | 7 +++++ 11 files changed, 90 insertions(+), 10 deletions(-) create mode 100755 cookiecutter/hooks/post_gen_project.py create mode 100644 cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/CMakeLists.txt rename cookiecutter/{{cookiecutter.project_name}}/{ => src/beman/{{cookiecutter.project_name}}}/beman.{{cookiecutter.project_name}}-config.cmake.in (100%) create mode 100644 cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/identity.cpp diff --git a/README.md b/README.md index 3b487f39..e6b0e715 100644 --- a/README.md +++ b/README.md @@ -357,9 +357,9 @@ any libraries or executables that include `beman.exemplar` headers. target_link_libraries(yourlib PUBLIC beman::exemplar) ``` -### Produce beman.exemplar library +### Produce beman.exemplar interface library -You can install exemplar's headers locally by: +You can produce exemplar's interface library locally by: ```bash cmake --workflow --preset gcc-release diff --git a/cookiecutter/check_cookiecutter.sh b/cookiecutter/check_cookiecutter.sh index fb5cb04c..7d3ae0cc 100755 --- a/cookiecutter/check_cookiecutter.sh +++ b/cookiecutter/check_cookiecutter.sh @@ -18,7 +18,8 @@ function check_consistency() { paper="P0898R3" \ owner="bemanproject" \ description="A Beman Library Exemplar" \ - godbolt_link="https://godbolt.org/z/4qEPK87va" + godbolt_link="https://godbolt.org/z/4qEPK87va" \ + library_type="interface" cp "$script_dir"/../.github/workflows/cookiecutter_test.yml "$out_dir_path"/exemplar/.github/workflows local diff_path diff_path=$(mktemp) diff --git a/cookiecutter/cookiecutter.json b/cookiecutter/cookiecutter.json index a33b87b4..0793d6a6 100644 --- a/cookiecutter/cookiecutter.json +++ b/cookiecutter/cookiecutter.json @@ -5,8 +5,9 @@ "owner": "github-user-name", "description": "Short project description.", "godbolt_link": "https://www.example.com", + "library_type": ["interface", "static"], "_copy_without_render": [ - "infra", - ".github/workflows" - ] + "infra" + ], + "_jinja2_env_vars": {"trim_blocks": true} } diff --git a/cookiecutter/hooks/post_gen_project.py b/cookiecutter/hooks/post_gen_project.py new file mode 100755 index 00000000..98e26321 --- /dev/null +++ b/cookiecutter/hooks/post_gen_project.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +"""Post-generation hook to clean up template files based on library_type.""" + +import shutil +from pathlib import Path + +# Get the library type from cookiecutter context +library_type = "{{ cookiecutter.library_type }}" + +# If interface library, remove the src/ directory (not needed for header-only) +if library_type == "interface": + src_dir = Path("src") + if src_dir.exists(): + shutil.rmtree(src_dir) + print("✓ Removed src/ directory (not needed for interface library)") + +print("✓ Template generation complete") diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml index a6c0352f..447e03f3 100644 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml +++ b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml @@ -44,7 +44,8 @@ jobs: "tests": [ "Debug.Default", "Release.Default", "Release.TSan", "Release.MaxSan", "Debug.Werror", - "Debug.Coverage" + "Debug.Coverage"{% if cookiecutter.library_type == "static" %}, "Debug.Dynamic"{% endif %} + ] } ] @@ -78,7 +79,8 @@ jobs: { "stdlibs": ["libstdc++", "libc++"], "tests": [ "Debug.Default", "Release.Default", "Release.TSan", - "Release.MaxSan", "Debug.Werror" + "Release.MaxSan", "Debug.Werror"{% if cookiecutter.library_type == "static" %}, "Debug.Dynamic"{% endif %} + ] } ] diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-update.yml b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-update.yml index ec7ac74c..ac5b0483 100644 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-update.yml +++ b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-update.yml @@ -7,9 +7,12 @@ on: schedule: - cron: "0 16 * * 0" +{% raw -%} jobs: auto-update-pre-commit: uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-update-pre-commit.yml@1.1.0 secrets: APP_ID: ${{ secrets.AUTO_PR_BOT_APP_ID }} PRIVATE_KEY: ${{ secrets.AUTO_PR_BOT_PRIVATE_KEY }} +{%- endraw %} + diff --git a/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt b/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt index b0f73063..1cd78244 100644 --- a/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt +++ b/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt @@ -24,6 +24,7 @@ option( ${PROJECT_IS_TOP_LEVEL} ) +{% if cookiecutter.library_type == "interface" %} add_library(beman.{{cookiecutter.project_name}} INTERFACE) add_library(beman::{{cookiecutter.project_name}} ALIAS beman.{{cookiecutter.project_name}}) @@ -40,6 +41,9 @@ set_target_properties(beman.{{cookiecutter.project_name}} PROPERTIES VERIFY_INTE find_package(beman-install-library REQUIRED) beman_install_library(beman.{{cookiecutter.project_name}}) +{% else %} +add_subdirectory(src/beman/{{cookiecutter.project_name}}) +{% endif %} include(CTest) diff --git a/cookiecutter/{{cookiecutter.project_name}}/README.md b/cookiecutter/{{cookiecutter.project_name}}/README.md index b4035717..513a44e4 100644 --- a/cookiecutter/{{cookiecutter.project_name}}/README.md +++ b/cookiecutter/{{cookiecutter.project_name}}/README.md @@ -357,9 +357,13 @@ any libraries or executables that include `beman.{{cookiecutter.project_name}}` target_link_libraries(yourlib PUBLIC beman::{{cookiecutter.project_name}}) ``` -### Produce beman.{{cookiecutter.project_name}} library +### Produce beman.{{cookiecutter.project_name}} {{ cookiecutter.library_type }} library -You can install {{cookiecutter.project_name}}'s headers locally by: +{% if cookiecutter.library_type == "interface" %} +You can produce {{cookiecutter.project_name}}'s interface library locally by: +{% else %} +You can produce {{cookiecutter.project_name}}'s static library `libbeman.{{cookiecutter.project_name}}.a` by: +{% endif %} ```bash cmake --workflow --preset gcc-release @@ -368,6 +372,7 @@ cmake --install build/gcc-release --prefix /opt/beman This will generate the following directory structure at `/opt/beman`. +{% if cookiecutter.library_type == "interface" %} ```txt /opt/beman ├── include @@ -380,4 +385,22 @@ This will generate the following directory structure at `/opt/beman`. ├── beman.{{cookiecutter.project_name}}-config-version.cmake ├── beman.{{cookiecutter.project_name}}-config.cmake └── beman.{{cookiecutter.project_name}}-targets.cmake + +``` +{% else %} +```txt +/opt/beman +├── include +│ └── beman +│ └── {{cookiecutter.project_name}} +│ └── identity.hpp +└── lib + ├── cmake + │ └── beman.{{cookiecutter.project_name}} + │ ├── beman.{{cookiecutter.project_name}}-config-version.cmake + │ ├── beman.{{cookiecutter.project_name}}-config.cmake + │ ├── beman.{{cookiecutter.project_name}}-targets-debug.cmake + │ └── beman.{{cookiecutter.project_name}}-targets.cmake + └── libbeman.{{cookiecutter.project_name}}.a ``` +{% endif %} diff --git a/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/CMakeLists.txt b/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/CMakeLists.txt new file mode 100644 index 00000000..14e85036 --- /dev/null +++ b/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/CMakeLists.txt @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_library(beman.{{cookiecutter.project_name}}) +add_library(beman::{{cookiecutter.project_name}} ALIAS beman.{{cookiecutter.project_name}}) + +target_sources( + beman.{{cookiecutter.project_name}} + PUBLIC + FILE_SET HEADERS + BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../include" + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/../../../include/beman/{{cookiecutter.project_name}}/identity.hpp" + PRIVATE + identity.cpp +) + +set_target_properties(beman.{{cookiecutter.project_name}} PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON) + +find_package(beman-install-library REQUIRED) +beman_install_library(beman.{{cookiecutter.project_name}}) diff --git a/cookiecutter/{{cookiecutter.project_name}}/beman.{{cookiecutter.project_name}}-config.cmake.in b/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/beman.{{cookiecutter.project_name}}-config.cmake.in similarity index 100% rename from cookiecutter/{{cookiecutter.project_name}}/beman.{{cookiecutter.project_name}}-config.cmake.in rename to cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/beman.{{cookiecutter.project_name}}-config.cmake.in diff --git a/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/identity.cpp b/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/identity.cpp new file mode 100644 index 00000000..c1729968 --- /dev/null +++ b/cookiecutter/{{cookiecutter.project_name}}/src/beman/{{cookiecutter.project_name}}/identity.cpp @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include + +// Implementation file for static library build. +// For a simple identity function, there's nothing to implement here, +// but this file exists to demonstrate the static library structure.