update
This commit is contained in:
parent
27bcd2adac
commit
bcf2cfd64d
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1 +1 @@
|
||||||
build
|
**/build
|
||||||
|
|
|
||||||
71
cmake_demo/.clang-format
Normal file
71
cmake_demo/.clang-format
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Ultracruise Localization clang-format configuration file
|
||||||
|
# Please seek consensus from the team before modifying this file.
|
||||||
|
#
|
||||||
|
# To compare these settings with all available clang-format options:
|
||||||
|
# diff <(clang-format -dump-config | grep -Ev '^$|^( |BraceWrapping|IncludeCategories)' | sed -Ee 's/: +/: /g' | sort) <(cat .clang-format | grep -Ev '^$|^#' | sort) | colordiff
|
||||||
|
#
|
||||||
|
|
||||||
|
DisableFormat: false
|
||||||
|
Language: Cpp
|
||||||
|
Standard: Cpp11
|
||||||
|
|
||||||
|
# Indentation & whitespace
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
ColumnLimit: 140
|
||||||
|
ConstructorInitializerIndentWidth: 8
|
||||||
|
ContinuationIndentWidth: 8
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MaxEmptyLinesToKeep: 2
|
||||||
|
NamespaceIndentation: None
|
||||||
|
SpacesBeforeTrailingComments: 2
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
# Spacing style
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
PointerAlignment: Left
|
||||||
|
SpaceAfterCStyleCast: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
|
||||||
|
# Comments
|
||||||
|
AlignTrailingComments: true
|
||||||
|
CommentPragmas: ''
|
||||||
|
ReflowComments: true
|
||||||
|
|
||||||
|
# Pattern-based special behavior
|
||||||
|
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||||
|
IncludeCategories: []
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
|
||||||
|
# Alignment & breaking
|
||||||
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignOperands: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
AlwaysBreakTemplateDeclarations: true
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BreakBeforeBinaryOperators: NonAssignment
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: true
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
28
cmake_demo/.gitea/workflows/demo.yaml
Normal file
28
cmake_demo/.gitea/workflows/demo.yaml
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Explore-Gitea-Actions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||||
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
|
||||||
|
- name: Disable SSL verification for Git
|
||||||
|
run: |
|
||||||
|
git config --global http.sslVerify false
|
||||||
|
echo "SSL verification is to: $(git config --global http.sslVerify)."
|
||||||
|
|
||||||
|
- run: echo "💡 Attempting to clone ${{ gitea.repository }}"
|
||||||
|
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
|
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
4
cmake_demo/.gitignore
vendored
Normal file
4
cmake_demo/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
**/build
|
||||||
|
compile_commands.json
|
||||||
|
.cache
|
||||||
|
|
||||||
7
cmake_demo/CMakeLists.txt.bak
Normal file
7
cmake_demo/CMakeLists.txt.bak
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(
|
||||||
|
SimpleLibrary
|
||||||
|
VERSION 1.0.0
|
||||||
|
LANGUAGES CXX)
|
||||||
|
|
||||||
|
add_subdirectory(simple_library)
|
||||||
3
cmake_demo/README.md
Normal file
3
cmake_demo/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# cmake_demo
|
||||||
|
|
||||||
|
demo to create a simple library, consume it in another cmake project, make a conan repo out of it, and make it cpakcable for debian,
|
||||||
56
cmake_demo/simple_caller/CMakeLists.txt
Normal file
56
cmake_demo/simple_caller/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(
|
||||||
|
SimpleCaller
|
||||||
|
VERSION 1.0.0
|
||||||
|
LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
#
|
||||||
|
# auto genrate a stamp header
|
||||||
|
#
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-parse --short HEAD
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_HASH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-parse --abbrev-ref HEAD
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_BRANCH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
set(CUSTOM_VALUE "Blah blah custom value.")
|
||||||
|
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/version.h.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/include/version.h")
|
||||||
|
|
||||||
|
add_custom_target(generate_version_h ALL
|
||||||
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/include/version.h")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build
|
||||||
|
#
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||||
|
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG")
|
||||||
|
set(CMAKE_BUILD_TYPE
|
||||||
|
"Release"
|
||||||
|
CACHE STRING "Choose the type of build." FORCE)
|
||||||
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
|
||||||
|
"RelWithDebInfo")
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||||
|
# file(GLOB_RECURSE HEADERS "include/*.h")
|
||||||
|
|
||||||
|
find_package(simple_library REQUIRED)
|
||||||
|
|
||||||
|
# shared - set_target_properties is so that the binary is libSimpleLibrary.so
|
||||||
|
# add_depdencies so the config.h file is auto generated
|
||||||
|
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||||
|
target_include_directories(${PROJECT_NAME} PUBLIC include)
|
||||||
|
target_link_libraries(${PROJECT_NAME} SimpleLibrary::SimpleLibrary)
|
||||||
|
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "simple_caller")
|
||||||
9
cmake_demo/simple_caller/CMakeUserPresets.json
Normal file
9
cmake_demo/simple_caller/CMakeUserPresets.json
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"vendor": {
|
||||||
|
"conan": {}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"build/Release/generators/CMakePresets.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
4
cmake_demo/simple_caller/README.md
Normal file
4
cmake_demo/simple_caller/README.md
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
```
|
||||||
|
conan install . --build=missing
|
||||||
|
conan build . --name=simple_caller --version=1.0.0 --user=ras --channel=stable
|
||||||
|
```
|
||||||
23
cmake_demo/simple_caller/conanfile.py
Normal file
23
cmake_demo/simple_caller/conanfile.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
from conan import ConanFile
|
||||||
|
from conan.tools.cmake import CMake, cmake_layout
|
||||||
|
|
||||||
|
class SimpleCallerConan(ConanFile):
|
||||||
|
name = "simple_caller"
|
||||||
|
version = "1.0.0"
|
||||||
|
settings = "os", "compiler", "build_type", "arch"
|
||||||
|
requires = "simple_library/1.0.0@ras/stable" # Replace with the actual reference
|
||||||
|
generators = "CMakeDeps", "CMakeToolchain"
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
cmake_layout(self)
|
||||||
|
|
||||||
|
def imports(self):
|
||||||
|
self.copy("*.dll", dst="bin", src="bin")
|
||||||
|
self.copy("*.dylib*", dst="bin", src="lib")
|
||||||
|
self.copy("*.so", dst="bin", src="lib")
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
cmake = CMake(self)
|
||||||
|
cmake.configure()
|
||||||
|
cmake.build()
|
||||||
|
|
||||||
3
cmake_demo/simple_caller/include/header.h
Normal file
3
cmake_demo/simple_caller/include/header.h
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
const char * hello();
|
||||||
11
cmake_demo/simple_caller/include/version.h.in
Normal file
11
cmake_demo/simple_caller/include/version.h.in
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define SIMPLE_LIBRARY_VERSION_MAJOR @SimpleLibrary_VERSION_MAJOR@
|
||||||
|
#define SIMPLE_LIBRARY_VERSION_MINOR @SimpleLibrary_VERSION_MINOR@
|
||||||
|
#define SIMPLE_LIBRARY_VERSION_PATCH @SimpleLibrary_VERSION_PATCH@
|
||||||
|
#define SIMPLE_LIBRARY_VERSION "@SimpleLibrary_VERSION@"
|
||||||
|
|
||||||
|
#define SIMPLE_LIBRARY_GIT_HASH "@GIT_HASH@"
|
||||||
|
#define SIMPLE_LIBRARY_GIT_BRANCH "@GIT_BRANCH@"
|
||||||
|
#define SIMPLE_LIBRARY_CUSTOM_VALUE "@CUSTOM_VALUE@"
|
||||||
|
|
||||||
5
cmake_demo/simple_caller/src/header.cpp
Normal file
5
cmake_demo/simple_caller/src/header.cpp
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
const char *hello() {
|
||||||
|
return "Hello, World!";
|
||||||
|
}
|
||||||
10
cmake_demo/simple_caller/src/main.cpp
Normal file
10
cmake_demo/simple_caller/src/main.cpp
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[], char *envp[]) {
|
||||||
|
cout << hello() << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
185
cmake_demo/simple_library/CMakeLists.txt
Normal file
185
cmake_demo/simple_library/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,185 @@
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(
|
||||||
|
SimpleLibrary
|
||||||
|
VERSION 1.0.0
|
||||||
|
LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
#
|
||||||
|
# auto genrate a stamp header
|
||||||
|
#
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-parse --short HEAD
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_HASH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-parse --abbrev-ref HEAD
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_BRANCH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
set(CUSTOM_VALUE "Blah blah custom value.")
|
||||||
|
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/version.h.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/include/simple/version.h")
|
||||||
|
|
||||||
|
add_custom_target(
|
||||||
|
generate_version_h ALL
|
||||||
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/include/simple/version.h")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build
|
||||||
|
#
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||||
|
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG")
|
||||||
|
set(CMAKE_BUILD_TYPE
|
||||||
|
"Release"
|
||||||
|
CACHE STRING "Choose the type of build." FORCE)
|
||||||
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
|
||||||
|
"RelWithDebInfo")
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||||
|
# file(GLOB_RECURSE HEADERS "include/*.h")
|
||||||
|
|
||||||
|
# shared - set_target_properties is so that the binary is libSimpleLibrary.so
|
||||||
|
# add_depdencies so the config.h file is auto generated
|
||||||
|
add_library(SimpleLibraryShared SHARED ${SOURCES})
|
||||||
|
target_include_directories(
|
||||||
|
SimpleLibraryShared
|
||||||
|
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/simple>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include/simple>)
|
||||||
|
set_target_properties(SimpleLibraryShared PROPERTIES OUTPUT_NAME
|
||||||
|
"SimpleLibrary")
|
||||||
|
add_dependencies(SimpleLibraryShared generate_version_h doc_doxygen)
|
||||||
|
|
||||||
|
# static - set_target_properties is so that the binary is libSimpleLibrary.a
|
||||||
|
# add_depdencies so the config.h file is auto generated
|
||||||
|
add_library(SimpleLibraryStatic STATIC ${SOURCES})
|
||||||
|
set_target_properties(SimpleLibraryStatic PROPERTIES OUTPUT_NAME
|
||||||
|
"SimpleLibrary")
|
||||||
|
target_include_directories(
|
||||||
|
SimpleLibraryStatic
|
||||||
|
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/simple>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include/simple>)
|
||||||
|
add_dependencies(SimpleLibraryStatic generate_version_h doc_doxygen)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test
|
||||||
|
#
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(test)
|
||||||
|
|
||||||
|
#
|
||||||
|
# doxygen
|
||||||
|
#
|
||||||
|
find_package(Doxygen REQUIRED)
|
||||||
|
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
|
||||||
|
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||||
|
|
||||||
|
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
|
||||||
|
add_custom_target(
|
||||||
|
doc_doxygen # ALL otherwise it's constantly being rebuilt
|
||||||
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
COMMENT "Generating API documentation with Doxygen"
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
#
|
||||||
|
# man page
|
||||||
|
#
|
||||||
|
# look into pandoc that'll turn markdown into man pages.
|
||||||
|
add_custom_target(
|
||||||
|
man ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/man
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/man
|
||||||
|
COMMENT "Copying man pages")
|
||||||
|
|
||||||
|
#
|
||||||
|
# CMake find support
|
||||||
|
#
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/SimpleLibraryConfigVersion.cmake"
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY AnyNewerVersion)
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/SimpleLibraryConfig.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/SimpleLibraryConfig.cmake"
|
||||||
|
INSTALL_DESTINATION lib/cmake/SimpleLibrary)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install
|
||||||
|
#
|
||||||
|
install(
|
||||||
|
TARGETS SimpleLibraryShared SimpleLibraryStatic
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
PUBLIC_HEADER DESTINATION include/simple)
|
||||||
|
|
||||||
|
install(DIRECTORY include/simple/ DESTINATION include/simple)
|
||||||
|
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/simple/version.h"
|
||||||
|
DESTINATION include/simple)
|
||||||
|
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SimpleLibraryConfig.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/SimpleLibraryConfigVersion.cmake"
|
||||||
|
DESTINATION lib/cmake/SimpleLibrary)
|
||||||
|
|
||||||
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html
|
||||||
|
DESTINATION share/doc/SimpleLibrary)
|
||||||
|
|
||||||
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man/ DESTINATION share/man)
|
||||||
|
|
||||||
|
#
|
||||||
|
# CPack
|
||||||
|
#
|
||||||
|
set(CPACK_PACKAGE_NAME "SimpleLibrary")
|
||||||
|
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||||
|
set(CPACK_PACKAGE_CONTACT "RAS <sprague.a.rick@gmail.com>")
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A simple library example")
|
||||||
|
set(CPACK_PACKAGE_VENDOR "Your Organization")
|
||||||
|
set(CPACK_PACKAGE_LICENSE "MIT")
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||||
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
|
||||||
|
|
||||||
|
# Debian specific settings
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "RAS <sprague.a.rick@gmail.com>")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.27)")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
|
||||||
|
set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
|
|
||||||
|
cpack_add_component_group(Development)
|
||||||
|
cpack_add_component(
|
||||||
|
Headers
|
||||||
|
DISPLAY_NAME "C++ Headers"
|
||||||
|
DESCRIPTION "C++ header files for SimpleLibrary"
|
||||||
|
GROUP Development
|
||||||
|
REQUIRED)
|
||||||
|
cpack_add_component(
|
||||||
|
Libraries
|
||||||
|
DISPLAY_NAME "Libraries"
|
||||||
|
DESCRIPTION "Shared and static libraries for SimpleLibrary"
|
||||||
|
GROUP Development
|
||||||
|
REQUIRED)
|
||||||
|
|
||||||
|
cpack_add_component(
|
||||||
|
Doxygen
|
||||||
|
DISPLAY_NAME "Doxygen Documentation"
|
||||||
|
DESCRIPTION "API documentation generated by Doxygen"
|
||||||
|
GROUP Development
|
||||||
|
REQUIRED)
|
||||||
9
cmake_demo/simple_library/CMakeUserPresets.json
Normal file
9
cmake_demo/simple_library/CMakeUserPresets.json
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"vendor": {
|
||||||
|
"conan": {}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"build/Release/generators/CMakePresets.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
18
cmake_demo/simple_library/Doxyfile.in
Normal file
18
cmake_demo/simple_library/Doxyfile.in
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Doxyfile.in
|
||||||
|
|
||||||
|
# Doxyfile configuration for Doxygen
|
||||||
|
|
||||||
|
# Project related configuration options
|
||||||
|
PROJECT_NAME = @PROJECT_NAME@
|
||||||
|
PROJECT_NUMBER = @PROJECT_VERSION@
|
||||||
|
|
||||||
|
# Build related configuration options
|
||||||
|
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/doc
|
||||||
|
GENERATE_HTML = YES
|
||||||
|
GENERATE_LATEX = NO
|
||||||
|
|
||||||
|
# Configuration options related to the input files
|
||||||
|
INPUT = @CMAKE_SOURCE_DIR@/include
|
||||||
|
|
||||||
|
# Configuration options related to the output files
|
||||||
|
HTML_OUTPUT = html
|
||||||
47
cmake_demo/simple_library/README.md
Normal file
47
cmake_demo/simple_library/README.md
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Conan development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# install depedencies
|
||||||
|
conan install . --build=missing
|
||||||
|
|
||||||
|
# export recipe to the local cache
|
||||||
|
conan export . --name=simple_library --version=1.0.0 --user=ras --channel=stable
|
||||||
|
|
||||||
|
# builds the package
|
||||||
|
conan build . --name=simple_library --version=1.0.0 --user=ras --channel=stable
|
||||||
|
|
||||||
|
# create a package from a recipe in add to local cache
|
||||||
|
conan create . --name=simple_library --version=1.0.0 --user=ras --channel=stable
|
||||||
|
|
||||||
|
# check to see create works
|
||||||
|
conan list simple_library/1.0.0@ras/stable
|
||||||
|
```
|
||||||
|
|
||||||
|
# conanfile.py
|
||||||
|
|
||||||
|
looks like exports_sources in conanfile.py is where you specify the essential files.
|
||||||
|
|
||||||
|
|
||||||
|
# Upload to Conan
|
||||||
|
```bash
|
||||||
|
conan remote login -p <<password>> <<remote>> <<user>>
|
||||||
|
# rastar sprague.a.rick
|
||||||
|
|
||||||
|
conan upload --remote <<remote>> <<recipe>>
|
||||||
|
# rastar simple_library
|
||||||
|
|
||||||
|
conan search simple_library
|
||||||
|
```
|
||||||
|
|
||||||
|
# Building DEB
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cpack -G DEB -C Release --config CPackConfig.cmake
|
||||||
|
dpkg-deb --contents SimpleLibrary-1.0.0.deb
|
||||||
|
dpkg-deb --info SimpleLibrary-1.0.0.deb
|
||||||
|
```
|
||||||
|
```
|
||||||
|
|
||||||
|
# Other notes
|
||||||
|
* pandoc to make man pages from markdown
|
||||||
|
* using conan for gmock and gtest
|
||||||
16
cmake_demo/simple_library/SimpleLibraryConfig.cmake.in
Normal file
16
cmake_demo/simple_library/SimpleLibraryConfig.cmake.in
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
|
||||||
|
# Include the version file
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/SimpleLibraryConfigVersion.cmake")
|
||||||
|
|
||||||
|
# Add the targets file
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/SimpleLibraryTargets.cmake")
|
||||||
|
|
||||||
|
# Set the include directories
|
||||||
|
set(SimpleLibrary_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@")
|
||||||
|
|
||||||
|
# Provide the include directories to the caller
|
||||||
|
set(SimpleLibrary_INCLUDE_DIRS ${SimpleLibrary_INCLUDE_DIRS})
|
||||||
|
mark_as_advanced(SimpleLibrary_INCLUDE_DIRS)
|
||||||
47
cmake_demo/simple_library/conanfile.py
Normal file
47
cmake_demo/simple_library/conanfile.py
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
from conan import ConanFile
|
||||||
|
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
||||||
|
import os
|
||||||
|
|
||||||
|
class SimpleLibraryConan(ConanFile):
|
||||||
|
name = "simple_library"
|
||||||
|
version = "1.0.0"
|
||||||
|
license = "MIT"
|
||||||
|
url = "https://rastar.netgear.com/gitea/sprague.a.rick/cmake_demo.git"
|
||||||
|
description = "A simple library that adds two integers"
|
||||||
|
settings = "os", "compiler", "build_type", "arch"
|
||||||
|
exports_sources = (
|
||||||
|
"CMakeLists.txt",
|
||||||
|
"src/*",
|
||||||
|
"include/*",
|
||||||
|
"test/*",
|
||||||
|
"SimpleLibraryConfig.cmake.in",
|
||||||
|
"man/*",
|
||||||
|
"Doxyfile.in"
|
||||||
|
)
|
||||||
|
generators = "CMakeDeps"
|
||||||
|
requires = "gtest/1.11.0"
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
cmake_layout(self)
|
||||||
|
|
||||||
|
def generate(self):
|
||||||
|
tc = CMakeToolchain(self)
|
||||||
|
tc.generator = "Ninja"
|
||||||
|
tc.generate()
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
os.environ["CONAN_CPU_COUNT"] = "4"
|
||||||
|
cmake = CMake(self)
|
||||||
|
cmake.configure()
|
||||||
|
cmake.build()
|
||||||
|
|
||||||
|
def package(self):
|
||||||
|
cmake = CMake(self)
|
||||||
|
cmake.install()
|
||||||
|
|
||||||
|
def package_info(self):
|
||||||
|
self.cpp_info.libs = ["simple_library", "simple_library_shared"]
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
cmake = CMake(self)
|
||||||
|
cmake.test()
|
||||||
3
cmake_demo/simple_library/include/internal.h
Normal file
3
cmake_demo/simple_library/include/internal.h
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
int getvalue();
|
||||||
33
cmake_demo/simple_library/include/simple/simple_library.h
Normal file
33
cmake_demo/simple_library/include/simple/simple_library.h
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Brief description of the function.
|
||||||
|
*
|
||||||
|
* Detailed description of the function. This part can be used to elaborate on the functionality, parameters, and return values.
|
||||||
|
*
|
||||||
|
* @param x The first parameter, representating an integer value.
|
||||||
|
* @param y The second parameter, representing an integer value.
|
||||||
|
* @return The sum of x and y.
|
||||||
|
*/
|
||||||
|
int add(int a, int b);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version that was generated.
|
||||||
|
*/
|
||||||
|
const char* getVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the git hash
|
||||||
|
*/
|
||||||
|
const char* getGitHash();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the git branch
|
||||||
|
*/
|
||||||
|
const char* getGitBranch();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the custom value
|
||||||
|
*/
|
||||||
|
const char* getCustomValue();
|
||||||
|
|
||||||
11
cmake_demo/simple_library/include/version.h.in
Normal file
11
cmake_demo/simple_library/include/version.h.in
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define SIMPLE_LIBRARY_VERSION_MAJOR @SimpleLibrary_VERSION_MAJOR@
|
||||||
|
#define SIMPLE_LIBRARY_VERSION_MINOR @SimpleLibrary_VERSION_MINOR@
|
||||||
|
#define SIMPLE_LIBRARY_VERSION_PATCH @SimpleLibrary_VERSION_PATCH@
|
||||||
|
#define SIMPLE_LIBRARY_VERSION "@SimpleLibrary_VERSION@"
|
||||||
|
|
||||||
|
#define SIMPLE_LIBRARY_GIT_HASH "@GIT_HASH@"
|
||||||
|
#define SIMPLE_LIBRARY_GIT_BRANCH "@GIT_BRANCH@"
|
||||||
|
#define SIMPLE_LIBRARY_CUSTOM_VALUE "@CUSTOM_VALUE@"
|
||||||
|
|
||||||
11
cmake_demo/simple_library/man/simple_library.1
Normal file
11
cmake_demo/simple_library/man/simple_library.1
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
.TH SIMPLE_LIBRARY 1 "October 2023" "SimpleLibrary 1.0.0" "SimpleLibrary Manual"
|
||||||
|
.SH NAME
|
||||||
|
simple_library \- A simple library example
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B simple_library
|
||||||
|
.SH DESCRIPTION
|
||||||
|
This is a simple library example for demonstration purposes.
|
||||||
|
.SH AUTHOR
|
||||||
|
Written by RAS <sprague.a.rick@gmail.com>.
|
||||||
|
.SH COPYRIGHT
|
||||||
|
MIT License
|
||||||
6
cmake_demo/simple_library/src/internal.cpp
Normal file
6
cmake_demo/simple_library/src/internal.cpp
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
int getvalue() {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
33
cmake_demo/simple_library/src/simple_library.cpp
Normal file
33
cmake_demo/simple_library/src/simple_library.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include "simple/simple_library.h"
|
||||||
|
#include "simple/version.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
int add(int a, int b) {
|
||||||
|
int rv = (a + b) * getvalue();
|
||||||
|
cout << "a: " << a << endl;
|
||||||
|
cout << "b: " << b << endl;
|
||||||
|
cout << "c: " << getvalue() << endl;
|
||||||
|
cout << "(a + b) * c = " << rv << endl;
|
||||||
|
return rv;
|
||||||
|
return (a + b) * getvalue();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *getCustomValue() {
|
||||||
|
return SIMPLE_LIBRARY_CUSTOM_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *getVersion() {
|
||||||
|
return SIMPLE_LIBRARY_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *getGitHash() {
|
||||||
|
return SIMPLE_LIBRARY_GIT_HASH;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *getGitBranch() {
|
||||||
|
return SIMPLE_LIBRARY_GIT_BRANCH;
|
||||||
|
}
|
||||||
7
cmake_demo/simple_library/test/CMakeLists.txt
Normal file
7
cmake_demo/simple_library/test/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||||
|
|
||||||
|
find_package(GTest REQUIRED)
|
||||||
|
add_executable(SimpleLibraryTests ${SOURCES})
|
||||||
|
target_link_libraries(SimpleLibraryTests GTest::gtest GTest::gtest_main SimpleLibraryShared)
|
||||||
|
add_test(NAME SimpleLibraryTests COMMAND SimpleLibraryTests)
|
||||||
|
|
||||||
11
cmake_demo/simple_library/test/src/test_simple_library.cpp
Normal file
11
cmake_demo/simple_library/test/src/test_simple_library.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "simple_library.h" // Include your library header
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
TEST(SimpleLibraryTest, BasicAssertions) {
|
||||||
|
// Expect two strings not to be equal.
|
||||||
|
EXPECT_STRNE("hello", "world");
|
||||||
|
// Expect equality.
|
||||||
|
EXPECT_EQ(7 * 6, 42);
|
||||||
|
|
||||||
|
EXPECT_EQ(150, add(5, 10));
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user