Do CMake properly

This commit is contained in:
Simon Brand
2019-05-01 12:15:40 +01:00
parent 2c9780949d
commit 90ed23a4e4
19 changed files with 285 additions and 276 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "cmake/tl-cmake"]
path = cmake/tl-cmake
url = https://github.com/TartanLlama/tl-cmake.git

View File

@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.8)
project(expected) project(tl-expected VERSION 1.0.0 LANGUAGES CXX)
option(EXPECTED_ENABLE_TESTS "Enable tests." ON) option(EXPECTED_ENABLE_TESTS "Enable tests." ON)
add_library(expected INTERFACE) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/tl-cmake" ${CMAKE_MODULE_PATH})
target_sources(expected INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tl/expected.hpp) include(add-tl)
target_include_directories(expected INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tl)
tl_add_library(expected SOURCES
include/tl/expected.hpp)
# Prepare "Catch" library for other executables # Prepare "Catch" library for other executables
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test) set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)

1
cmake/tl-cmake Submodule

Submodule cmake/tl-cmake added at 284c6a3f0f

View File

@ -0,0 +1,3 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/tl-expected-targets.cmake")

View File

@ -12,8 +12,8 @@ class ExpectedConan(ConanFile):
exports_sources = "*" exports_sources = "*"
def source(self): def source(self):
tools.replace_in_file('CMakeLists.txt', 'project(expected)', tools.replace_in_file('CMakeLists.txt', 'project(tl-expected)',
'''project(expected) '''project(tl-expected)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup() conan_basic_setup()
''') ''')
@ -31,4 +31,4 @@ conan_basic_setup()
self.run('%s/bin/tests' % self.build_folder) self.run('%s/bin/tests' % self.build_folder)
def package(self): def package(self):
self.copy('*.hpp', dst='include/tl', src='tl') self.copy('*.hpp', dst='include/tl', src='include/tl')

BIN
include/tl/expected.hpp.gch Normal file

Binary file not shown.

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
TEST_CASE("Simple assignment", "[assignment.simple]") { TEST_CASE("Simple assignment", "[assignment.simple]") {
tl::expected<int, int> e1 = 42; tl::expected<int, int> e1 = 42;

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
#include <string> #include <string>

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
TEST_CASE("Constexpr", "[constexpr]") { TEST_CASE("Constexpr", "[constexpr]") {
//TODO //TODO

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
#include <vector> #include <vector>
#include <type_traits> #include <type_traits>

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <tuple> #include <tuple>

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
#define TOKENPASTE(x, y) x##y #define TOKENPASTE(x, y) x##y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y) #define TOKENPASTE2(x, y) TOKENPASTE(x, y)

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
#include <string> #include <string>

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
TEST_CASE("Noexcept", "[noexcept]") { TEST_CASE("Noexcept", "[noexcept]") {
//TODO //TODO

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
struct move_detector { struct move_detector {
move_detector() = default; move_detector() = default;

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
TEST_CASE("Relational operators", "[relops]") { TEST_CASE("Relational operators", "[relops]") {
//TODO //TODO

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "expected.hpp" #include <tl/expected.hpp>
struct no_throw { struct no_throw {
no_throw(std::string i) : i(i) {} no_throw(std::string i) : i(i) {}