Skip to content

Commit

Permalink
refs #1 Компилируемая библиотека
Browse files Browse the repository at this point in the history
  • Loading branch information
izvolov committed Aug 10, 2019
1 parent cef11af commit db223b8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ language: cpp
- /usr/bin/cmake -BBuild/mylib -H. -DCMAKE_BUILD_TYPE=Debug -DMYLIB_COVERAGE=ON
- /usr/bin/cmake --build Build/mylib --target coverage
after_success:
- coveralls --root . --build-root Build/mylib --include include
- coveralls --root . --build-root Build/mylib --include include --include src

matrix:
include:
Expand Down
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ endif()

###################################################################################################
##
## Основная цель
## Заголовочная библиотека
##
###################################################################################################

Expand All @@ -64,6 +64,17 @@ target_compile_features(mylib INTERFACE cxx_std_17)

add_library(Mylib::mylib ALIAS mylib)

###################################################################################################
##
## Компилируемая библиотека
##
###################################################################################################

add_library(myfeature src/mylib/myfeature.cpp)
target_link_libraries(myfeature PUBLIC mylib)

add_library(Mylib::myfeature ALIAS myfeature)

###################################################################################################
##
## Установка
Expand All @@ -72,7 +83,7 @@ add_library(Mylib::mylib ALIAS mylib)

install(DIRECTORY include/mylib DESTINATION include)

install(TARGETS mylib EXPORT MylibConfig)
install(TARGETS mylib myfeature EXPORT MylibConfig)
install(EXPORT MylibConfig NAMESPACE Mylib:: DESTINATION share/Mylib/cmake)

include(CMakePackageConfigHelpers)
Expand Down
5 changes: 1 addition & 4 deletions include/mylib/myfeature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,5 @@ namespace mylib
\~ \see mystruct
*/
inline bool myfunc (mystruct)
{
return true;
}
bool myfunc (mystruct);
}
9 changes: 9 additions & 0 deletions src/mylib/myfeature.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <mylib/myfeature.hpp>

namespace mylib
{
bool myfunc (mystruct)
{
return true;
}
}
11 changes: 8 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ add_executable(mylib-unit-tests test_main.cpp)
target_sources(mylib-unit-tests PRIVATE mylib/myfeature.cpp)
target_link_libraries(mylib-unit-tests
PRIVATE
Mylib::mylib
Mylib::myfeature
doctest::doctest
)

Expand All @@ -15,11 +15,16 @@ if(MYLIB_COVERAGE AND GCOVR_EXECUTABLE)
target_compile_options(mylib-unit-tests PRIVATE --coverage)
target_link_libraries(mylib-unit-tests PRIVATE gcov)

target_compile_options(myfeature PRIVATE --coverage)
target_link_libraries(myfeature PRIVATE gcov)

add_custom_target(coverage
COMMAND
${GCOVR_EXECUTABLE}
--root=${PROJECT_SOURCE_DIR}/include/
--object-directory=${CMAKE_CURRENT_BINARY_DIR}
--root=${PROJECT_SOURCE_DIR}/
--filter=${PROJECT_SOURCE_DIR}/include
--filter=${PROJECT_SOURCE_DIR}/src
--object-directory=${PROJECT_BINARY_DIR}
DEPENDS
check
)
Expand Down

0 comments on commit db223b8

Please sign in to comment.