cmake: Add CMakeLists.txt

Includes unit tests (using Catch2) and examples
This commit is contained in:
Joshua Scott 2018-03-26 19:19:39 +01:00
parent ce75b39c4b
commit ddbeb492b6
5 changed files with 12898 additions and 0 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
# Visual Studio/Code
.vs/
# Prerequisites # Prerequisites
*.d *.d

24
CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
project(ki)
cmake_minimum_required(VERSION 3.1)
add_library(${PROJECT_NAME})
set_target_properties(${PROJECT_NAME}
PROPERTIES
LINKER_LANGUAGE CXX
CXX_STANDARD 11
)
target_include_directories(${PROJECT_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
option(KI_BUILD_EXAMPLES "Determines whether to build examples." ON)
if (KI_BUILD_EXAMPLES)
add_subdirectory("examples")
endif()
option(KI_BUILD_TESTS "Determines whether to build tests." ON)
if (KI_BUILD_TESTS)
enable_testing()
add_subdirectory("test")
endif()

6
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,6 @@
file(GLOB files "src/example-*.cpp")
foreach (file ${files})
get_filename_component(file_basename ${file} NAME_WE)
add_executable(${file_basename} ${file})
target_link_libraries(${file_basename} ${PROJECT_NAME})
endforeach()

13
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,13 @@
set(CATCH_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/third_party)
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
file(GLOB files "src/unit-*.cpp")
foreach (file ${files})
get_filename_component(file_basename ${file} NAME_WE)
string(REGEX REPLACE "unit-([^$]+)" "test-\\1" testcase ${file_basename})
add_executable(${testcase} ${file})
target_link_libraries(${testcase} Catch ${PROJECT_NAME})
add_test(${testcase} ${testcase})
endforeach()

12852
third_party/catch.hpp vendored Normal file

File diff suppressed because it is too large Load Diff