Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
env:
TIPI_CACHE_FORCE_ENABLE: ON
CMAKE_TIPI_PROVIDER_ENABLE: ON
steps:
- name: checkout
uses: actions/checkout@v2
- name: tipi builds project
run: |
tipi . -t linux-cxx17 --dont-upgrade --verbose --test all --use-cmakelists
8 changes: 0 additions & 8 deletions .tipi/deps

This file was deleted.

186 changes: 186 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
cmake_minimum_required(VERSION 3.27.6)
project(cpp-pre_file VERSION "0.0.1")

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)

include (FetchContent)
FetchContent_Declare(
Boost
GIT_REPOSITORY https://github.com/boostorg/boost.git
# 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 )
add_library(cpp-pre_file::file ALIAS file)

set(include_install_dir "include")

target_include_directories(file BEFORE INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:${include_install_dir}/>)

target_link_libraries(file INTERFACE
Boost::system Boost::filesystem Boost::uuid
${CMAKE_THREAD_LIBS_INIT}
)


# 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:
# * <prefix>/lib/cmake/<PROJECT-NAME>
# * <prefix>/lib/
# * <prefix>/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 '<PROJECT-NAME>ConfigVersion.cmake'
# Note: PROJECT_VERSION is used as a VERSION
write_basic_package_version_file(
"${version_config}" COMPATIBILITY SameMajorVersion
)

# Configure '<PROJECT-NAME>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 pre
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
# * <prefix>/lib/cmake/file/fileConfig.cmake
# * <prefix>/lib/cmake/file/fileConfigVersion.cmake
# * <prefix>/lib/cmake/file/fileTargets.cmake
install(
FILES "${project_config}" "${version_config}"
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}"
#)

install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
7 changes: 7 additions & 0 deletions cmake/modules/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
check_required_components("@PROJECT_NAME@")


19 changes: 19 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 $<TARGET_FILE:hash>)
else()
add_test(NAME hash COMMAND "$<TARGET_FILE:hash>")
endif()


2 changes: 1 addition & 1 deletion tests/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down