Skip to content

Commit

Permalink
everything ok now ?
Browse files Browse the repository at this point in the history
  • Loading branch information
yobeonline committed Feb 10, 2024
1 parent 8422b2f commit 64e9a6a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 88 deletions.
67 changes: 0 additions & 67 deletions .github/workflows/install.yml

This file was deleted.

10 changes: 9 additions & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ jobs:
- name: Publish test report
uses: mikepenz/action-junit-report@v3
with:
report_paths: 'build/test/junit_*.xml'
report_paths: 'build/test/junit_*.xml'

- name: Install
run: cmake --install build --prefix install --config ${{ matrix.config }}

- name: Use install
run: |
cmake -B install_build -S test -D CMAKE_BUILD_TYPE=${{ matrix.config }} -D "io1-money_DIR=install/share/io1-money/cmake"
cmake --build install_build --config ${{ matrix.config }} --parallel
22 changes: 17 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ include(GNUInstallDirs)
add_library(${PROJECT_NAME} INTERFACE include/io1/money.hpp)
target_include_directories(
${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_20)

Expand All @@ -39,17 +39,29 @@ write_basic_package_version_file(

configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/config.cmake.in" "${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/io1/cmake)

install(
EXPORT ${PROJECT_NAME}
NAMESPACE io1::
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
DESTINATION ${CMAKE_INSTALL_DATADIR}/io1/cmake)

install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
DESTINATION ${CMAKE_INSTALL_DATADIR}/io1/cmake)

if(IO1_WITH_TESTS)
add_subdirectory(test)
include(CTest)

find_package(doctest CONFIG REQUIRED)

add_executable(test_${PROJECT_NAME} test/test_money.cpp test/tutorial.cpp)
target_link_libraries(test_${PROJECT_NAME} PRIVATE io1::money
doctest::doctest)

add_test(
NAME test_${PROJECT_NAME}
COMMAND test_${PROJECT_NAME} --reporters=junit
--out=junit_test_${PROJECT_NAME}.xml
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
19 changes: 4 additions & 15 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
cmake_minimum_required(VERSION 3.25)

project(test_io1-money LANGUAGES CXX)
project(test_io1-money_install LANGUAGES CXX)

include(CTest)
find_package(io1_money REQUIRED)

find_package(doctest REQUIRED)
if (NOT TARGET io1::money)
find_package(io1_money REQUIRED)
endif()

add_executable(${PROJECT_NAME} test/test_money.cpp test/tutorial.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE io1::money
doctest::doctest)
add_test(
NAME ${PROJECT_NAME}
COMMAND ${PROJECT_NAME} --reporters=junit
--out=junit_${PROJECT_NAME}.xml
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
add_library(${PROJECT_NAME} test_install.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE io1::money)
6 changes: 6 additions & 0 deletions test/test_install.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "io1/money.hpp"

io1::money add_twice(io1::money const & lhs, io1::money const & rhs) noexcept
{
return lhs + 2 * rhs;
}

0 comments on commit 64e9a6a

Please sign in to comment.