mirror of https://github.com/SeanOMik/libki.git
cmake: Add CMakeLists.txt
Includes unit tests (using Catch2) and examples
This commit is contained in:
parent
ce75b39c4b
commit
ddbeb492b6
|
@ -1,3 +1,6 @@
|
|||
# Visual Studio/Code
|
||||
.vs/
|
||||
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
|
|
|
@ -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()
|
|
@ -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()
|
|
@ -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()
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue