Skip to content

Commit

Permalink
Merge pull request #14 from karel-burda/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
karel-burda authored Nov 19, 2018
2 parents ecd9a22 + 5ee2e16 commit 6c61510
Show file tree
Hide file tree
Showing 18 changed files with 331 additions and 204 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "tests"
6 changes: 4 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[submodule "cmake-helpers"]
path = cmake-helpers
path = submodules/cmake-helpers
url = https://github.com/karel-burda/cmake-helpers
branch = master
shallow = true
[submodule "test-utils"]
path = test-utils
path = submodules/test-utils
url = https://github.com/karel-burda/test-utils
shallow = true
104 changes: 89 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,113 @@
stages:
- example and tests (C++14) -- cppcheck, build (linux, gcc5), valgrind, tests
- 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: example and tests (C++14) -- cppcheck, build (linux, gcc5), valgrind, tests
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:
- 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

- 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/example -Hexample -Dfunction-loader_DIR:PATH=$(pwd)/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE
- cmake --build build/example --config $BUILD_TYPE
- pushd build/example
- ./example
- popd

- 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

- bash <(curl -s https://codecov.io/bash)

- set +e

- stage: function-loader, example, tests -- osx, release with debug info, valgrind, clang++, 64-bit
os: osx
osx_image: xcode10.1
language: cpp
env: BUILD_TYPE="RelWithDebInfo"
compiler: clang
before_install:
- brew install valgrind
script:
- set -e

- cmake -Bbuild -H. -DEXAMPLE:BOOL=ON -DUNIT-TESTS:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCOVERAGE:BOOL=ON
- 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
# RVM overrides these shell built-ins for Ruby, but we need to use these
- unset -f pushd && unset -f popd
- pushd build/example
- valgrind --error-exitcode=255 -v ./example
- popd

- 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 -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

- stage: function-loader, example, tests -- windows, release, msvc, 32-bit
os: windows
language: cpp
env: BUILD_TYPE="Release"
script:
- set -e

- cmake --build build --target example --config RelWithDebInfo
- cmake -Bbuild -H. -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE

- pushd ./build/bin/
- valgrind --leak-check=full --error-exitcode=255 -v ./example
- 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
- start example.exe
- popd

- cmake --build build --target run-all-tests-verbose --config RelWithDebInfo
- 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/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
97 changes: 45 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,58 +1,51 @@
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

project(function-loader VERSION 1.2.0 LANGUAGES CXX)

include("cmake-helpers/cmake-helpers/messages.cmake")
include("cmake-helpers/cmake-helpers/standard-settings.cmake")
include("cmake-helpers/cmake-helpers/warnings.cmake")

option(EXAMPLE "Build example usage" ON)
option(UNIT-TESTS "Build unit tests" OFF)

_print_project_version()

_set_standards("11" "14")
_set_default_build_type("Debug")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

set(HEADERS
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
$<$<PLATFORM_ID:Windows>:include/function_loader/detail/function_loader_platform_specific_windows.hpp>
$<$<PLATFORM_ID:Unix>: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
$<$<PLATFORM_ID:Windows>:include/function_loader/detail/library_loader_platform_specific_windows.hpp>
$<$<PLATFORM_ID:Unix>:include/function_loader/detail/library_loader_platform_specific_unix.hpp>)

set(OTHER
README.md
.travis.yml
${PROJECT_NAME}-config.cmake.in)

add_custom_target(${PROJECT_NAME} SOURCES ${HEADERS} ${OTHER})
project(function-loader VERSION 1.2.1 LANGUAGES CXX)

add_library(${PROJECT_NAME} INTERFACE)

target_sources(${PROJECT_NAME}
INTERFACE
${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
$<$<PLATFORM_ID:Windows>:
${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/function_loader_platform_specific_windows.hpp>
$<$<PLATFORM_ID:Unix>:
${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
$<$<PLATFORM_ID:Windows>:
${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/library_loader_platform_specific_windows.hpp>
$<$<PLATFORM_ID:Unix>:
${CMAKE_CURRENT_SOURCE_DIR}/include/function_loader/detail/library_loader_platform_specific_unix.hpp>)

target_include_directories(${PROJECT_NAME}
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include)

if (CMAKE_DL_LIBS)
message(STATUS "Will add ${CMAKE_DL_LIBS}")
set_target_properties(${PROJECT_NAME}
PROPERTIES
INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}")
endif()

configure_file(${PROJECT_NAME}-config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" @ONLY)
target_compile_features(${PROJECT_NAME}
INTERFACE
cxx_std_11)

if (EXAMPLE OR UNIT-TESTS)
add_subdirectory(demo-library)
install(TARGETS ${PROJECT_NAME}
EXPORT _targets)

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)
export(EXPORT _targets
NAMESPACE burda::
FILE "${PROJECT_NAME}-config.cmake")

add_subdirectory(tests/unit)
endif()
endif()
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
COMPATIBILITY ExactVersion)
Loading

0 comments on commit 6c61510

Please sign in to comment.