Skip to content

Commit f507f7a

Browse files
committed
Do CMake properly
1 parent b2b125e commit f507f7a

File tree

10 files changed

+40
-35
lines changed

10 files changed

+40
-35
lines changed

.appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ os:
33
- Visual Studio 2017
44

55
build_script:
6+
- git submodule update --init --recursive
67
- mkdir build
78
- cd build
89
- cmake ..

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "cmake/tl-cmake"]
2+
path = cmake/tl-cmake
3+
url = https://github.com/TartanLlama/tl-cmake.git

CMakeLists.txt

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1-
cmake_minimum_required(VERSION 3.0)
1+
cmake_minimum_required(VERSION 3.8)
22

3-
project(function_ref)
3+
project(tl-function_ref VERSION 1.0.0 LANGUAGES CXX)
44

5-
# Prepare "Catch" library for other executables
6-
set(CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/test)
7-
add_library(Catch INTERFACE)
8-
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
9-
10-
# Make test executable
11-
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp
12-
${CMAKE_CURRENT_SOURCE_DIR}/tests/constructors.cpp
13-
${CMAKE_CURRENT_SOURCE_DIR}/tests/call.cpp
14-
${CMAKE_CURRENT_SOURCE_DIR}/tests/issues.cpp
15-
${CMAKE_CURRENT_SOURCE_DIR}/tests/assignment.cpp)
16-
17-
add_executable(tests ${TEST_SOURCES})
5+
option(FUNCTION_REF_ENABLE_TESTS "Enable tests." ON)
186

19-
add_library(function_ref INTERFACE)
20-
target_sources(function_ref INTERFACE ${CMAKE_SOURCE_DIR}/function_ref.hpp)
21-
target_include_directories(function_ref INTERFACE ${CMAKE_SOURCE_DIR})
7+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/tl-cmake" ${CMAKE_MODULE_PATH})
8+
include(add-tl)
229

23-
target_link_libraries(tests Catch function_ref)
24-
set_property(TARGET tests PROPERTY CXX_STANDARD 14)
10+
tl_add_library(function-ref SOURCES
11+
include/tl/function_ref.hpp)
2512

13+
# Prepare "Catch" library for other executables
14+
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
15+
add_library(Catch INTERFACE)
16+
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
2617

27-
find_package(standardese) # find standardese after installation
28-
29-
# generates a custom target that will run standardese to generate the documentation
30-
if (standardese_FOUND)
31-
standardese_generate(function_ref
32-
INCLUDE_DIRECTORY .
33-
CONFIG ${CMAKE_SOURCE_DIR}/standardese.config
34-
INPUT function_ref.hpp)
35-
endif ()
18+
if(FUNCTION_REF_ENABLE_TESTS)
19+
# Make test executable
20+
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp
21+
${CMAKE_CURRENT_SOURCE_DIR}/tests/constructors.cpp
22+
${CMAKE_CURRENT_SOURCE_DIR}/tests/call.cpp
23+
${CMAKE_CURRENT_SOURCE_DIR}/tests/issues.cpp
24+
${CMAKE_CURRENT_SOURCE_DIR}/tests/assignment.cpp)
25+
26+
add_executable(tests ${TEST_SOURCES})
27+
28+
target_link_libraries(tests Catch function-ref)
29+
30+
set_property(TARGET tests PROPERTY CXX_STANDARD 14)
31+
endif()

cmake/tl-cmake

Submodule tl-cmake added at 284c6a3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/tl-function-ref-targets.cmake")
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
#ifndef TL_FUNCTION_REF_HPP
1515
#define TL_FUNCTION_REF_HPP
1616

17-
#define TL_FUNCTION_REF_VERSION_MAJOR 0
18-
#define TL_FUNCTION_REF_VERSION_MINOR 2
17+
#define TL_FUNCTION_REF_VERSION_MAJOR 1
18+
#define TL_FUNCTION_REF_VERSION_MINOR 0
19+
#define TL_FUNCTION_REF_VERSION_PATCH 0
1920

2021
#if (defined(_MSC_VER) && _MSC_VER == 1900)
2122
/// \exclude

tests/assignment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "catch.hpp"
2-
#include "function_ref.hpp"
2+
#include <tl/function_ref.hpp>
33

44
void f(){}
55
struct b {

tests/call.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "catch.hpp"
2-
#include "function_ref.hpp"
2+
#include <tl/function_ref.hpp>
33

44
namespace {
55
bool f_called = false;

tests/constructors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "catch.hpp"
2-
#include "function_ref.hpp"
2+
#include <tl/function_ref.hpp>
33

44
void foo(){}
55
struct bar {

tests/issues.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "catch.hpp"
2-
#include "function_ref.hpp"
2+
#include <tl/function_ref.hpp>
33

44
TEST_CASE("Issue #2") {
55
const auto lam = [](int ) {};

0 commit comments

Comments
 (0)