From a4ea0d1e24055f4bde914376b485aa09728ba38e Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Fri, 30 Aug 2024 13:49:58 +0200 Subject: [PATCH 01/12] :gear: add generated CMakeLists in source tree directly. --- CMakeLists.txt | 127 ++++++++++++++++++++++++++++++++++ cmake/modules/Config.cmake.in | 7 ++ tests/CMakeLists.txt | 19 +++++ 3 files changed, 153 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/modules/Config.cmake.in create mode 100644 tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e80d85f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,127 @@ +cmake_minimum_required(VERSION 3.17.0) +project(cpp-pre_file VERSION "0.0.1") + +# testing stuff +enable_testing() + +# Warning as errors to ensure file quality +string(TOUPPER "${CMAKE_CXX_COMPILER_ID}" COMPILER_IN_USE) +if ("${COMPILER_IN_USE}" STREQUAL "GNU" OR "${COMPILER_IN_USE}" MATCHES "CLANG") + add_definitions( + -Wall + #-Werror + -Wno-unused-local-typedefs + -Wno-unused-variable + ) +endif() + +find_package(Threads) + +FetchContent_Declare( + Boost + GIT_REPOSITORY https://github.com/boostorg/boost.git + # boost 1.85 + GIT_TAG ab7968a0bbcf574a7859240d1d8443f58ed6f6cf +) +FetchContent_MakeAvailable(Boost) + +# Define library +add_library(file INTERFACE ) +add_library(cpp-pre_file::file ALIAS file) + +target_include_directories(file BEFORE INTERFACE + $ + $) + +target_link_libraries(file INTERFACE + Boost::system Boost::filesystem Boost::uuid + ${CMAKE_THREAD_LIBS_INIT} +) + +set(include_install_dir "include") + +# Targets: +install( + TARGETS + EXPORT "${targets_export_name}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "${include_install_dir}" +) + +add_subdirectory(tests) + + +# Installing + +# Layout. This works for all platforms: +# * /lib/cmake/ +# * /lib/ +# * /include/ +set(config_install_dir "lib/cmake/${PROJECT_NAME}") + +set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") + +# Configuration +set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") +set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") +set(targets_export_name "${PROJECT_NAME}Targets") +set(namespace "${PROJECT_NAME}::") + +# Include module with fuction 'write_basic_package_version_file' +include(CMakePackageConfigHelpers) + +# Configure 'ConfigVersion.cmake' +# Note: PROJECT_VERSION is used as a VERSION +write_basic_package_version_file( + "${version_config}" COMPATIBILITY SameMajorVersion +) + +# Configure 'Config.cmake' +# Use variables: +# * targets_export_name +# * PROJECT_NAME +configure_package_config_file( + "cmake/modules/Config.cmake.in" + "${project_config}" + INSTALL_DESTINATION "${config_install_dir}" +) + + +# Targets: +install( + TARGETS file + EXPORT "${targets_export_name}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "${include_install_dir}" +) + +# Headers: +install( + DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + DESTINATION "${include_install_dir}" + FILES_MATCHING PATTERN "*.[ih]*" + PATTERN build/ EXCLUDE + PATTERN "/build*" EXCLUDE + PATTERN ".git/*" EXCLUDE + PATTERN ".tipistore/*" EXCLUDE + PATTERN "doc/*" EXCLUDE + PATTERN "node_modules/*" EXCLUDE +) + +# Config +# * /lib/cmake/file/fileConfig.cmake +# * /lib/cmake/file/fileConfigVersion.cmake +# * /lib/cmake/file/fileTargets.cmake +install( + FILES "${project_config}" "${version_config}" + DESTINATION "${config_install_dir}" +) +install( + EXPORT "${targets_export_name}" + NAMESPACE "${namespace}" + DESTINATION "${config_install_dir}" +) \ No newline at end of file diff --git a/cmake/modules/Config.cmake.in b/cmake/modules/Config.cmake.in new file mode 100644 index 0000000..8145e30 --- /dev/null +++ b/cmake/modules/Config.cmake.in @@ -0,0 +1,7 @@ + +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") +check_required_components("@PROJECT_NAME@") + + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..ee24a8f --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,19 @@ +# To modify this, edit the template: +# - .tipi/CMakeLists.subdir-tests.txt.tpl +# - tests/CMakeLists.subdir-tests.txt.tpl +# +# The templates can be generated using the 'tipi cmaketpl' command + + + # hash + add_executable(hash hash.cpp ) + set_target_properties(hash PROPERTIES OUTPUT_NAME hash) + target_link_libraries(hash cpp-pre_file::file) + + if (DEFINED EMSCRIPTEN) + add_test(NAME hash COMMAND node --experimental-wasm-threads --experimental-wasm-bulk-memory $) + else() + add_test(NAME hash COMMAND "$") + endif() + + From 91480e7d6df9c08325deba3a1392eff4ed20a38b Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Thu, 5 Sep 2024 10:39:26 +0200 Subject: [PATCH 02/12] :gear: allow FetchContent use of cpp-pre/file even in non tipi-cmake-provider enabled contexts. --- CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e80d85f..5bea567 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ -cmake_minimum_required(VERSION 3.17.0) +cmake_minimum_required(VERSION 3.27.6) project(cpp-pre_file VERSION "0.0.1") -# testing stuff enable_testing() # Warning as errors to ensure file quality @@ -17,6 +16,7 @@ endif() find_package(Threads) +include (FetchContent) FetchContent_Declare( Boost GIT_REPOSITORY https://github.com/boostorg/boost.git @@ -120,6 +120,59 @@ install( FILES "${project_config}" "${version_config}" DESTINATION "${config_install_dir}" ) + +set(BOOST_TARGETS boost_filesystem boost_system boost_uuid +boost_assert +boost_atomic +boost_config +boost_container_hash +boost_core +boost_detail +boost_io +boost_iterator +boost_move +boost_numeric_conversion +boost_predef +boost_random +boost_scope +boost_smart_ptr +boost_static_assert +boost_throw_exception +boost_tti +boost_type_traits +boost_variant2 +boost_winapi +boost_align +boost_array +boost_concept_check +boost_conversion +boost_describe +boost_dynamic_bitset +boost_function_types +boost_fusion +boost_integer +boost_mp11 +boost_mpl +boost_optional +boost_preprocessor +boost_range +boost_utility +boost_tuple +boost_typeof +boost_functional +boost_regex +boost_function +boost_bind +) +install( + TARGETS ${BOOST_TARGETS} + EXPORT "${targets_export_name}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "${include_install_dir}" +) + install( EXPORT "${targets_export_name}" NAMESPACE "${namespace}" From a11c599e48823e0137333ff6afde473b64fa96ad Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Thu, 5 Sep 2024 10:39:48 +0200 Subject: [PATCH 03/12] :wrench: fix test case assertion which was spelled the wrong way around. --- tests/hash.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/hash.cpp b/tests/hash.cpp index ec85b0b..e981bd3 100644 --- a/tests/hash.cpp +++ b/tests/hash.cpp @@ -49,7 +49,7 @@ int main() { std::cout << "Modifying '" << testdata_path << "' & hashing again \n" << " - computed: " << hashed_modified << std::endl; - assert(hashed_modified == hashed_initial); + assert(hashed_modified != hashed_initial); std::cout << " [PASS]" << std::endl; From fda36ebd1d62ba846b6a03974293fbd87be4b433 Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Thu, 5 Sep 2024 10:41:45 +0200 Subject: [PATCH 04/12] :book: document the reason for the reexport of Boost targets to exists. --- CMakeLists.txt | 84 ++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bea567..47ac00b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,48 +121,50 @@ install( DESTINATION "${config_install_dir}" ) +# This overcomes the issue with "cpp-pre_file::file depends on targets +# that are in no EXPORT sets in plain cmake non cmake-tipi-provider contexts set(BOOST_TARGETS boost_filesystem boost_system boost_uuid -boost_assert -boost_atomic -boost_config -boost_container_hash -boost_core -boost_detail -boost_io -boost_iterator -boost_move -boost_numeric_conversion -boost_predef -boost_random -boost_scope -boost_smart_ptr -boost_static_assert -boost_throw_exception -boost_tti -boost_type_traits -boost_variant2 -boost_winapi -boost_align -boost_array -boost_concept_check -boost_conversion -boost_describe -boost_dynamic_bitset -boost_function_types -boost_fusion -boost_integer -boost_mp11 -boost_mpl -boost_optional -boost_preprocessor -boost_range -boost_utility -boost_tuple -boost_typeof -boost_functional -boost_regex -boost_function -boost_bind + boost_assert + boost_atomic + boost_config + boost_container_hash + boost_core + boost_detail + boost_io + boost_iterator + boost_move + boost_numeric_conversion + boost_predef + boost_random + boost_scope + boost_smart_ptr + boost_static_assert + boost_throw_exception + boost_tti + boost_type_traits + boost_variant2 + boost_winapi + boost_align + boost_array + boost_concept_check + boost_conversion + boost_describe + boost_dynamic_bitset + boost_function_types + boost_fusion + boost_integer + boost_mp11 + boost_mpl + boost_optional + boost_preprocessor + boost_range + boost_utility + boost_tuple + boost_typeof + boost_functional + boost_regex + boost_function + boost_bind ) install( TARGETS ${BOOST_TARGETS} From 2692c9fb92c4afd136cdfc18a3318d218541a5b0 Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Thu, 5 Sep 2024 12:37:48 +0200 Subject: [PATCH 05/12] :gear: use Boost 1.80.0 as in our main build --- CMakeLists.txt | 113 +++++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47ac00b..77746da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,10 +20,13 @@ include (FetchContent) FetchContent_Declare( Boost GIT_REPOSITORY https://github.com/boostorg/boost.git - # boost 1.85 - GIT_TAG ab7968a0bbcf574a7859240d1d8443f58ed6f6cf + # boost 1.80 + GIT_TAG 32da69a36f84c5255af8a994951918c258bac601 ) FetchContent_MakeAvailable(Boost) +find_package(boost_filesystem CONFIG REQUIRED) +find_package(boost_system CONFIG REQUIRED) +find_package(boost_uuid CONFIG REQUIRED) # Define library add_library(file INTERFACE ) @@ -121,59 +124,59 @@ install( DESTINATION "${config_install_dir}" ) -# This overcomes the issue with "cpp-pre_file::file depends on targets -# that are in no EXPORT sets in plain cmake non cmake-tipi-provider contexts -set(BOOST_TARGETS boost_filesystem boost_system boost_uuid - boost_assert - boost_atomic - boost_config - boost_container_hash - boost_core - boost_detail - boost_io - boost_iterator - boost_move - boost_numeric_conversion - boost_predef - boost_random - boost_scope - boost_smart_ptr - boost_static_assert - boost_throw_exception - boost_tti - boost_type_traits - boost_variant2 - boost_winapi - boost_align - boost_array - boost_concept_check - boost_conversion - boost_describe - boost_dynamic_bitset - boost_function_types - boost_fusion - boost_integer - boost_mp11 - boost_mpl - boost_optional - boost_preprocessor - boost_range - boost_utility - boost_tuple - boost_typeof - boost_functional - boost_regex - boost_function - boost_bind -) -install( - TARGETS ${BOOST_TARGETS} - EXPORT "${targets_export_name}" - LIBRARY DESTINATION "lib" - ARCHIVE DESTINATION "lib" - RUNTIME DESTINATION "bin" - INCLUDES DESTINATION "${include_install_dir}" -) +## This overcomes the issue with "cpp-pre_file::file depends on targets +## that are in no EXPORT sets in plain cmake non cmake-tipi-provider contexts +#set(BOOST_TARGETS boost_filesystem boost_system boost_uuid +# boost_assert +# boost_atomic +# boost_config +# boost_container_hash +# boost_core +# boost_detail +# boost_io +# boost_iterator +# boost_move +# boost_numeric_conversion +# boost_predef +# boost_random +# boost_scope +# boost_smart_ptr +# boost_static_assert +# boost_throw_exception +# boost_tti +# boost_type_traits +# boost_variant2 +# boost_winapi +# boost_align +# boost_array +# boost_concept_check +# boost_conversion +# boost_describe +# boost_dynamic_bitset +# boost_function_types +# boost_fusion +# boost_integer +# boost_mp11 +# boost_mpl +# boost_optional +# boost_preprocessor +# boost_range +# boost_utility +# boost_tuple +# boost_typeof +# boost_functional +# boost_regex +# boost_function +# boost_bind +#) +#install( +# TARGETS ${BOOST_TARGETS} +# EXPORT "${targets_export_name}" +# LIBRARY DESTINATION "lib" +# ARCHIVE DESTINATION "lib" +# RUNTIME DESTINATION "bin" +# INCLUDES DESTINATION "${include_install_dir}" +#) install( EXPORT "${targets_export_name}" From c9eef0845bad48a9ea891278a186849ea30ad135 Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Thu, 5 Sep 2024 12:56:27 +0200 Subject: [PATCH 06/12] :wrench: define include_install_dir at the right moment --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77746da..046583d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,8 @@ find_package(boost_uuid CONFIG REQUIRED) add_library(file INTERFACE ) add_library(cpp-pre_file::file ALIAS file) +set(include_install_dir "include") + target_include_directories(file BEFORE INTERFACE $ $) @@ -41,7 +43,6 @@ target_link_libraries(file INTERFACE ${CMAKE_THREAD_LIBS_INIT} ) -set(include_install_dir "include") # Targets: install( From 57780f632473360d4daee3a868276498f946ffb6 Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Thu, 5 Sep 2024 13:01:42 +0200 Subject: [PATCH 07/12] :wrench: fix header installation --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 046583d..9d888f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ install( # Headers: install( - DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + DIRECTORY pre DESTINATION "${include_install_dir}" FILES_MATCHING PATTERN "*.[ih]*" PATTERN build/ EXCLUDE From 80e1f3ffca4a8cf9f1d556620198eb55e95e0767 Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Fri, 6 Sep 2024 11:39:38 +0200 Subject: [PATCH 08/12] :gear: minimal gitub CI support --- .github/workflows/ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cb56e0d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,17 @@ +name: build +# This workflow is triggered on pushes to the repository. +on: [push] + +jobs: + build: + name: build-linux + runs-on: ubuntu-latest + container: tipibuild/tipi-ubuntu + steps: + - name: checkout + uses: actions/checkout@v2 + - name: tipi builds project + run: | + export HOME=/root + mkdir -p ~/.tipi + tipi . --dont-upgrade --verbose --test all --use-cmakelists From 1dfb8411359cb6694fd8719a8af62d5eaa4e4481 Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Fri, 6 Sep 2024 11:42:29 +0200 Subject: [PATCH 09/12] :wrench: fix workflow to use default container user --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb56e0d..3a12d46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,4 @@ jobs: uses: actions/checkout@v2 - name: tipi builds project run: | - export HOME=/root - mkdir -p ~/.tipi tipi . --dont-upgrade --verbose --test all --use-cmakelists From fe0b4a517387dd6b18d0f8d1fae7ac2f9b7f6d6a Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Fri, 6 Sep 2024 17:52:05 +0200 Subject: [PATCH 10/12] :gear: actually build for linux --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a12d46..b93deff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,4 +12,4 @@ jobs: uses: actions/checkout@v2 - name: tipi builds project run: | - tipi . --dont-upgrade --verbose --test all --use-cmakelists + tipi . -t linux-cxx17 --dont-upgrade --verbose --test all --use-cmakelists From 14f3385c6f033e07b9986054e72427be9a54eed7 Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Fri, 6 Sep 2024 20:24:28 +0200 Subject: [PATCH 11/12] :gear: enhanced FetchContent support with caching --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b93deff..74c7500 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,9 @@ jobs: name: build-linux runs-on: ubuntu-latest container: tipibuild/tipi-ubuntu + env: + TIPI_CACHE_FORCE_ENABLE: ON + CMAKE_TIPI_PROVIDER_ENABLE: ON steps: - name: checkout uses: actions/checkout@v2 From d6e2f875e70de332cb678bfcfbff32e8d51ad78d Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Wed, 16 Apr 2025 15:13:46 +0200 Subject: [PATCH 12/12] :wrench: remove unnecessary .tipi/deps as we use FetchContent for Boost. --- .tipi/deps | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .tipi/deps diff --git a/.tipi/deps b/.tipi/deps deleted file mode 100644 index e023dfc..0000000 --- a/.tipi/deps +++ /dev/null @@ -1,8 +0,0 @@ -{ - "boostorg/boost" : { "@" : "boost-1.80.0", - "opts": "set(BOOST_INCLUDE_LIBRARIES system filesystem uuid)", - "packages": [ "boost_system", "boost_filesystem", "boost_uuid" ], - "targets": [ "Boost::system", "Boost::filesystem", "Boost::uuid" ], - "u": true - } -}