-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from TartanLlama/cmake_love
Do CMake properly
- Loading branch information
Showing
11 changed files
with
75 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "cmake/tl-cmake"] | ||
path = cmake/tl-cmake | ||
url = https://github.com/TartanLlama/tl-cmake.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
cmake_minimum_required(VERSION 3.11) | ||
|
||
project(function_ref) | ||
project(tl-function_ref VERSION 1.0.0 LANGUAGES CXX) | ||
|
||
# Prepare "Catch" library for other executables | ||
set(CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/test) | ||
add_library(Catch INTERFACE) | ||
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) | ||
|
||
# Make test executable | ||
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tests/constructors.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tests/call.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tests/issues.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tests/assignment.cpp) | ||
|
||
add_executable(tests ${TEST_SOURCES}) | ||
option(FUNCTION_REF_ENABLE_TESTS "Enable tests." ON) | ||
|
||
add_library(function_ref INTERFACE) | ||
target_sources(function_ref INTERFACE ${CMAKE_SOURCE_DIR}/function_ref.hpp) | ||
target_include_directories(function_ref INTERFACE ${CMAKE_SOURCE_DIR}) | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
tl_cmake | ||
GIT_REPOSITORY https://github.com/TartanLlama/tl-cmake.git | ||
) | ||
FetchContent_GetProperties(tl_cmake) | ||
if(NOT tl_cmake_POPULATED) | ||
FetchContent_Populate(tl_cmake) | ||
set(CMAKE_MODULE_PATH ${tl_cmake_SOURCE_DIR} ${CMAKE_MODULE_PATH}) | ||
endif() | ||
include(add-tl) | ||
|
||
target_link_libraries(tests Catch function_ref) | ||
set_property(TARGET tests PROPERTY CXX_STANDARD 14) | ||
tl_add_library(function-ref SOURCES | ||
include/tl/function_ref.hpp) | ||
|
||
# Prepare "Catch" library for other executables | ||
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test) | ||
add_library(Catch INTERFACE) | ||
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) | ||
|
||
find_package(standardese) # find standardese after installation | ||
|
||
# generates a custom target that will run standardese to generate the documentation | ||
if (standardese_FOUND) | ||
standardese_generate(function_ref | ||
INCLUDE_DIRECTORY . | ||
CONFIG ${CMAKE_SOURCE_DIR}/standardese.config | ||
INPUT function_ref.hpp) | ||
endif () | ||
if(FUNCTION_REF_ENABLE_TESTS) | ||
# Make test executable | ||
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tests/constructors.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tests/call.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tests/issues.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/tests/assignment.cpp) | ||
|
||
add_executable(tests ${TEST_SOURCES}) | ||
|
||
target_link_libraries(tests Catch function-ref) | ||
|
||
set_property(TARGET tests PROPERTY CXX_STANDARD 14) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/tl-function-ref-targets.cmake") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include "catch.hpp" | ||
#include "function_ref.hpp" | ||
#include <tl/function_ref.hpp> | ||
|
||
void f(){} | ||
struct b { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include "catch.hpp" | ||
#include "function_ref.hpp" | ||
#include <tl/function_ref.hpp> | ||
|
||
void foo(){} | ||
struct bar { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters