library/CMakeLists.txt

52 lines
1.5 KiB
CMake
Raw Normal View History

2019-10-21 17:19:26 +02:00
cmake_minimum_required(VERSION 3.7.2)
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "In-source builds are disabled.
Please create a subfolder called build and use `cmake ..` inside it.
NOTE: cmake will now create CMakeCache.txt and CMakeFiles/*.
You must delete them, or cmake will refuse to work.")
endif()
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "bin" "doc" "CMakeFiles" "lib" "include")
2019-10-15 13:57:41 +02:00
project(library)
set(CMAKE_CXX_STANDARD 14)
2019-10-21 17:19:26 +02:00
# enable clang_tidy
2019-11-21 11:35:54 +01:00
set(CMAKE_CXX_CLANG_TIDY clang-tidy;)
2019-10-21 17:19:26 +02:00
2019-10-15 13:57:41 +02:00
file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS src/*.hpp)
file(GLOB_RECURSE TESTS test/*.cpp)
2019-10-15 13:57:41 +02:00
include_directories(src)
include_directories(test)
2019-11-21 11:35:54 +01:00
add_library(library ${SOURCES} ${HEADERS})
2019-10-15 13:57:41 +02:00
2019-11-27 13:39:16 +01:00
2019-10-15 13:57:41 +02:00
file(COPY "${CMAKE_SOURCE_DIR}/src/"
DESTINATION "${CMAKE_SOURCE_DIR}/include"
2019-10-15 13:57:41 +02:00
FILES_MATCHING
2019-11-13 13:44:23 +01:00
PATTERN *.hpp
2019-10-15 13:57:41 +02:00
)
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
enable_testing()
find_package(Catch2 REQUIRED)
add_executable(UnitTests test/test_main.cpp ${SOURCES} ${HEADERS} ${TESTS})
target_link_libraries(UnitTests Catch2::Catch2)
include(CTest)
include(Catch)
2019-12-08 19:06:16 +01:00
catch_discover_tests(UnitTests)
if (ENABLE_COVERAGE)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../external/codecov/cmake" ${CMAKE_MODULE_PATH})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
find_package(codecov)
add_coverage(UnitTests)
list(APPEND LCOV_REMOVE_PATTERNS "/usr/")
coverage_evaluate()
endif()