wrmath/CMakeLists.txt

82 lines
2.2 KiB
CMake
Raw Normal View History

2019-08-05 05:22:27 +00:00
cmake_minimum_required(VERSION 3.15)
2019-08-03 02:03:44 +00:00
cmake_policy(SET CMP0048 NEW)
## CONFIG
project(wrmath VERSION 0.0.1 LANGUAGES CXX)
2019-08-03 02:03:44 +00:00
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-Werror -Wall -g -O0)
if(DEFINED ENV{CMAKE_GCOV})
add_compile_options(-fprofile-arcs -ftest-coverage)
# Need CMake 3.15+.
add_link_options(-fprofile-arcs -ftest-coverage)
2019-08-05 05:44:06 +00:00
add_custom_target(coverage COMMAND lcov -d . -t wrmath -o wrmath.info -c -i
COMMAND lcov -d . -t wrmath -o wrmath.info -c
2019-08-05 05:21:50 +00:00
COMMAND genhtml -o coverage-report wrmath.info)
2019-08-03 02:03:44 +00:00
endif()
include_directories(include)
file(GLOB_RECURSE ${PROJECT_NAME}_HEADERS include/**.h)
file(GLOB_RECURSE ${PROJECT_NAME}_SOURCES src/*.cc)
2019-08-03 02:03:44 +00:00
## BUILD
add_library(lib${PROJECT_NAME} ${${PROJECT_NAME}_SOURCES})
2019-08-03 02:03:44 +00:00
## INSTALL
install(DIRECTORY include/${PROJECT_NAME}
DESTINATION include/
FILES_MATCHING PATTERN "*.h")
## TEST
# From Modern CMake:
# https://cliutils.gitlab.io/modern-cmake/chapters/testing/googletest.html
add_subdirectory("${PROJECT_SOURCE_DIR}/extern/googletest" "extern/googletest")
include_directories("${gtest_SOURCE_DIR}/include")
mark_as_advanced(
BUILD_GMOCK BUILD_GTEST BUILD_SHARED_LIBS
gmock_build_tests gtest_build_samples gtest_build_tests
gtest_disable_pthreads gtest_force_shared_crt gtest_hide_internal_symbols
)
set_target_properties(gtest PROPERTIES FOLDER extern)
set_target_properties(gtest_main PROPERTIES FOLDER extern)
set_target_properties(gmock PROPERTIES FOLDER extern)
set_target_properties(gmock_main PROPERTIES FOLDER extern)
2019-08-03 02:03:44 +00:00
include(CTest)
set(TEST_EXECS)
macro(package_add_gtest TESTNAME)
add_executable(${TESTNAME} ${ARGN})
target_link_libraries(${TESTNAME} gtest_main lib${PROJECT_NAME})
2019-08-03 02:03:44 +00:00
target_compile_options(${TESTNAME} PUBLIC ${GTEST_CFLAGS})
add_test(NAME ${TESTNAME} COMMAND ${TESTNAME})
set_target_properties(${TESTNAME} PROPERTIES
FOLDER tests
RUNTIME_OUTPUT_DIRECTORY tests)
list(APPEND TEST_EXECS ${TESTNAME})
endmacro()
# define the tests
2019-08-03 02:03:44 +00:00
package_add_gtest(vector_test test/vector_test.cc)
package_add_gtest(orientation_test test/orientation_test.cc)
2019-08-03 02:03:44 +00:00
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose DEPENDS ${TEST_EXECS})
## DEPLOY
include(CMakePack.txt)
## DOCUMENTATE
add_subdirectory ("docs")