Merge branch 'master' of github.com:TartanLlama/expected

This commit is contained in:
Simon Brand
2018-06-08 12:35:51 +01:00

View File

@@ -2,11 +2,19 @@ cmake_minimum_required(VERSION 3.0)
project(expected) project(expected)
option(EXPECTED_ENABLE_TESTS "Enable tests." ON)
option(EXPECTED_ENABLE_DOCS "Enable documentation." ON)
add_library(expected INTERFACE)
target_sources(expected INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tl/expected.hpp)
target_include_directories(expected INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tl)
# Prepare "Catch" library for other executables # Prepare "Catch" library for other executables
set(CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/test) set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
add_library(Catch INTERFACE) add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
if(EXPECTED_ENABLE_TESTS)
# Make test executable # Make test executable
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tests/extensions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/extensions.cpp
@@ -19,23 +27,21 @@ set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp
add_executable(tests ${TEST_SOURCES}) add_executable(tests ${TEST_SOURCES})
add_library(expected INTERFACE)
target_sources(expected INTERFACE ${CMAKE_SOURCE_DIR}/tl/expected.hpp)
target_include_directories(expected INTERFACE ${CMAKE_SOURCE_DIR}/tl)
target_link_libraries(tests Catch expected) target_link_libraries(tests Catch expected)
set(CXXSTD 14 CACHE STRING "C++ standard to use, default C++14") set(CXXSTD 14 CACHE STRING "C++ standard to use, default C++14")
set_property(TARGET tests PROPERTY CXX_STANDARD ${CXXSTD}) set_property(TARGET tests PROPERTY CXX_STANDARD ${CXXSTD})
set_property(TARGET tests PROPERTY CXX_FLAGS "-Wall -Wextra") set_property(TARGET tests PROPERTY CXX_FLAGS "-Wall -Wextra")
endif()
if(EXPECTED_ENABLE_DOCS)
find_package(standardese) # find standardese after installation find_package(standardese) # find standardese after installation
# generates a custom target that will run standardese to generate the documentation # generates a custom target that will run standardese to generate the documentation
if(standardese_FOUND) if(standardese_FOUND)
standardese_generate(expected standardese_generate(expected
INCLUDE_DIRECTORY tl INCLUDE_DIRECTORY tl
CONFIG ${CMAKE_SOURCE_DIR}/standardese.config CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/standardese.config
INPUT tl/expected.hpp) INPUT tl/expected.hpp)
endif() endif()
endif()