-
Notifications
You must be signed in to change notification settings - Fork 59
/
CMakeLists.txt
82 lines (70 loc) · 3.71 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Concise header-only library cmake template. Configuring this template into an actual project:
# - Add your source files to the sources list.
# - Add your third party libraries via the import_library function.
# - Add your test source files to the test sources list (optional).
################################################## Project ##################################################
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project (fg VERSION 1.0 LANGUAGES CXX)
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
################################################## Options ##################################################
option(BUILD_TESTS "Build tests." OFF)
################################################## Sources ##################################################
set(PROJECT_SOURCES
CMakeLists.txt
cmake/assign_source_group.cmake
cmake/import_library.cmake
include/fg/framegraph.hpp
include/fg/realize.hpp
include/fg/render_task.hpp
include/fg/render_task_base.hpp
include/fg/render_task_builder.hpp
include/fg/resource.hpp
include/fg/resource_base.hpp
license.txt
readme.md
)
include(assign_source_group)
assign_source_group(${PROJECT_SOURCES})
################################################## Dependencies ##################################################
include(import_library)
################################################## Targets ##################################################
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>)
target_include_directories(${PROJECT_NAME} INTERFACE ${PROJECT_INCLUDE_DIRS})
target_link_libraries (${PROJECT_NAME} INTERFACE ${PROJECT_LIBRARIES})
# Hack for header-only project to appear in the IDEs.
add_library(${PROJECT_NAME}_ STATIC ${PROJECT_SOURCES})
target_include_directories(${PROJECT_NAME}_
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${PROJECT_NAME}_ PUBLIC ${PROJECT_INCLUDE_DIRS})
target_link_libraries (${PROJECT_NAME}_ PUBLIC ${PROJECT_LIBRARIES})
set_target_properties (${PROJECT_NAME}_ PROPERTIES LINKER_LANGUAGE CXX)
set_property (TARGET ${PROJECT_NAME}_ PROPERTY CXX_STANDARD 17)
set_property (TARGET ${PROJECT_NAME}_ PROPERTY CXX_STANDARD_REQUIRED ON)
################################################## Testing ##################################################
if(BUILD_TESTS)
enable_testing()
set(PROJECT_TEST_SOURCES
tests/framegraph_test.cpp
)
foreach(_SOURCE ${PROJECT_TEST_SOURCES})
get_filename_component(_NAME ${_SOURCE} NAME_WE)
set (_SOURCES tests/catch.hpp tests/main.cpp ${_SOURCE})
add_executable (${_NAME} ${_SOURCES})
target_link_libraries (${_NAME} ${PROJECT_NAME})
add_test (${_NAME} ${_NAME})
set_property (TARGET ${_NAME} PROPERTY FOLDER "Tests")
set_property (TARGET ${_NAME} PROPERTY CXX_STANDARD 17)
set_property (TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
source_group ("source" FILES ${_SOURCES})
endforeach()
endif()
################################################## Installation ##################################################
install(TARGETS ${PROJECT_NAME} EXPORT "${PROJECT_NAME}-config")
install(DIRECTORY include/ DESTINATION include)
install(EXPORT "${PROJECT_NAME}-config" DESTINATION "cmake")
export (TARGETS "${PROJECT_NAME}" FILE "${PROJECT_NAME}-config.cmake")