library/CMakeLists.txt

41 lines
1.2 KiB
CMake

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")
project(library)
set(CMAKE_CXX_STANDARD 14)
# enable clang_tidy
set(CMAKE_CXX_CLANG_TIDY clang-tidy;)
file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS src/*.hpp)
file(GLOB_RECURSE TESTS test/*.cpp)
include_directories(src)
include_directories(test)
add_library(library ${SOURCES} ${HEADERS})
file(COPY "${CMAKE_SOURCE_DIR}/src/"
DESTINATION "${CMAKE_SOURCE_DIR}/include"
FILES_MATCHING
PATTERN *.hpp
)
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)
catch_discover_tests(UnitTests)