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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ compile-headers: $(_build_path)/CMakeCache.txt ## Compile the headers
install: $(_build_path)/CMakeCache.txt compile ## Install the project
cmake --install $(_build_path) --config $(CONFIG) --component beman.optional --verbose

.PHONY: clean-install
clean-install:
-rm -rf .install

realclean: clean-install

ctest: $(_build_path)/CMakeCache.txt ## Run CTest on current build
cd $(_build_path) && ctest --output-on-failure -C $(CONFIG)

Expand Down Expand Up @@ -195,6 +201,18 @@ mrdocs: ## Build the docs with Doxygen
cd docs && NO_COLOR=1 mrdocs mrdocs.yml 2>&1 | sed 's/\x1b\[[0-9;]*m//g'
find docs/adoc -name '*.adoc' | xargs asciidoctor

.PHONY: testinstall
testinstall: install
testinstall: ## Test the installed package
cmake -S installtest -B installtest/.build
cmake --build installtest/.build --target test

.PHONY: clean-testinstall
clean-testinstall:
-rm -rf installtest/.build

realclean: clean-testinstall

# Help target
.PHONY: help
help: ## Show this help.
Expand Down
28 changes: 28 additions & 0 deletions installtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.30)
project(ConsumerBemanOptional)

set(CMAKE_CXX_STANDARD 20)

# Enable testing in this separate project
enable_testing()

# Find the installed package
set(OPTIONAL_INSTALL_DIR "../.install/lib/cmake/beman.optional")
find_package(
beman.optional
REQUIRED
PATHS ${OPTIONAL_INSTALL_DIR}
NO_DEFAULT_PATH
)

# Add your test executable
add_executable(TestInstalledOptional test.cpp)

# Link against the imported target
target_link_libraries(TestInstalledOptional beman::optional)

# Register the test with CTest
add_test(NAME RunInstalledTest COMMAND TestInstalledOptional)

# Ensure 'make test' first builds the 'all' target
set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE)
19 changes: 19 additions & 0 deletions installtest/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// testinstall/test.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/optional/optional.hpp>
#include <iostream>

int main() {
beman::optional::optional<int> empty_opt{};
if (!empty_opt) {
std::cout << "empty_opt is empty!\n";
}

beman::optional::optional<int> opt{26};
if (opt) {
std::cout << "opt = " << *opt << "\n";
}

return 0;
}