-
Notifications
You must be signed in to change notification settings - Fork 11
Feature/export cmake config package #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
e9b94ce
67a3b6a
25b04eb
3a030e0
1923125
f9c6d1a
75935e9
ee3d65b
a28d0a8
0ee9ae7
7b88578
9b16321
4ec37c3
821293a
a75dccb
e7071c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| format: | ||
| line_width: 119 | ||
| tab_size: 4 | ||
ClausKlein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| max_subgroups_hwrap: 4 | ||
| max_rows_cmdline: 8 | ||
| separate_ctrl_name_with_space: false | ||
| separate_fn_name_with_space: false | ||
| dangle_parens: true | ||
| dangle_align: prefix | ||
| line_ending: unix | ||
| keyword_case: upper | ||
| always_wrap: | ||
| - file | ||
| - install | ||
| - project | ||
| - write_basic_package_version_file | ||
|
|
||
| markup: | ||
| enable_markup: false | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change reject out of scope, please move to another PR. |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change rejected due to out of scope, please move to another PR. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # .github/workflows/macos.yml | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| name: Macos Build | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main", "develop"] | ||
| pull_request: | ||
| branches: ["main", "develop"] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: macos-15 | ||
| strategy: | ||
| fail-fast: false | ||
|
|
||
| matrix: | ||
| preset: [debug, release, gcov, asan, lsan, usan] | ||
| # TODO: compiler: [g++, clang++-19] | ||
| compiler: [clang++-19] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Cpp | ||
| uses: aminya/setup-cpp@v1 | ||
| with: | ||
| # cmake: true | ||
| ninja: true | ||
| gcovr: true | ||
|
|
||
| - name: Install llvm-19 | ||
| if: startsWith(matrix.compiler, 'clang') | ||
| run: | | ||
| brew install llvm@19 | ||
|
|
||
| - name: macos clang++-19 ${{ matrix.preset }} | ||
| if: startsWith(matrix.compiler, 'clang') | ||
| run: GCOV=$(brew --prefix llvm@19)/bin/llvm-cov CXX=$(brew --prefix llvm@19)/bin/clang++ cmake --workflow --preset ${{ matrix.preset }} | ||
|
|
||
| - name: macos g++ ${{ matrix.preset }} | ||
| if: startsWith(matrix.compiler, 'g++') | ||
| run: CXX=${{ matrix.compiler }} cmake --workflow --preset ${{ matrix.preset }} |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change rejected due to out of scope, please move to another PR. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # .github/workflows/windows.yml | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| name: Windows Build | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main", "develop"] | ||
| pull_request: | ||
| branches: ["main", "develop"] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: windows-latest | ||
| strategy: | ||
| fail-fast: false | ||
|
|
||
| matrix: | ||
| preset: [debug, release] | ||
| # TODO: compiler: [cl, clang-cl] | ||
| compiler: [cl] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| # see https://github.com/marketplace/actions/enable-developer-command-prompt | ||
| - uses: ilammy/msvc-dev-cmd@v1 | ||
| with: | ||
| vsversion: 2022 | ||
|
|
||
| # - name: build environment | ||
| # run: pip install -r requirements.txt | ||
|
|
||
| - name: cmake workflow ${{ matrix.preset }} | ||
| shell: bash | ||
| run: | | ||
| cmake --version | ||
| ninja --version | ||
| CXX=${{ matrix.compiler }} cmake --workflow --preset ${{ matrix.preset }} | ||
|
|
||
| # - name: configure | ||
| # run: CXX=${{ matrix.compiler }} cmake --preset ${{ matrix.preset }} | ||
|
|
||
| # - name: build | ||
| # run: cmake --build --preset ${{ matrix.preset }} | ||
|
|
||
| # - name: ctest | ||
| # run: ctest --preset ${{ matrix.preset }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| /stagedir | ||
| /build | ||
| /out | ||
| CMakeUserPresets.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,16 +3,22 @@ | |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| # cmake-format: on | ||
|
|
||
| cmake_minimum_required(VERSION 3.23) | ||
| set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE) | ||
|
|
||
| cmake_minimum_required(VERSION 3.25...3.31) | ||
|
|
||
| project( | ||
| beman.inplace_vector | ||
| beman_inplace_vector | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not conform to our naming tradition, why changing it to We have used
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it because I needed it for cmake export config package And it was used like this in For TBD see #14 (comment)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will end in a very strange export package, not very common: bash-5.2$ tree /usr/local/lib/cmake/boost_
boost_atomic-1.86.0/ boost_graph_parallel-1.86.0/ boost_math_tr1l-1.86.0/ boost_system-1.86.0/
boost_charconv-1.86.0/ boost_headers-1.86.0/ boost_nowide-1.86.0/ boost_test_exec_monitor-1.86.0/
boost_chrono-1.86.0/ boost_iostreams-1.86.0/ boost_prg_exec_monitor-1.86.0/ boost_thread-1.86.0/
boost_container-1.86.0/ boost_json-1.86.0/ boost_process-1.86.0/ boost_timer-1.86.0/
boost_context-1.86.0/ boost_locale-1.86.0/ boost_program_options-1.86.0/ boost_type_erasure-1.86.0/
boost_contract-1.86.0/ boost_log-1.86.0/ boost_random-1.86.0/ boost_unit_test_framework-1.86.0/
boost_coroutine-1.86.0/ boost_log_setup-1.86.0/ boost_regex-1.86.0/ boost_url-1.86.0/
boost_date_time-1.86.0/ boost_math_c99-1.86.0/ boost_serialization-1.86.0/ boost_wave-1.86.0/
boost_exception-1.86.0/ boost_math_c99f-1.86.0/ boost_stacktrace_addr2line-1.86.0/ boost_wserialization-1.86.0/
boost_fiber-1.86.0/ boost_math_c99l-1.86.0/ boost_stacktrace_basic-1.86.0/
boost_filesystem-1.86.0/ boost_math_tr1-1.86.0/ boost_stacktrace_from_exception-1.86.0/
boost_graph-1.86.0/ boost_math_tr1f-1.86.0/ boost_stacktrace_noop-1.86.0/
bash-5.2$ tree /usr/local/lib/cmake/boost_atomic-1.86.0
/usr/local/lib/cmake/boost_atomic-1.86.0
|-- boost_atomic-config-version.cmake
|-- boost_atomic-config.cmake
|-- libboost_atomic-variant-mt-shared.cmake
`-- libboost_atomic-variant-mt-static.cmake
1 directory, 4 files
bash-5.2$ tree stagedir/lib/cmake/
stagedir/lib/cmake/
`-- beman_inplace_vector
|-- beman_inplace_vector-config-version.cmake
|-- beman_inplace_vector-config.cmake
`-- beman_inplace_vector-targets.cmake
2 directories, 3 files
bash-5.2$
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and it may be used like this: #---------------------------------------------------------------------------------------
# search required packages and libs
#---------------------------------------------------------------------------------------
find_package(
Boost 1.86 CONFIG
COMPONENTS filesystem asio headers
REQUIRED
)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you are right here. This was recommended in the weekly sync too because this format works better with compiler explorer. You can keep this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also agree that using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The most important point in this PR!So you agree this change?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, according to: bemanproject/beman#69 We cannot update the project/ target name. |
||
| VERSION 1.0.0 | ||
| DESCRIPTION | ||
| "A dynamically-resizable vector with fixed capacity and embedded storage" | ||
| LANGUAGES CXX | ||
| ) | ||
|
|
||
| if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) | ||
| message(FATAL_ERROR "In-source builds are not allowed!") | ||
| endif() | ||
|
|
||
| # [CMAKE.SKIP_EXAMPLES] | ||
| option( | ||
| BEMAN_EXEMPLAR_BUILD_EXAMPLES | ||
|
|
@@ -27,41 +33,102 @@ option( | |
| ${PROJECT_IS_TOP_LEVEL} | ||
| ) | ||
|
|
||
| # includes | ||
| include(GNUInstallDirs) | ||
| include(CMakePackageConfigHelpers) | ||
|
|
||
| add_library(beman.inplace_vector INTERFACE) | ||
| add_library(beman_inplace_vector INTERFACE) | ||
| # [CMAKE.LIBRARY_ALIAS] | ||
| add_library(beman::inplace_vector ALIAS beman.inplace_vector) | ||
| add_library(beman::beman_inplace_vector ALIAS beman_inplace_vector) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non conforming with [CMAKE.LIBRARY_ALIAS], https://github.com/bemanproject/beman/blob/main/docs/BEMAN_STANDARD.md#cmake . Please discard this change.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #14 (comment) |
||
|
|
||
| target_include_directories( | ||
| beman.inplace_vector | ||
| target_sources( | ||
| beman_inplace_vector | ||
| PUBLIC | ||
| FILE_SET inplace_vector_public_headers | ||
| TYPE HEADERS | ||
| BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
| FILES | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/include/beman/inplace_vector/inplace_vector.hpp" | ||
| ) | ||
| set_target_properties( | ||
| beman_inplace_vector | ||
| PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON | ||
| ) | ||
| target_compile_features( | ||
| beman_inplace_vector | ||
| INTERFACE | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:include> | ||
| "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>" | ||
| "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>" | ||
| ) | ||
|
|
||
| # Install the InplaceVector library to the appropriate destination | ||
| install( | ||
| TARGETS beman.inplace_vector | ||
| EXPORT ${TARGETS_EXPORT_NAME} | ||
| DESTINATION | ||
| ${CMAKE_INSTALL_LIBDIR} | ||
| ) | ||
| # export cmake config package | ||
| block() | ||
| # NOTE: copied from execution26: | ||
| # FIXME: but not yet used? CK | ||
| # set(TARGET_NAME inplace_vector) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wdym by this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That a long odyssey:This block was copied from execution26. But the original version use CMAKE_PROJECT_NAME and that is wrong! If you import this project with |
||
| # set(TARGET_NAMESPACE beman) | ||
| # set(TARGET_PREFIX ${TARGET_NAMESPACE}.${TARGET_NAME}) | ||
| # set(TARGET_LIBRARY ${PROJECT_NAME}) | ||
| # set(TARGET_ALIAS ${TARGET_NAMESPACE}::${TARGET_LIBRARY}) | ||
|
|
||
| # Install the header files to the appropriate destination | ||
| install( | ||
| DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ | ||
| DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME} | ||
| FILES_MATCHING | ||
| PATTERN | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/include/beman/inplace_vector/inplace_vector.hpp" | ||
| ) | ||
| set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config) | ||
| set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets) | ||
| set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) | ||
|
|
||
| # Install the InplaceVector library to the appropriate destination | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need help reviewing this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, most people do this wrong or only partly .... |
||
| install( | ||
| TARGETS beman_inplace_vector | ||
| EXPORT ${TARGETS_EXPORT_NAME} | ||
| FILE_SET inplace_vector_public_headers | ||
| ) | ||
|
|
||
| write_basic_package_version_file( | ||
| ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake | ||
| VERSION ${PROJECT_VERSION} | ||
| COMPATIBILITY AnyNewerVersion | ||
| ) | ||
|
|
||
| configure_package_config_file( | ||
| cmake/Config.cmake.in | ||
| ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake | ||
| INSTALL_DESTINATION ${INSTALL_CONFIGDIR} | ||
| ) | ||
|
|
||
| install( | ||
| FILES | ||
| ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake | ||
| ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake | ||
| DESTINATION ${INSTALL_CONFIGDIR} | ||
| ) | ||
|
|
||
| install( | ||
| EXPORT ${TARGETS_EXPORT_NAME} | ||
| FILE ${TARGETS_EXPORT_NAME}.cmake | ||
| DESTINATION "${INSTALL_CONFIGDIR}" | ||
| NAMESPACE beman:: | ||
| ) | ||
ClausKlein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| set(CPACK_GENERATOR TGZ) | ||
| include(CPack) | ||
| endblock() | ||
|
|
||
| if(BEMAN_INPLACE_VECTOR_BUILD_TESTS) | ||
| include(CTest) | ||
| enable_testing() | ||
| add_subdirectory(tests/beman/inplace_vector) | ||
| endif() | ||
|
|
||
| if(BEMAN_EXEMPLAR_BUILD_EXAMPLES) | ||
| add_subdirectory(examples) | ||
| endif() | ||
|
|
||
| # Coverage | ||
ClausKlein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| configure_file(cmake/gcovr.cfg.in gcovr.cfg @ONLY) | ||
|
|
||
| add_custom_target( | ||
| process_coverage | ||
| WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
| DEPENDS test | ||
| COMMENT "Running gcovr to process coverage results" | ||
| COMMAND mkdir -p coverage | ||
| COMMAND gcovr --config gcovr.cfg . | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.