From 5703c9ffd6fc6783b1cb9204fb6581665d912d51 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 13 Oct 2018 19:40:57 +0200 Subject: [PATCH 01/45] Fixed formatting --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 717d39f..c88ee23 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,13 @@ catch (const function_loader::exceptions::library_load_failed & error) } catch (const function_loader::exceptions::library_handle_invalid & error) { - // happens when "get_function" called on the function_loader with invalid library handle (may happen after the object was moved) + // happens when "get_function" called on the function_loader with invalid library handle + // (may happen after the object was moved) } catch (const function_loader::exceptions::function_does_not_exist & error) { - // given function not found in the library, might be caused by incorrect signature, or function is not exported (visible) from outside + // given function not found in the library, might be caused by incorrect signature, + // or function is not exported (visible) from outside } ``` From 174af3ca0ee3ad4ebcfcd8b1a41e380eac5a3d37 Mon Sep 17 00:00:00 2001 From: karel-burda <38255062+karel-burda@users.noreply.github.com> Date: Fri, 19 Oct 2018 14:09:40 +0200 Subject: [PATCH 02/45] Added support for parallel make --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b17ab52..a2b6854 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ jobs: - cppcheck --enable=all -I include -I test-utils/include -I tests/unit/include --language=c++ --platform=unix64 --std=c++11 --check-config --suppress=missingIncludeSystem -v ./example ./tests - - cmake --build build --target example --config RelWithDebInfo + - cmake --build build --target example --config RelWithDebInfo -- -j $(nproc) - pushd ./build/bin/ - valgrind --leak-check=full --error-exitcode=255 -v ./example From b7973ed033ba1c5bad2d4bf7f46c6cb9777c1bbd Mon Sep 17 00:00:00 2001 From: karel-burda <38255062+karel-burda@users.noreply.github.com> Date: Fri, 19 Oct 2018 14:13:48 +0200 Subject: [PATCH 03/45] Added parallel build also to tests [skip ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a2b6854..c4b800f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ jobs: - valgrind --leak-check=full --error-exitcode=255 -v ./example - popd - - cmake --build build --target run-all-tests-verbose --config RelWithDebInfo + - cmake --build build --target run-all-tests-verbose --config RelWithDebInfo -- -j $(nproc) - coveralls -e ./build/gtest-src -e build/demo-library -e ./build/CMakeFiles -e ./tests/unit -e ./example -e cmake-helpers -e demo-library -e test-utils --gcov-options '\-lp' - set +e From 4f41c261a9159e29b090b0b44312680611ffbbe6 Mon Sep 17 00:00:00 2001 From: karel-burda <38255062+karel-burda@users.noreply.github.com> Date: Tue, 30 Oct 2018 19:19:13 +0100 Subject: [PATCH 04/45] Fixed formatting --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c88ee23..57583ea 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,8 @@ try func_simple(); std::clog << "func_more_complex returned " << func_more_complex(99.0, "foo"); - // if the "loader" object went out of scope in here, it would free all resources and unload the library handle, - // but for demo purposes, we'll move the instance + // if the "loader" object went out of scope in here, it would free all resources and unload + // the library handle, but for demo purposes, we'll move the instance const auto another_loader = std::move(loader); // do whatever actions you like with the "another_loader" @@ -84,8 +84,8 @@ Where this is the header of the `shared-library.(so|dll|dylib)`: ```cpp extern "C" { -/// LIBRARY_EXPORT is defined elsewhere, but we just need the symbols to be visible from outside the shared libary -/// (e.g. using "__declspec(dllexport)" or "__attribute__((visibility("default")))" on the GCC). +/// LIBRARY_EXPORT is defined elsewhere, but we just need the symbols to be visible from outside +/// the shared libary (e.g. using "__declspec(dllexport)" or "__attribute__((visibility("default")))" on the GCC). /// When using function_loader, we don't need to import any symbols (e.g. "__declspec(dllimport)"), /// because there's no static linking. From 0c0d3f2da01018a31716a9e21649e083935428cd Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Thu, 15 Nov 2018 20:00:51 +0100 Subject: [PATCH 05/45] Updated infrastructure --- CMakeLists.txt | 76 +++++++++++---------------- README.md | 107 +++++++++++++++++++++++++++++--------- tests/unit/CMakeLists.txt | 71 +++++++------------------ 3 files changed, 132 insertions(+), 122 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3501b69..efa5c2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,58 +1,40 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR) -project(function-loader VERSION 1.2.0 LANGUAGES CXX) +project(function-loader VERSION 1.2.1 LANGUAGES CXX) -include("cmake-helpers/cmake-helpers/messages.cmake") -include("cmake-helpers/cmake-helpers/standard-settings.cmake") -include("cmake-helpers/cmake-helpers/warnings.cmake") +add_library(${PROJECT_NAME} INTERFACE) -option(EXAMPLE "Build example usage" ON) -option(UNIT-TESTS "Build unit tests" OFF) +target_sources(${PROJECT_NAME} + INTERFACE + include/function_loader/function_loader.hpp + include/function_loader/exceptions.hpp -_print_project_version() + include/function_loader/detail/function_loader_base.hpp + include/function_loader/detail/function_loader_platform_specific.hpp + $<$:include/function_loader/detail/function_loader_platform_specific_windows.hpp> + $<$:include/function_loader/detail/function_loader_platform_specific_unix.hpp> -_set_standards("11" "14") -_set_default_build_type("Debug") + include/function_loader/detail/library_loader.hpp + include/function_loader/detail/library_loader_base.hpp + include/function_loader/detail/library_loader_platform_specific.hpp + $<$:include/function_loader/detail/library_loader_platform_specific_windows.hpp> + $<$:include/function_loader/detail/library_loader_platform_specific_unix.hpp>) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) +target_include_directories(${PROJECT_NAME} + INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/include) -set(HEADERS - include/function_loader/function_loader.hpp - include/function_loader/exceptions.hpp +target_compile_features(${PROJECT_NAME} + INTERFACE + cxx_std_11) - include/function_loader/detail/function_loader_base.hpp - include/function_loader/detail/function_loader_platform_specific.hpp - $<$:include/function_loader/detail/function_loader_platform_specific_windows.hpp> - $<$:include/function_loader/detail/function_loader_platform_specific_unix.hpp> +install(TARGETS ${PROJECT_NAME} + EXPORT _targets) - include/function_loader/detail/library_loader.hpp - include/function_loader/detail/library_loader_base.hpp - include/function_loader/detail/library_loader_platform_specific.hpp - $<$:include/function_loader/detail/library_loader_platform_specific_windows.hpp> - $<$:include/function_loader/detail/library_loader_platform_specific_unix.hpp>) +export(EXPORT _targets + NAMESPACE burda:: + FILE "${PROJECT_NAME}-config.cmake") -set(OTHER - README.md - .travis.yml - ${PROJECT_NAME}-config.cmake.in) - -add_custom_target(${PROJECT_NAME} SOURCES ${HEADERS} ${OTHER}) - -configure_file(${PROJECT_NAME}-config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" @ONLY) - -if (EXAMPLE OR UNIT-TESTS) - add_subdirectory(demo-library) - - if (EXAMPLE) - add_subdirectory(example) - endif() - - if (UNIT-TESTS) - # test-utils are being used as a git sub-module - set(USED-AS-SUBMODULE ON BOOL) - add_subdirectory(test-utils) - - add_subdirectory(tests/unit) - endif() -endif() +include(CMakePackageConfigHelpers) +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + COMPATIBILITY ExactVersion) diff --git a/README.md b/README.md index 57583ea..8c8ab7b 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,71 @@ Exceptions provide additional information about the reason using `what()`, see # Usage In order to use the `function_loader`, it's the `include` directory that matters. Just make sure that the header search path is pointing to the [include](include) directory located in the root directory. -On POSIXes, the `libdl` has to be linked to the final executable. - -You can use the provided CMake package configuration at [function-loader-config.cmake.in](function-loader-config.cmake.in). Implementation resides in the `burda::function_loader` namespace, so it might be useful to do something like `namespace fe = burda::function_loader;` in your project. +There are basically these options when it comes to build system integration: + +## 1. CMake Way +Recommended option. + +There are essentially these ways of how to use this package depending on your preferences our build architecture: + +### A) Generate directly + +Call `add_subdirectory(...)` directly in your CMakeLists.txt: + +```cmake +add_executable("my-project" main.cpp) + +add_subdirectory() +# Example: add_subdirectory(test-utils ${CMAKE_BINARY_DIR}/test-utils) + +# Query of package version +message(STATUS "Current version of test-utils is: ${test-utils_VERSION}") + +add_library(burda::test-utils ALIAS test-utils) + +# This will import search paths, compile definitions and other dependencies of the test-utils as well +target_link_libraries("my-project" test-utils) +# Or with private visibility: target_link_libraries("my-project" PRIVATE test-utils) + +``` + +### B) Generate separately + +Generation phase on the test-utils is run separately, that means that you run: +```cmake +cmake +# Example: cmake -Bbuild/test-utils -Htest-utils in the root of your project +``` + +This will create automatically generated package configuration file `test-utils-config.cmake` that contains exported target and all important information. + +Then you can do this in your CMakeLists.txt: + +```cmake +add_executable("my-project" main.cpp) + +find_package(test-utils CONFIG PATHS ) +# Alternatively assuming that the "test-utils_DIR" variable is set: find_package(test-utils CONFIG) + +# You can also query (or force specific version during the previous "find_package()" call) +message(STATUS "Found version of test-utils is: ${test-utils_VERSION}") + +# This will import search paths, compile definitions and other dependencies of the test-utils as well +target_link_libraries("my-project" burda::test-utils) +# Or with public visibility: target_link_libraries("my-project" PUBLIC burda::test-utils) + +``` + +## 2. Manual Way +Not recommended. + +Make sure that the `include` directory is in the search paths. + +You also have to set C++11 standard and potentially other settings as well (e.g. linking `libdl` on POSIXes). + ### Example ```cpp #include @@ -110,30 +169,30 @@ I personally prefer to specify a separate build directory explicitly: You can of course specify ordinary cmake options like build type (debug, release with debug info, ...), used generator, etc. # Unit Tests -For building tests, run cmake with the option `UNIT-TESTS=ON`: - -`cmake -Bbuild -H. -DUNIT-TESTS:BOOL=ON` - -The project is using the `gtest` that is automatically downloaded, "cmaked" and built in its build step -(the fixed stable revision of the `gtest` is used). - -Then, you can run the default test target (e.g. `make test` or `RUN_TESTS` in the Visual Studio) -or the custom target `run-all-tests-verbose` (which is recommended and used in the Continuous Integration). - -The target `run-all-tests-verbose` uses the `ctest` for executing the tests binary and has built-in timeout feature (useful because of dead-locks for example). - -If you want to debug tests and implementation, run the target `tests` target manually (ideally in the Debug mode). - -It is also possible to turn off build of the example, and build just the tests: +Tests require sub-module [cmake-helpers](https://github.com/karel-burda/cmake-helpers) and [test-utils](https://github.com/karel-burda/test-utils). + +For building tests, run CMake in the source directory [tests/unit](tests/unit): + +```cmake +cmake -Bbuild -H. +# You can also add coverage by appending "-DCOVERAGE:BOOL=ON" +cmake -Bbuild/tests/unit -Htests/unit -Dcpp-utils_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo +cmake --build build/tests/unit --config RelWithDebInfo +# This runs target "run-all-tests-verbose" that will also run the tests with timeout, etc.: +cmake --build build/tests/unit --target run-all-tests-verbose --config RelWithDebInfo +# Or you can execute tests manually +``` -`cmake -Bbuild -H. -DEXAMPLE:BOOL=OFF -DUNIT-TESTS:BOOL=ON` +For more info, see [.travis.yml](.travis.yml). # Continuous Integration -Continuous Integration is now being run Linux (with GCC 5.x) on Travis: https://travis-ci.org/karel-burda/function-loader. +Continuous Integration is now being run Linux (with GCC 6.x) and OS X on Travis: https://travis-ci.org/karel-burda/cpp-utils. -Compilers are set-up to treat warnings as errors and with pedantic warning level. Targets are built in a release mode with debug symbols (because of the [valgrind](http://valgrind.org) and code coverage measure). +Compilers are set-up to treat warnings as errors and with pedantic warning level. +Targets are built debug symbols with code coverage measure and release with debug symbols). -The project is using just one stage (because of the overhead of spawning other stages) -* `example and tests (C++14)` -- cppcheck, build (linux, gcc5), valgrind, tests +The project is using thse stages: +* `cpp-utils, tests -- linux, debug, gcc, cppcheck, coverage` +* `cpp-utils, tests -- osx, release with debug info, clang` -Project uses [coveralls.io](https://coveralls.io/github/karel-burda/function-loader) for code coverage summary and [codacy](https://app.codacy.com/app/karel-burda/function-loader/dashboard) for the coding style and additional static analysis. +Project uses [codecov.io](https://codecov.io/gh/karel-burda/cpp-utils) for code coverage summary. diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index a0282b5..3df8ee4 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -2,73 +2,42 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR) project(tests LANGUAGES CXX) -_print_status_message("building with unit tests") -_print_project_version() +message(STATUS "Building unit tests") -include("${CMAKE_SOURCE_DIR}/cmake-helpers/cmake-helpers/code-coverage.cmake") -include("${CMAKE_SOURCE_DIR}/cmake-helpers/cmake-helpers/gtest.cmake") -include("${CMAKE_SOURCE_DIR}/cmake-helpers/cmake-helpers/threads.cmake") - -_gtest_download_and_build("gtest-build" "Release" "gtest-src" "0957cce368316577aae5ddfffcb67f24621d69e7") +include(${CMAKE_CURRENT_SOURCE_DIR}/../../submodules/cmake-helpers/cmake-helpers/cpp_coverage.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../submodules/cmake-helpers/cmake-helpers/cpp_gtest.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../submodules/cmake-helpers/cmake-helpers/cpp_warnings.cmake) add_executable(${PROJECT_NAME} "") -target_include_directories(${PROJECT_NAME} PUBLIC include) -target_sources( - ${PROJECT_NAME} - PUBLIC - src/exceptions_test.cpp - src/library_loader_test.cpp - src/function_loader_test.cpp - - PRIVATE - include/helpers.hpp) +target_sources(${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/include/helpers.hpp -add_dependencies(${PROJECT_NAME} gtest-build) + ${CMAKE_CURRENT_SOURCE_DIR}/src/exceptions_test.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/function_loader_test.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/library_loader_test.cpp) -_gtest_resolve_build_options(${PROJECT_NAME}) +find_package(test-utils CONFIG REQUIRED) +message(STATUS "Found version of test-utils is: ${test-utils_VERSION}") +target_link_libraries(${PROJECT_NAME} PRIVATE burda::test-utils) -find_package(function-loader REQUIRED CONFIG PATHS ${CMAKE_BINARY_DIR} NO_DEFAULT_PATH) -target_include_directories(${PROJECT_NAME} PUBLIC ${function-loader_INCLUDE_DIRS}) -target_link_libraries(${PROJECT_NAME} PUBLIC ${function-loader_LIBRARIES}) - -find_package(test-utils REQUIRED CONFIG PATHS ${CMAKE_BINARY_DIR} NO_DEFAULT_PATH) -target_include_directories(${PROJECT_NAME} PUBLIC ${test-utils_INCLUDE_DIRS}) -target_link_libraries(${PROJECT_NAME} PUBLIC ${test-utils_LIBRARIES}) +burda_cmake_helpers_cpp_gtest_bootstrap_and_link(${PROJECT_NAME} "release-1.8.1" "Release" PRIVATE) if (COVERAGE) - _print_status_message("building unit tests with code coverage") - - _coverage_add_build_options(${PROJECT_NAME}) + message(STATUS "Building unit tests with code coverage") + burda_cmake_helpers_cpp_coverage_add_build_options(${PROJECT_NAME} PRIVATE) endif() enable_testing() -# We deliberately copy the testing library into a subdirectories in order to test whether loading of library from more subdirectories work -get_target_property(_demo-library_prefix demo-library PREFIX) -get_target_property(_demo-library_suffix demo-library SUFFIX) -set(_demo-library_location ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -set(_demo-library_filename "${_demo-library_prefix}demo-library${_demo-library_suffix}") -if (MSVC) - string(APPEND _demo-library_location "/${CMAKE_BUILD_TYPE}") -endif() - -add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${_demo-library_location}/${_demo-library_filename} - ${_demo-library_location}/subdirectory/another/${_demo-library_filename}) - -# create invalid (empty) file that will be used in the tests to verify, whether the implementation correctly refuses to load this file -#file(WRITE) - add_test(NAME all-unit-tests WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND $ --gtest_color=yes --gtest_shuffle) add_custom_target(run-all-tests-verbose - COMMAND ${CMAKE_CTEST_COMMAND} -V -C ${CMAKE_BUILD_TYPE} --build-run-dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} --timeout 300 - DEPENDS ${PROJECT_NAME}) + COMMAND ${CMAKE_CTEST_COMMAND} -V -C ${CMAKE_BUILD_TYPE} --build-run-dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} --timeout 300 + DEPENDS ${PROJECT_NAME}) -_add_pedantic_warning_level(${PROJECT_NAME}) -_supress_cxx_compiler_warning(${PROJECT_NAME} "keyword-macro") -_supress_cxx_compiler_warning(${PROJECT_NAME} "maybe-uninitialized") +burda_cmake_helpers_cpp_warnings_add_pedantic_level(${PROJECT_NAME} PRIVATE) +burda_cmake_helpers_cpp_warnings_suppress(${PROJECT_NAME} "keyword-macro" PRIVATE) From a1b17cbcaa859ad41c547200e8350d12ced8e3e0 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Thu, 15 Nov 2018 20:01:35 +0100 Subject: [PATCH 06/45] cmake-helpers moved --- .gitmodules | 2 +- cmake-helpers => submodules/cmake-helpers | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename cmake-helpers => submodules/cmake-helpers (100%) diff --git a/.gitmodules b/.gitmodules index 26bcbc2..62c0cde 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ [submodule "cmake-helpers"] - path = cmake-helpers + path = submodules/cmake-helpers url = https://github.com/karel-burda/cmake-helpers branch = master [submodule "test-utils"] diff --git a/cmake-helpers b/submodules/cmake-helpers similarity index 100% rename from cmake-helpers rename to submodules/cmake-helpers From 8670784ac4f364c3e92a3d4dc2f5db4f013803a2 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Thu, 15 Nov 2018 20:02:10 +0100 Subject: [PATCH 07/45] test-utils moved --- .gitmodules | 2 +- test-utils => submodules/test-utils | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename test-utils => submodules/test-utils (100%) diff --git a/.gitmodules b/.gitmodules index 62c0cde..3e93187 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,5 +3,5 @@ url = https://github.com/karel-burda/cmake-helpers branch = master [submodule "test-utils"] - path = test-utils + path = submodules/test-utils url = https://github.com/karel-burda/test-utils diff --git a/test-utils b/submodules/test-utils similarity index 100% rename from test-utils rename to submodules/test-utils From 5f0ed5f5e794e48af5c64aca329ef55bf96f3865 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Thu, 15 Nov 2018 20:04:40 +0100 Subject: [PATCH 08/45] Shallow clone for sub-modules --- .gitmodules | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitmodules b/.gitmodules index 3e93187..124d248 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,6 +2,8 @@ path = submodules/cmake-helpers url = https://github.com/karel-burda/cmake-helpers branch = master + shallow = true [submodule "test-utils"] path = submodules/test-utils url = https://github.com/karel-burda/test-utils + shallow = true From 5cff655adc3c1bb115a57f34dc74e27d1e7761cb Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Thu, 15 Nov 2018 20:08:37 +0100 Subject: [PATCH 09/45] Updated CI --- .codecov.yml | 2 ++ .travis.yml | 56 ++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 .codecov.yml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..e6b99e6 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,2 @@ +ignore: + - "tests" diff --git a/.travis.yml b/.travis.yml index c4b800f..19b3730 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,17 @@ stages: - - example and tests (C++14) -- cppcheck, build (linux, gcc5), valgrind, tests + - cpp-utils, tests -- linux, debug, gcc, cppcheck, coverage + - cpp-utils, tests -- osx, release with debug info, clang + +git: + depth: 1 jobs: include: - - stage: example and tests (C++14) -- cppcheck, build (linux, gcc5), valgrind, tests + - stage: cpp-utils, tests -- linux, debug, gcc, cppcheck, coverage sudo: required dist: trusty language: cpp + env: BUILD_TYPE="Debug" compiler: g++ os: linux addons: @@ -14,26 +19,51 @@ jobs: sources: - ubuntu-toolchain-r-test packages: - - g++-5 - - valgrind + - g++-6 - cppcheck before_install: - pip install --user cpp-coveralls - install: export CXX="g++-5" + install: export CXX="g++-6" script: - set -e - - cmake -Bbuild -H. -DEXAMPLE:BOOL=ON -DUNIT-TESTS:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCOVERAGE:BOOL=ON + - cppcheck --enable=all + -I include + --language=c++ + --platform=unix64 + --std=c++11 + --check-config + --suppress=missingIncludeSystem + -v ./tests + + - cmake -Bbuild -H. -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + - cmake -Bbuild/tests/unit -Htests/unit + -Dfunction_loader_DIR:PATH=$(pwd)/build + -Dtest-utils_DIR:PATH=$(pwd)/build/submodules/test-utils + -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + -DCOVERAGE:BOOL=ON + - cmake --build build/tests/unit --target run-all-tests-verbose --config $BUILD_TYPE - - cppcheck --enable=all -I include -I test-utils/include -I tests/unit/include --language=c++ --platform=unix64 --std=c++11 --check-config --suppress=missingIncludeSystem -v ./example ./tests + - bash <(curl -s https://codecov.io/bash) - - cmake --build build --target example --config RelWithDebInfo -- -j $(nproc) + - set +e - - pushd ./build/bin/ - - valgrind --leak-check=full --error-exitcode=255 -v ./example - - popd + - stage: cpp-utils, tests -- osx, release with debug info, clang + os: osx + language: cpp + env: BUILD_TYPE="RelWithDebInfo" + compiler: clang + script: + - set -e - - cmake --build build --target run-all-tests-verbose --config RelWithDebInfo -- -j $(nproc) - - coveralls -e ./build/gtest-src -e build/demo-library -e ./build/CMakeFiles -e ./tests/unit -e ./example -e cmake-helpers -e demo-library -e test-utils --gcov-options '\-lp' + - cmake -Bbuild -H. -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + - cmake -Bbuild/tests/unit -Htests/unit + -Dfunction_loader_DIR:PATH=$(pwd)/build + -Dtest-utils_DIR:PATH=$(pwd)/build/submodules/test-utils + -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + -DCOVERAGE:BOOL=ON + - cmake --build build/tests/unit --target run-all-tests-verbose --config $BUILD_TYPE - set +e From c97d446e241a8360342074d3e74b15ed9aa5d63d Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Thu, 15 Nov 2018 20:09:11 +0100 Subject: [PATCH 10/45] Updated tests according to sub-modules --- README.md | 2 +- tests/unit/src/function_loader_test.cpp | 2 +- tests/unit/src/library_loader_test.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c8ab7b..78f4824 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Version](https://img.shields.io/badge/version-1.2.0-green.svg) +![Version](https://img.shields.io/badge/version-1.2.1-green.svg) [![License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat)](LICENSE) [![Build Status](https://travis-ci.org/karel-burda/function-loader.svg?branch=master)](https://travis-ci.org/karel-burda/function-loader) [![Coverage Status](https://coveralls.io/repos/github/karel-burda/function-loader/badge.svg?branch=master)](https://coveralls.io/github/karel-burda/function-loader?branch=master) diff --git a/tests/unit/src/function_loader_test.cpp b/tests/unit/src/function_loader_test.cpp index bb1469b..20e78af 100644 --- a/tests/unit/src/function_loader_test.cpp +++ b/tests/unit/src/function_loader_test.cpp @@ -3,8 +3,8 @@ #include #include #include +#include #include -#include #include "helpers.hpp" diff --git a/tests/unit/src/library_loader_test.cpp b/tests/unit/src/library_loader_test.cpp index 58d100e..b1923b9 100644 --- a/tests/unit/src/library_loader_test.cpp +++ b/tests/unit/src/library_loader_test.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include "helpers.hpp" From 72af1523936e2e27866cc6d3d4ff80c89b668972 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Thu, 15 Nov 2018 20:16:10 +0100 Subject: [PATCH 11/45] Sub-modules updated to newest versions --- submodules/cmake-helpers | 2 +- submodules/test-utils | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/submodules/cmake-helpers b/submodules/cmake-helpers index d2e1f43..cee2276 160000 --- a/submodules/cmake-helpers +++ b/submodules/cmake-helpers @@ -1 +1 @@ -Subproject commit d2e1f430e150323908fc1bd42f304d940cf94108 +Subproject commit cee2276145b31775f4d7106bc97beaa130b07def diff --git a/submodules/test-utils b/submodules/test-utils index ddb3a9b..1ac2f8e 160000 --- a/submodules/test-utils +++ b/submodules/test-utils @@ -1 +1 @@ -Subproject commit ddb3a9b1b2b763b630104322ceaa783e7def3c05 +Subproject commit 1ac2f8e82dcd25cf5ff747aac900a200cea18596 From 2149828162c34a5c67abf5d403a9144ce2d4cd47 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Fri, 16 Nov 2018 10:23:35 +0100 Subject: [PATCH 12/45] Updated CI --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 19b3730..61b0876 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ stages: - - cpp-utils, tests -- linux, debug, gcc, cppcheck, coverage - - cpp-utils, tests -- osx, release with debug info, clang + - function-loader, example, tests -- linux, debug, gcc, cppcheck, coverage + - function-loader, example, tests -- osx, release with debug info, valgrind, clang git: depth: 1 @@ -39,7 +39,7 @@ jobs: - cmake -Bbuild -H. -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit - -Dfunction_loader_DIR:PATH=$(pwd)/build + -Dfunction-loader_DIR:PATH=$(pwd)/build -Dtest-utils_DIR:PATH=$(pwd)/build/submodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DCOVERAGE:BOOL=ON @@ -54,13 +54,15 @@ jobs: language: cpp env: BUILD_TYPE="RelWithDebInfo" compiler: clang + before_install: + - brew install valgrind script: - set -e - cmake -Bbuild -H. -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit - -Dfunction_loader_DIR:PATH=$(pwd)/build + -Dfunction-loader_DIR:PATH=$(pwd)/build -Dtest-utils_DIR:PATH=$(pwd)/build/submodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DCOVERAGE:BOOL=ON From fc37dfb3115f6cd894565c7207fdceaf8096676b Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Fri, 16 Nov 2018 10:42:20 +0100 Subject: [PATCH 13/45] Finding package in tests --- tests/unit/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 3df8ee4..ec1abbe 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -22,6 +22,10 @@ find_package(test-utils CONFIG REQUIRED) message(STATUS "Found version of test-utils is: ${test-utils_VERSION}") target_link_libraries(${PROJECT_NAME} PRIVATE burda::test-utils) +find_package(function-loader CONFIG REQUIRED) +message(STATUS "Found version of function-loader is: ${function-loader_VERSION}") +target_link_libraries(${PROJECT_NAME} PRIVATE burda::function-loader) + burda_cmake_helpers_cpp_gtest_bootstrap_and_link(${PROJECT_NAME} "release-1.8.1" "Release" PRIVATE) if (COVERAGE) From 7b768e2f0592a6470a0fa27fec088ff6dbcc03cc Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Fri, 16 Nov 2018 11:08:25 +0100 Subject: [PATCH 14/45] Fixed paths --- CMakeLists.txt | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efa5c2c..0b910b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,19 +6,23 @@ add_library(${PROJECT_NAME} INTERFACE) target_sources(${PROJECT_NAME} INTERFACE - include/function_loader/function_loader.hpp - include/function_loader/exceptions.hpp - - include/function_loader/detail/function_loader_base.hpp - include/function_loader/detail/function_loader_platform_specific.hpp - $<$:include/function_loader/detail/function_loader_platform_specific_windows.hpp> - $<$:include/function_loader/detail/function_loader_platform_specific_unix.hpp> - - include/function_loader/detail/library_loader.hpp - include/function_loader/detail/library_loader_base.hpp - include/function_loader/detail/library_loader_platform_specific.hpp - $<$:include/function_loader/detail/library_loader_platform_specific_windows.hpp> - $<$:include/function_loader/detail/library_loader_platform_specific_unix.hpp>) + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/function_loader.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/exceptions.hpp + + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/function_loader_base.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/function_loader_platform_specific.hpp + $<$: + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/function_loader_platform_specific_windows.hpp> + $<$: + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/function_loader_platform_specific_unix.hpp> + + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/library_loader.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/library_loader_base.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/library_loader_platform_specific.hpp + $<$: + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/library_loader_platform_specific_windows.hpp> + $<$: + ${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/library_loader_platform_specific_unix.hpp>) target_include_directories(${PROJECT_NAME} INTERFACE From 8051708c80f621d6c8cca760bdf4998a729138f3 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Fri, 16 Nov 2018 11:14:47 +0100 Subject: [PATCH 15/45] Fixed include dir --- tests/unit/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index ec1abbe..41013fd 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -18,6 +18,10 @@ target_sources(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/function_loader_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/library_loader_test.cpp) +target_include_directories(${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/include) + find_package(test-utils CONFIG REQUIRED) message(STATUS "Found version of test-utils is: ${test-utils_VERSION}") target_link_libraries(${PROJECT_NAME} PRIVATE burda::test-utils) From 5a172b17789cf6bdfcef553a6313da11c6b63865 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Fri, 16 Nov 2018 11:43:04 +0100 Subject: [PATCH 16/45] Linking with dl --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b910b0..1cc9539 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,10 @@ target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_link_libraries(${PROJECT_NAME} + PUBLIC + $<$:${CMAKE_DL_LIBS}>) + target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11) From 4c3fb613af9430ffab295c4a9c16f434e07761a9 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Fri, 16 Nov 2018 11:46:24 +0100 Subject: [PATCH 17/45] Have to use INTERFACE --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cc9539..37b50de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/include) target_link_libraries(${PROJECT_NAME} - PUBLIC + INTERFACE $<$:${CMAKE_DL_LIBS}>) target_compile_features(${PROJECT_NAME} From 5550099418b404d711f14428b18a4220b8784f8b Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Fri, 16 Nov 2018 17:05:36 +0100 Subject: [PATCH 18/45] Debugging Linux build on the CI --- CMakeLists.txt | 9 ++++++--- .../detail/function_loader_platform_specific.hpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37b50de..5bdafbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,12 @@ target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) -target_link_libraries(${PROJECT_NAME} - INTERFACE - $<$:${CMAKE_DL_LIBS}>) +if (UNIX AND NOT APPLE) + message(STATUS "dl libs: ${CMAKE_DL_LIBS}") + set_target_properties(${PROJECT_NAME} + PROPERTIES + INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}") +endif() target_compile_features(${PROJECT_NAME} INTERFACE diff --git a/include/function_loader/detail/function_loader_platform_specific.hpp b/include/function_loader/detail/function_loader_platform_specific.hpp index 9a251bf..17e193e 100644 --- a/include/function_loader/detail/function_loader_platform_specific.hpp +++ b/include/function_loader/detail/function_loader_platform_specific.hpp @@ -2,7 +2,7 @@ #ifdef _WIN32 #include "function_loader/detail/function_loader_platform_specific_windows.hpp" -#elif __linux__ +#elif __unix__ #include "function_loader/detail/function_loader_platform_specific_unix.hpp" #else #error Platform not implemented From a1d966cce93d5a38153151af713a0d09708bfead Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Fri, 16 Nov 2018 19:38:21 +0100 Subject: [PATCH 19/45] Fixed build of demo-library --- CMakeLists.txt | 4 ++-- demo-library/CMakeLists.txt | 23 ++++++++----------- .../function_loader_platform_specific.hpp | 2 +- .../library_loader_platform_specific.hpp | 2 +- tests/unit/CMakeLists.txt | 20 ++++++++++++++++ tests/unit/src/library_loader_test.cpp | 2 +- 6 files changed, 35 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bdafbe..afac6ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,8 +28,8 @@ target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) -if (UNIX AND NOT APPLE) - message(STATUS "dl libs: ${CMAKE_DL_LIBS}") +if (CMAKE_DL_LIBS) + message(STATUS "Will add ${CMAKE_DL_LIBS}") set_target_properties(${PROJECT_NAME} PROPERTIES INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}") diff --git a/demo-library/CMakeLists.txt b/demo-library/CMakeLists.txt index f3fbb6d..8119546 100644 --- a/demo-library/CMakeLists.txt +++ b/demo-library/CMakeLists.txt @@ -2,28 +2,23 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR) project(demo-library LANGUAGES CXX) -_print_status_message("building demo library") -_print_project_version() +message(STATUS "Building demo library") -include(GenerateExportHeader) +include(${CMAKE_CURRENT_SOURCE_DIR}/../submodules/cmake-helpers/cmake-helpers/cpp_warnings.cmake) add_library(${PROJECT_NAME} SHARED) -_add_pedantic_warning_level(${PROJECT_NAME}) - +include(GenerateExportHeader) set(CMAKE_CXX_VISIBILITY_PRESET default) generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME "export.hpp") -FILE(COPY - ${CMAKE_CURRENT_BINARY_DIR}/export.hpp - DESTINATION - ${CMAKE_CURRENT_SOURCE_DIR}/src -) +FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}/export.hpp + DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/src) target_sources(${PROJECT_NAME} PUBLIC - src/demo-library.hpp - src/demo-library.cpp - src/export.hpp) + ${CMAKE_CURRENT_SOURCE_DIR}/src/demo-library.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/demo-library.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/export.hpp) # Unfortunately, we cannot use SUFFIX as empty string property on MSVC, because the LoadLibrary method from WinAPI # checks whether the file name has some suffix at all. For simplicity, use the same suffix also on POSIXEs @@ -31,3 +26,5 @@ set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".dll") + +burda_cmake_helpers_cpp_warnings_add_pedantic_level(${PROJECT_NAME} PRIVATE) diff --git a/include/function_loader/detail/function_loader_platform_specific.hpp b/include/function_loader/detail/function_loader_platform_specific.hpp index 17e193e..eba62e8 100644 --- a/include/function_loader/detail/function_loader_platform_specific.hpp +++ b/include/function_loader/detail/function_loader_platform_specific.hpp @@ -2,7 +2,7 @@ #ifdef _WIN32 #include "function_loader/detail/function_loader_platform_specific_windows.hpp" -#elif __unix__ +#elif defined(__unix__) || defined(__APPLE__) #include "function_loader/detail/function_loader_platform_specific_unix.hpp" #else #error Platform not implemented diff --git a/include/function_loader/detail/library_loader_platform_specific.hpp b/include/function_loader/detail/library_loader_platform_specific.hpp index ae94de7..5cca0b4 100644 --- a/include/function_loader/detail/library_loader_platform_specific.hpp +++ b/include/function_loader/detail/library_loader_platform_specific.hpp @@ -2,7 +2,7 @@ #ifdef _WIN32 #include "function_loader/detail/library_loader_platform_specific_windows.hpp" -#elif __linux__ +#elif defined(__unix__) || defined(__APPLE__) #include "function_loader/detail/library_loader_platform_specific_unix.hpp" #else #error Platform not implemented diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 41013fd..ede17e0 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -37,6 +37,26 @@ if (COVERAGE) burda_cmake_helpers_cpp_coverage_add_build_options(${PROJECT_NAME} PRIVATE) endif() +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library ${CMAKE_CURRENT_BINARY_DIR}/demo-library) + +# We deliberately copy the testing library into a subdirectories in order to test whether loading of library from more subdirectories work +get_target_property(_demo-library_prefix demo-library PREFIX) +get_target_property(_demo-library_suffix demo-library SUFFIX) +set(_demo-library_location ${CMAKE_CURRENT_BINARY_DIR}/demo-library) +set(_demo-library_filename ${_demo-library_prefix}demo-library${_demo-library_suffix}) +if (MSVC) + string(APPEND _demo-library_location /${CMAKE_BUILD_TYPE}) +endif() + +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${_demo-library_location}/${_demo-library_filename} + ${_demo-library_location}/subdirectory/another/${_demo-library_filename}) + +# create invalid (empty) file that will be used in the tests to verify, whether the implementation correctly refuses to load this file +#file(WRITE) + enable_testing() add_test(NAME all-unit-tests diff --git a/tests/unit/src/library_loader_test.cpp b/tests/unit/src/library_loader_test.cpp index b1923b9..dd57e73 100644 --- a/tests/unit/src/library_loader_test.cpp +++ b/tests/unit/src/library_loader_test.cpp @@ -74,7 +74,7 @@ TEST(library_loader, resource_deallocation) // error is expected, because the handle is freed #ifdef _WIN32 EXPECT_EQ(FreeLibrary(handle), 0); -#elif __linux__ +#elif defined(__unix__) || defined(__APPLE__) EXPECT_NE(dlclose(handle), 0); #endif } From 8e06047f7368b80b5a274c2ac7b22425709f5b5f Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 17 Nov 2018 07:24:30 +0100 Subject: [PATCH 20/45] Working copying of the lib --- tests/unit/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index ede17e0..1506f7a 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -38,6 +38,7 @@ if (COVERAGE) endif() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library ${CMAKE_CURRENT_BINARY_DIR}/demo-library) +add_dependencies(${PROJECT_NAME} demo-library) # We deliberately copy the testing library into a subdirectories in order to test whether loading of library from more subdirectories work get_target_property(_demo-library_prefix demo-library PREFIX) @@ -52,15 +53,18 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${_demo-library_location}/${_demo-library_filename} - ${_demo-library_location}/subdirectory/another/${_demo-library_filename}) + ${CMAKE_CURRENT_BINARY_DIR}/${_demo-library_filename} -# create invalid (empty) file that will be used in the tests to verify, whether the implementation correctly refuses to load this file + COMMAND ${CMAKE_COMMAND} -E copy + ${_demo-library_location}/${_demo-library_filename} + ${CMAKE_CURRENT_BINARY_DIR}/subdirectory/another/${_demo-library_filename}) + +# TODO: create invalid (empty) file that will be used in the tests to verify, whether the implementation correctly refuses to load this file #file(WRITE) enable_testing() add_test(NAME all-unit-tests - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND $ --gtest_color=yes --gtest_shuffle) add_custom_target(run-all-tests-verbose From 65440cb556bdaea1223544a28a1865a1a5d48091 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 17 Nov 2018 18:59:00 +0100 Subject: [PATCH 21/45] Added post_build_steps.cmake for the demo-library --- demo-library/post_build_steps.cmake | 22 ++++++++++++++++++++++ tests/unit/CMakeLists.txt | 19 +------------------ 2 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 demo-library/post_build_steps.cmake diff --git a/demo-library/post_build_steps.cmake b/demo-library/post_build_steps.cmake new file mode 100644 index 0000000..e081d7d --- /dev/null +++ b/demo-library/post_build_steps.cmake @@ -0,0 +1,22 @@ +macro(_burda_function_loader_demo_library_add_post_build_steps _target) + get_target_property(_demo-library_prefix demo-library PREFIX) + get_target_property(_demo-library_suffix demo-library SUFFIX) + set(_demo-library_location ${CMAKE_CURRENT_BINARY_DIR}/demo-library) + set(_demo-library_filename ${_demo-library_prefix}demo-library${_demo-library_suffix}) + if (MSVC) + string(APPEND _demo-library_location /${CMAKE_BUILD_TYPE}) + endif() + + add_custom_command(TARGET ${_target} + POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E copy + ${_demo-library_location}/${_demo-library_filename} + ${CMAKE_CURRENT_BINARY_DIR}/${_demo-library_filename} + + # We deliberately copy the testing library into a subdirectories in order to test whether loading of library from nested dirs work + COMMAND + ${CMAKE_COMMAND} -E copy + ${_demo-library_location}/${_demo-library_filename} + ${CMAKE_CURRENT_BINARY_DIR}/subdirectory/another/${_demo-library_filename}) +endmacro() diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 1506f7a..afdcd94 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -40,24 +40,7 @@ endif() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library ${CMAKE_CURRENT_BINARY_DIR}/demo-library) add_dependencies(${PROJECT_NAME} demo-library) -# We deliberately copy the testing library into a subdirectories in order to test whether loading of library from more subdirectories work -get_target_property(_demo-library_prefix demo-library PREFIX) -get_target_property(_demo-library_suffix demo-library SUFFIX) -set(_demo-library_location ${CMAKE_CURRENT_BINARY_DIR}/demo-library) -set(_demo-library_filename ${_demo-library_prefix}demo-library${_demo-library_suffix}) -if (MSVC) - string(APPEND _demo-library_location /${CMAKE_BUILD_TYPE}) -endif() - -add_custom_command(TARGET ${PROJECT_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${_demo-library_location}/${_demo-library_filename} - ${CMAKE_CURRENT_BINARY_DIR}/${_demo-library_filename} - - COMMAND ${CMAKE_COMMAND} -E copy - ${_demo-library_location}/${_demo-library_filename} - ${CMAKE_CURRENT_BINARY_DIR}/subdirectory/another/${_demo-library_filename}) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library/post_build_steps.cmake) # TODO: create invalid (empty) file that will be used in the tests to verify, whether the implementation correctly refuses to load this file #file(WRITE) From e974b45d440f1f09b14d83c38fa64791fc20c8f2 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 17 Nov 2018 19:07:51 +0100 Subject: [PATCH 22/45] Building example --- .travis.yml | 13 +++++++++++-- example/CMakeLists.txt | 23 ++++++++++++++--------- tests/unit/CMakeLists.txt | 1 + 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61b0876..842ade1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ git: jobs: include: - - stage: cpp-utils, tests -- linux, debug, gcc, cppcheck, coverage + - stage: function-loader, example, tests -- linux, debug, gcc, cppcheck, coverage sudo: required dist: trusty language: cpp @@ -37,6 +37,10 @@ jobs: -v ./tests - cmake -Bbuild -H. -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + + - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + - cmake --build build/example --config $BUILD_TYPE + - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit -Dfunction-loader_DIR:PATH=$(pwd)/build @@ -49,7 +53,7 @@ jobs: - set +e - - stage: cpp-utils, tests -- osx, release with debug info, clang + - stage: function-loader, example, tests -- osx, release with debug info, valgrind, clang os: osx language: cpp env: BUILD_TYPE="RelWithDebInfo" @@ -60,6 +64,11 @@ jobs: - set -e - cmake -Bbuild -H. -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + + - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + - cmake --build build/example --config $BUILD_TYPE + - valgrind --version + - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit -Dfunction-loader_DIR:PATH=$(pwd)/build diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 21742cb..4368bce 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -2,19 +2,24 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR) project(example LANGUAGES CXX) -_print_status_message("building with example") -_print_project_version() +message(STATUS "Building example") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../submodules/cmake-helpers/cmake-helpers/cpp_warnings.cmake) add_executable(${PROJECT_NAME} "") target_sources(${PROJECT_NAME} - PUBLIC - src/main.cpp) - -find_package(function-loader REQUIRED CONFIG PATHS ${CMAKE_BINARY_DIR} NO_DEFAULT_PATH) -target_include_directories(${PROJECT_NAME} PUBLIC ${function-loader_INCLUDE_DIRS}) -target_link_libraries(${PROJECT_NAME} PUBLIC ${function-loader_LIBRARIES}) + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp) -_add_pedantic_warning_level(${PROJECT_NAME}) +find_package(function-loader CONFIG REQUIRED) +message(STATUS "Found version of function-loader is: ${function-loader_VERSION}") +target_link_libraries(${PROJECT_NAME} PRIVATE burda::function-loader) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library ${CMAKE_CURRENT_BINARY_DIR}/demo-library) add_dependencies(${PROJECT_NAME} demo-library) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library/post_build_steps.cmake) +_burda_function_loader_demo_library_add_post_build_steps(${PROJECT_NAME}) + +burda_cmake_helpers_cpp_warnings_add_pedantic_level(${PROJECT_NAME}) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index afdcd94..1a22d8d 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -41,6 +41,7 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library ${CMAKE_CURRENT_ add_dependencies(${PROJECT_NAME} demo-library) include(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library/post_build_steps.cmake) +_burda_function_loader_demo_library_add_post_build_steps(${PROJECT_NAME}) # TODO: create invalid (empty) file that will be used in the tests to verify, whether the implementation correctly refuses to load this file #file(WRITE) From a0995f309da0d090eae129e70cd8fd1f45f33439 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 17 Nov 2018 19:16:19 +0100 Subject: [PATCH 23/45] Fixed example generation step --- example/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 4368bce..5d164eb 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -4,7 +4,7 @@ project(example LANGUAGES CXX) message(STATUS "Building example") -include(${CMAKE_CURRENT_SOURCE_DIR}/../../submodules/cmake-helpers/cmake-helpers/cpp_warnings.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../submodules/cmake-helpers/cmake-helpers/cpp_warnings.cmake) add_executable(${PROJECT_NAME} "") From 918a2fbc32992ec3156534d077aac4285666dd3c Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 17 Nov 2018 19:23:11 +0100 Subject: [PATCH 24/45] Fixed example includes --- example/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 5d164eb..053dd3c 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -16,10 +16,10 @@ find_package(function-loader CONFIG REQUIRED) message(STATUS "Found version of function-loader is: ${function-loader_VERSION}") target_link_libraries(${PROJECT_NAME} PRIVATE burda::function-loader) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library ${CMAKE_CURRENT_BINARY_DIR}/demo-library) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../demo-library ${CMAKE_CURRENT_BINARY_DIR}/demo-library) add_dependencies(${PROJECT_NAME} demo-library) -include(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library/post_build_steps.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../demo-library/post_build_steps.cmake) _burda_function_loader_demo_library_add_post_build_steps(${PROJECT_NAME}) burda_cmake_helpers_cpp_warnings_add_pedantic_level(${PROJECT_NAME}) From b1d9e12b1b888d7c590a0648206f155335ee9c94 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 17 Nov 2018 19:28:15 +0100 Subject: [PATCH 25/45] FIxed macro invocation --- example/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 053dd3c..600fda0 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -22,4 +22,4 @@ add_dependencies(${PROJECT_NAME} demo-library) include(${CMAKE_CURRENT_SOURCE_DIR}/../demo-library/post_build_steps.cmake) _burda_function_loader_demo_library_add_post_build_steps(${PROJECT_NAME}) -burda_cmake_helpers_cpp_warnings_add_pedantic_level(${PROJECT_NAME}) +burda_cmake_helpers_cpp_warnings_add_pedantic_level(${PROJECT_NAME} PRIVATE) From e1fae94e828ef91444a23845bfdb90f3ebbf689e Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 17 Nov 2018 19:39:26 +0100 Subject: [PATCH 26/45] Valgrind on the CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 842ade1..38b8a1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,7 +67,7 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - - valgrind --version + - valgrind --leak-check=full --error-exitcode=255 -v ./build/example - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit From a8fa1363d490df4211b4d2cdc47dc9a6cee32422 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 17 Nov 2018 19:51:46 +0100 Subject: [PATCH 27/45] Fixed paths --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38b8a1e..1355933 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,7 @@ jobs: env: BUILD_TYPE="RelWithDebInfo" compiler: clang before_install: - - brew install valgrind + - HOMEBREW_NO_AUTO_UPDATE=1 brew install valgrind script: - set -e @@ -67,7 +67,7 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - - valgrind --leak-check=full --error-exitcode=255 -v ./build/example + - valgrind --leak-check=full --error-exitcode=255 -v ./build/example/example - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit From e85837c85e6033c49a444f86c0fbb87598b11671 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sat, 17 Nov 2018 20:04:04 +0100 Subject: [PATCH 28/45] Updating homebrew --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1355933..510f4a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,7 @@ jobs: env: BUILD_TYPE="RelWithDebInfo" compiler: clang before_install: - - HOMEBREW_NO_AUTO_UPDATE=1 brew install valgrind + - brew install valgrind script: - set -e From 78351b4a6244bc030d7fc46f958d03abd457f71f Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sun, 18 Nov 2018 07:12:24 +0100 Subject: [PATCH 29/45] Fixed valgrind run --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 510f4a1..a9103e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,7 +67,9 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - - valgrind --leak-check=full --error-exitcode=255 -v ./build/example/example + - pushd build/example + - valgrind --leak-check=full --error-exitcode=255 -v ./example + - popd - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit From fc2cd800c252046e11002b5125af301cfb189cd5 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sun, 18 Nov 2018 07:41:19 +0100 Subject: [PATCH 30/45] Fixed pushd --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a9103e2..0944669 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,7 +67,7 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - - pushd build/example + - pushd ./build/example - valgrind --leak-check=full --error-exitcode=255 -v ./example - popd From 08b314e4738fa648c0e36dbca1c4f493d5840e30 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sun, 18 Nov 2018 07:52:27 +0100 Subject: [PATCH 31/45] Removed pushd on OS X --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0944669..2926000 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,9 +67,10 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - - pushd ./build/example + # pushd fails for some strange reason on the OS X images on Traviscd + - cd build/example - valgrind --leak-check=full --error-exitcode=255 -v ./example - - popd + - cd ../.. - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit From 03958d4980cb7a959336a7804e1f34733c024400 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sun, 18 Nov 2018 07:52:54 +0100 Subject: [PATCH 32/45] Updated README --- README.md | 76 +++++++++++++++++++++++-------------------------------- 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 78f4824..0dfe7d0 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ ![Version](https://img.shields.io/badge/version-1.2.1-green.svg) [![License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat)](LICENSE) -[![Build Status](https://travis-ci.org/karel-burda/function-loader.svg?branch=master)](https://travis-ci.org/karel-burda/function-loader) -[![Coverage Status](https://coveralls.io/repos/github/karel-burda/function-loader/badge.svg?branch=master)](https://coveralls.io/github/karel-burda/function-loader?branch=master) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fd08a5e184a945208324fd7a415428ad)](https://app.codacy.com/app/karel-burda/function-loader?utm_source=github.com&utm_medium=referral&utm_content=karel-burda/function-loader&utm_campaign=Badge_Grade_Dashboard) +[![Build Status](https://travis-ci.org/karel-burda/function-loader.svg?branch=develop)](https://travis-ci.org/karel-burda/function-loader) +[![Codecov Status](https://codecov.io/gh/karel-burda/function-loader/branch/develop/graph/badge.svg)](https://codecov.io/gh/karel-burda/cmake-helpers/branch/develop) # Important -This project contains git sub-modules that are needed for building example and tests. +This project contains git sub-modules that are needed for building tests. -If you just want to use the implementation, you can clone **without** sub-modules. In case you want to build example, tests, or use CMake, please, be sure to clone the repository +If you just want to use the implementation, you can clone without sub-modules. In case you want to build the tests, be sure to clone the repository with `--recurse-submodules` or `--recursive` on older versions of git. Alternatively, you can clone without sub-modules and initialize these later. # Introduction @@ -43,44 +42,44 @@ Call `add_subdirectory(...)` directly in your CMakeLists.txt: ```cmake add_executable("my-project" main.cpp) -add_subdirectory() -# Example: add_subdirectory(test-utils ${CMAKE_BINARY_DIR}/test-utils) +add_subdirectory() +# Example: add_subdirectory(function-loader ${CMAKE_BINARY_DIR}/function-loader) # Query of package version -message(STATUS "Current version of test-utils is: ${test-utils_VERSION}") +message(STATUS "Current version of function-loader is: ${function-loader_VERSION}") -add_library(burda::test-utils ALIAS test-utils) +add_library(burda::function-loader ALIAS function-loader) -# This will import search paths, compile definitions and other dependencies of the test-utils as well -target_link_libraries("my-project" test-utils) -# Or with private visibility: target_link_libraries("my-project" PRIVATE test-utils) +# This will import search paths, compile definitions and other dependencies of the function-loader as well +target_link_libraries("my-project" function-loader) +# Or with private visibility: target_link_libraries("my-project" PRIVATE function-loader) ``` ### B) Generate separately -Generation phase on the test-utils is run separately, that means that you run: +Generation phase on the function-loader is run separately, that means that you run: ```cmake -cmake -# Example: cmake -Bbuild/test-utils -Htest-utils in the root of your project +cmake +# Example: cmake -Bbuild/function-loader -Hfunction-loader in the root of your project ``` -This will create automatically generated package configuration file `test-utils-config.cmake` that contains exported target and all important information. +This will create automatically generated package configuration file `function-loader-config.cmake` that contains exported target and all important information. Then you can do this in your CMakeLists.txt: ```cmake add_executable("my-project" main.cpp) -find_package(test-utils CONFIG PATHS ) -# Alternatively assuming that the "test-utils_DIR" variable is set: find_package(test-utils CONFIG) +find_package(function-loader CONFIG PATHS ) +# Alternatively assuming that the "function-loader_DIR" variable is set: find_package(function-loader CONFIG) # You can also query (or force specific version during the previous "find_package()" call) -message(STATUS "Found version of test-utils is: ${test-utils_VERSION}") +message(STATUS "Found version of function-loader is: ${function-loader_VERSION}") -# This will import search paths, compile definitions and other dependencies of the test-utils as well -target_link_libraries("my-project" burda::test-utils) -# Or with public visibility: target_link_libraries("my-project" PUBLIC burda::test-utils) +# This will import search paths, compile definitions and other dependencies of the function-loader as well +target_link_libraries("my-project" burda::function-loader) +# Or with public visibility: target_link_libraries("my-project" PUBLIC burda::function-loader) ``` @@ -91,7 +90,9 @@ Make sure that the `include` directory is in the search paths. You also have to set C++11 standard and potentially other settings as well (e.g. linking `libdl` on POSIXes). -### Example +# Example +For full use cases, see [main.cpp](example/src/main.cpp) or implementation of unit tests at [tests/unit](tests/unit). + ```cpp #include @@ -153,21 +154,6 @@ LIBRARY_EXPORT int bar(float number, const char * str); } ``` -For full use cases, see [main.cpp](example/src/main.cpp) or implementation of unit tests at [tests/unit](tests/unit). - -# Build Process -Library itself is just header-only, so no need for additional linking, just `libdl` needs to be linked to the final executable on POSIXes. See section [Usage](#Usage) for more info. - -In order to build the usage example ([main.cpp](example/src/main.cpp)) run the cmake in the top-level directory like this: - -`cmake .` - -I personally prefer to specify a separate build directory explicitly: - -`cmake -Bbuild -H.` - -You can of course specify ordinary cmake options like build type (debug, release with debug info, ...), used generator, etc. - # Unit Tests Tests require sub-module [cmake-helpers](https://github.com/karel-burda/cmake-helpers) and [test-utils](https://github.com/karel-burda/test-utils). @@ -175,12 +161,12 @@ For building tests, run CMake in the source directory [tests/unit](tests/unit): ```cmake cmake -Bbuild -H. +cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils # You can also add coverage by appending "-DCOVERAGE:BOOL=ON" -cmake -Bbuild/tests/unit -Htests/unit -Dcpp-utils_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -cmake --build build/tests/unit --config RelWithDebInfo +cmake -Bbuild/tests/unit -Htests/unit -Dtest-utils_DIR:PATH=$(pwd)/build/submodules/test-utils +cmake --build build/tests/unit # This runs target "run-all-tests-verbose" that will also run the tests with timeout, etc.: cmake --build build/tests/unit --target run-all-tests-verbose --config RelWithDebInfo -# Or you can execute tests manually ``` For more info, see [.travis.yml](.travis.yml). @@ -191,8 +177,10 @@ Continuous Integration is now being run Linux (with GCC 6.x) and OS X on Travis: Compilers are set-up to treat warnings as errors and with pedantic warning level. Targets are built debug symbols with code coverage measure and release with debug symbols). +Valgrind is being run on the example as well. + The project is using thse stages: -* `cpp-utils, tests -- linux, debug, gcc, cppcheck, coverage` -* `cpp-utils, tests -- osx, release with debug info, clang` +* `function-loader, example, tests -- linux, debug, gcc, cppcheck, coverage` +* `function-loader, example, tests -- osx, release with debug info, valgrind, clang` -Project uses [codecov.io](https://codecov.io/gh/karel-burda/cpp-utils) for code coverage summary. +Project uses [codecov.io](https://codecov.io/gh/karel-burda/function-loader) for code coverage summary. From d2d725e12ff4f9973ad73f1a76c2436f8e57f977 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sun, 18 Nov 2018 19:07:57 +0100 Subject: [PATCH 33/45] Fixing pushd/popd on OS X images --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2926000..7e0543e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,10 +67,11 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - # pushd fails for some strange reason on the OS X images on Traviscd - - cd build/example + # pushd fails for some strange reason on the OS X images on Travis + - unset -f pushd && unsef -f popd + - pushd build/example - valgrind --leak-check=full --error-exitcode=255 -v ./example - - cd ../.. + - popd - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit From 81ef8a53e2ae31a0c1e3dcb31d9197285f2032a3 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sun, 18 Nov 2018 19:18:57 +0100 Subject: [PATCH 34/45] Fixed typos --- .travis.yml | 4 ++-- README.md | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e0543e..e7881e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,8 +67,8 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - # pushd fails for some strange reason on the OS X images on Travis - - unset -f pushd && unsef -f popd + # RVM overrides these shell built-ins for Ruby, but we need to use these + - unset -f pushd && unset -f popd - pushd build/example - valgrind --leak-check=full --error-exitcode=255 -v ./example - popd diff --git a/README.md b/README.md index 0dfe7d0..e9cec15 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ If you just want to use the implementation, you can clone without sub-modules. I with `--recurse-submodules` or `--recursive` on older versions of git. Alternatively, you can clone without sub-modules and initialize these later. # Introduction -`function_loader` is a header-only library that can find free functions in a shared library and provide and `std::function` wrapper around the found function. +`function_loader` is a header-only library that can find free functions in a shared library and provides `std::function` wrapper around the found function. -Essentially provides wrapper around the calls `LoadLibrary`, `GetProcedure` and `FreeLibrary` system calls on Windows and `dlopen`, `dlsym` and `dlclose` on POSIXes. +Essentially represents a wrapper around the calls `LoadLibrary`, `GetProcedure` and `FreeLibrary` system calls on Windows and `dlopen`, `dlsym` and `dlclose` on POSIXes. `function_loader` class supports move semantics and disables copy operations; implementation is in C++11. @@ -155,7 +155,7 @@ LIBRARY_EXPORT int bar(float number, const char * str); ``` # Unit Tests -Tests require sub-module [cmake-helpers](https://github.com/karel-burda/cmake-helpers) and [test-utils](https://github.com/karel-burda/test-utils). +Tests require sub-modules [cmake-helpers](https://github.com/karel-burda/cmake-helpers) and [test-utils](https://github.com/karel-burda/test-utils). For building tests, run CMake in the source directory [tests/unit](tests/unit): @@ -163,23 +163,27 @@ For building tests, run CMake in the source directory [tests/unit](tests/unit): cmake -Bbuild -H. cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils # You can also add coverage by appending "-DCOVERAGE:BOOL=ON" -cmake -Bbuild/tests/unit -Htests/unit -Dtest-utils_DIR:PATH=$(pwd)/build/submodules/test-utils +cmake -Bbuild/tests/unit -Htests/unit + -Dfunction-loader_DIR:PATH=$(pwd)/build + -Dtest-utils_DIR:PATH=$(pwd)/build/submodules/test-utils cmake --build build/tests/unit # This runs target "run-all-tests-verbose" that will also run the tests with timeout, etc.: -cmake --build build/tests/unit --target run-all-tests-verbose --config RelWithDebInfo +cmake --build build/tests/unit --target run-all-tests-verbose ``` +This is the example of running tests in the debug mode. + For more info, see [.travis.yml](.travis.yml). # Continuous Integration Continuous Integration is now being run Linux (with GCC 6.x) and OS X on Travis: https://travis-ci.org/karel-burda/cpp-utils. Compilers are set-up to treat warnings as errors and with pedantic warning level. -Targets are built debug symbols with code coverage measure and release with debug symbols). +Targets are built in one stage with debug symbols with code coverage measure and in release mode with debug symbols in the second one. Valgrind is being run on the example as well. -The project is using thse stages: +The project is using these stages: * `function-loader, example, tests -- linux, debug, gcc, cppcheck, coverage` * `function-loader, example, tests -- osx, release with debug info, valgrind, clang` From cbbd70cae052046dfa78d3877c9dbcbf186d15fa Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sun, 18 Nov 2018 19:40:41 +0100 Subject: [PATCH 35/45] Updated valgrind args --- .travis.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e7881e0..d787acc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,7 +70,7 @@ jobs: # RVM overrides these shell built-ins for Ruby, but we need to use these - unset -f pushd && unset -f popd - pushd build/example - - valgrind --leak-check=full --error-exitcode=255 -v ./example + - valgrind --error-exitcode=255 -v ./example - popd - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE diff --git a/README.md b/README.md index e9cec15..38f03e3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![Version](https://img.shields.io/badge/version-1.2.1-green.svg) [![License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat)](LICENSE) [![Build Status](https://travis-ci.org/karel-burda/function-loader.svg?branch=develop)](https://travis-ci.org/karel-burda/function-loader) -[![Codecov Status](https://codecov.io/gh/karel-burda/function-loader/branch/develop/graph/badge.svg)](https://codecov.io/gh/karel-burda/cmake-helpers/branch/develop) +[![Codecov Status](https://codecov.io/gh/karel-burda/function-loader/branch/develop/graph/badge.svg)](https://codecov.io/gh/karel-burda/function-loader/branch/develop) # Important This project contains git sub-modules that are needed for building tests. From f477289372863adea78f2da25d82155182c3913a Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sun, 18 Nov 2018 20:02:15 +0100 Subject: [PATCH 36/45] Removed useless file --- function-loader-config.cmake.in | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 function-loader-config.cmake.in diff --git a/function-loader-config.cmake.in b/function-loader-config.cmake.in deleted file mode 100644 index aef586c..0000000 --- a/function-loader-config.cmake.in +++ /dev/null @@ -1,4 +0,0 @@ -set(@PROJECT_NAME@_INCLUDE_DIRS "@CMAKE_CURRENT_SOURCE_DIR@/include") -if (UNIX) - set(@PROJECT_NAME@_LIBRARIES "dl") -endif() From c30397abcd11bc479edf21fb5482afb7deebc3cd Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Sun, 18 Nov 2018 20:02:31 +0100 Subject: [PATCH 37/45] Testing loading of empty library file --- tests/unit/CMakeLists.txt | 4 ++-- tests/unit/src/library_loader_test.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 1a22d8d..b9fa3e8 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -43,8 +43,8 @@ add_dependencies(${PROJECT_NAME} demo-library) include(${CMAKE_CURRENT_SOURCE_DIR}/../../demo-library/post_build_steps.cmake) _burda_function_loader_demo_library_add_post_build_steps(${PROJECT_NAME}) -# TODO: create invalid (empty) file that will be used in the tests to verify, whether the implementation correctly refuses to load this file -#file(WRITE) +# Create invalid (empty) file that will be used in the tests to verify, whether the implementation correctly refuses to load this file +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/empty.dll "") enable_testing() diff --git a/tests/unit/src/library_loader_test.cpp b/tests/unit/src/library_loader_test.cpp index dd57e73..dc257d1 100644 --- a/tests/unit/src/library_loader_test.cpp +++ b/tests/unit/src/library_loader_test.cpp @@ -96,6 +96,11 @@ TEST(library_loader, exceptions) } } +TEST(library_loader, empty_library) +{ + EXPECT_THROW(library_loader{ "./empty.dll" }, exceptions::library_load_failed); +} + TEST(library_loader, get_last_error) { library_loader loader{ testing::get_demo_library_file_path() }; From eb279bbada51ff683a6e93ddd71b52f19c37706b Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Mon, 19 Nov 2018 18:43:46 +0100 Subject: [PATCH 38/45] Added Windows CI --- .travis.yml | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d787acc..4172569 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,20 @@ stages: - - function-loader, example, tests -- linux, debug, gcc, cppcheck, coverage - - function-loader, example, tests -- osx, release with debug info, valgrind, clang + - function-loader, example, tests -- linux, debug, cppcheck, coverage, g++, 64-bit + - function-loader, example, tests -- osx, release with debug info, valgrind, clang++, 64-bit + - function-loader, example, tests -- windows, release, msvc, 32-bit git: depth: 1 jobs: include: - - stage: function-loader, example, tests -- linux, debug, gcc, cppcheck, coverage - sudo: required - dist: trusty + - stage: function-loader, example, tests -- linux, debug, cppcheck, coverage, g++, 64-bit + os: linux + dist: xenial language: cpp env: BUILD_TYPE="Debug" compiler: g++ - os: linux + sudo: required addons: apt: sources: @@ -40,6 +41,7 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE + - ./build/example/example - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit @@ -55,6 +57,7 @@ jobs: - stage: function-loader, example, tests -- osx, release with debug info, valgrind, clang os: osx + osx_image: xcode10.1 language: cpp env: BUILD_TYPE="RelWithDebInfo" compiler: clang @@ -82,3 +85,26 @@ jobs: - cmake --build build/tests/unit --target run-all-tests-verbose --config $BUILD_TYPE - set +e + + - stage: function-loader, example, tests -- windows, release, msvc, 32-bit + os: windows + language: cpp + env: BUILD_TYPE="Release" + compiler: clang + script: + - set -e + + - cmake -Bbuild -H. -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + + - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + - cmake --build build/example --config $BUILD_TYPE + - build/example/$BUILD_TYPE/example + + - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + - cmake -Bbuild/tests/unit -Htests/unit + -Dfunction-loader_DIR:PATH=$(pwd)/build + -Dtest-utils_DIR:PATH=$(pwd)/build/submodules/test-utils + -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE + - cmake --build build/tests/unit --target run-all-tests-verbose --config $BUILD_TYPE + + - set +e From f9ce215796573b67d98e1df3a87d313426f38643 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Mon, 19 Nov 2018 19:06:12 +0100 Subject: [PATCH 39/45] Fixed CI --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4172569..bf209a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,9 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE + - pushd build/example - ./build/example/example + - popd - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit @@ -98,7 +100,9 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - - build/example/$BUILD_TYPE/example + - pushd build/example/$BUILD_TYPE + - example + - popd - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake -Bbuild/tests/unit -Htests/unit From 7d56bf75a7b0b449ba15037f8724876f759b1731 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Mon, 19 Nov 2018 19:18:46 +0100 Subject: [PATCH 40/45] Fixed Windows CI --- .travis.yml | 2 +- README.md | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf209a8..94c6052 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,7 +42,7 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - pushd build/example - - ./build/example/example + - ./example - popd - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE diff --git a/README.md b/README.md index 38f03e3..b290421 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ This is the example of running tests in the debug mode. For more info, see [.travis.yml](.travis.yml). # Continuous Integration -Continuous Integration is now being run Linux (with GCC 6.x) and OS X on Travis: https://travis-ci.org/karel-burda/cpp-utils. +Continuous Integration is now being run Linux, OS X and Windows on Travis: https://travis-ci.org/karel-burda/cpp-utils. Compilers are set-up to treat warnings as errors and with pedantic warning level. Targets are built in one stage with debug symbols with code coverage measure and in release mode with debug symbols in the second one. @@ -184,7 +184,8 @@ Targets are built in one stage with debug symbols with code coverage measure and Valgrind is being run on the example as well. The project is using these stages: -* `function-loader, example, tests -- linux, debug, gcc, cppcheck, coverage` -* `function-loader, example, tests -- osx, release with debug info, valgrind, clang` +* `function-loader, example, tests -- linux, debug, cppcheck, coverage, g++, 64-bit` +* `function-loader, example, tests -- osx, release with debug info, valgrind, clang++, 64-bit` +* `function-loader, example, tests -- windows, release, msvc, 32-bit` Project uses [codecov.io](https://codecov.io/gh/karel-burda/function-loader) for code coverage summary. From de9193c118c55317cb259a6c29c3f7534cafd8b5 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Mon, 19 Nov 2018 19:27:04 +0100 Subject: [PATCH 41/45] FIxed exec --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 94c6052..7d77896 100644 --- a/.travis.yml +++ b/.travis.yml @@ -101,7 +101,8 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - pushd build/example/$BUILD_TYPE - - example + - dir + - example.exe - popd - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE From 7b8a13a0d5f13ce282961df012f5ca6d4984f2a2 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Mon, 19 Nov 2018 19:34:14 +0100 Subject: [PATCH 42/45] Running example.exe --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d77896..c6c4308 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,7 +92,6 @@ jobs: os: windows language: cpp env: BUILD_TYPE="Release" - compiler: clang script: - set -e @@ -101,8 +100,7 @@ jobs: - cmake -Bbuild/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE - cmake --build build/example --config $BUILD_TYPE - pushd build/example/$BUILD_TYPE - - dir - - example.exe + - start example.exe - popd - cmake -Bbuild/submodules/test-utils -Hsubmodules/test-utils -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE From cc637648a18c349ae1dece65900680071793d272 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Mon, 19 Nov 2018 19:46:36 +0100 Subject: [PATCH 43/45] Debugging --- .travis.yml | 2 +- tests/unit/src/library_loader_test.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c6c4308..3c54361 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,7 +57,7 @@ jobs: - set +e - - stage: function-loader, example, tests -- osx, release with debug info, valgrind, clang + - stage: function-loader, example, tests -- osx, release with debug info, valgrind, clang++, 64-bit os: osx osx_image: xcode10.1 language: cpp diff --git a/tests/unit/src/library_loader_test.cpp b/tests/unit/src/library_loader_test.cpp index dc257d1..ba5d794 100644 --- a/tests/unit/src/library_loader_test.cpp +++ b/tests/unit/src/library_loader_test.cpp @@ -105,5 +105,7 @@ TEST(library_loader, get_last_error) { library_loader loader{ testing::get_demo_library_file_path() }; EXPECT_TRUE(loader.get_last_error().empty()); + // debug only + std::cout << loader.get_last_error() << std::endl; } } From f4944ebe6f060c41eede540168f0ee8f39d75df2 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Mon, 19 Nov 2018 19:53:02 +0100 Subject: [PATCH 44/45] Fixed test --- tests/unit/src/library_loader_test.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/unit/src/library_loader_test.cpp b/tests/unit/src/library_loader_test.cpp index ba5d794..0cb647b 100644 --- a/tests/unit/src/library_loader_test.cpp +++ b/tests/unit/src/library_loader_test.cpp @@ -103,9 +103,7 @@ TEST(library_loader, empty_library) TEST(library_loader, get_last_error) { - library_loader loader{ testing::get_demo_library_file_path() }; - EXPECT_TRUE(loader.get_last_error().empty()); - // debug only - std::cout << loader.get_last_error() << std::endl; + library_loader loader{ "./foo" }; + EXPECT_FALSE(loader.get_last_error().empty()); } } From 5ee2e16e235ec6ac86796f7d88b6bda6c5e67646 Mon Sep 17 00:00:00 2001 From: Karel Burda Date: Mon, 19 Nov 2018 20:04:27 +0100 Subject: [PATCH 45/45] Removed incorrect test --- tests/unit/src/library_loader_test.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/unit/src/library_loader_test.cpp b/tests/unit/src/library_loader_test.cpp index 0cb647b..3469bfa 100644 --- a/tests/unit/src/library_loader_test.cpp +++ b/tests/unit/src/library_loader_test.cpp @@ -100,10 +100,4 @@ TEST(library_loader, empty_library) { EXPECT_THROW(library_loader{ "./empty.dll" }, exceptions::library_load_failed); } - -TEST(library_loader, get_last_error) -{ - library_loader loader{ "./foo" }; - EXPECT_FALSE(loader.get_last_error().empty()); -} }