forked from taskflow/taskflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
86 lines (63 loc) · 2.9 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
cmake_minimum_required (VERSION 3.9)
MESSAGE(STATUS "CMAKE_ROOT: " ${CMAKE_ROOT})
# Project name
project(Cpp-TaskFlow)
# Turn on the verbose
set(CMAKE_VERBOSE_MAKEFILE ON)
# CXX target properties
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#set(USE_WERROR ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER})
message(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})
message(STATUS "CMAKE_EXE_LINKER_FLAGS: " ${CMAKE_EXE_LINKER_FLAGS})
# The version number
set (TASKFLOW_MAJOR_VERSION "1")
set (TASKFLOW_MINOR_VERSION "0")
# add the binayr tree to the search path for include files
include_directories(${PROJECT_SOURCE_DIR})
include_directories(doctest)
# Find pthread package
find_package(Threads REQUIRED)
# Find OpenMP package
include(FindOpenMP)
if(OpenMP_CXX_FOUND)
message(STATUS "OpenMP_CXX_SPEC_DATE: ${OpenMP_CXX_SPEC_DATE}")
message(STATUS "OpenMP_CXX_VERSION: ${OpenMP_CXX_VERSION}")
else(OpenMP_CXX_FOUND)
message(WARNING "OpenMP CXX not found")
endif(OpenMP_CXX_FOUND)
# -----------------------------------------------------------------------------
# Example program
# -----------------------------------------------------------------------------
message(STATUS "Building examples ...")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/example)
set(EXAMPLE_CXX_FLAGS ${OpenMP_CXX_FLAGS})
list(APPEND EXAMPLE_EXE_LINKER_FLAGS "")
list(APPEND EXAMPLE_EXE_LINKER_FLAGS Threads::Threads)
list(APPEND EXAMPLE_EXE_LINKER_FLAGS OpenMP::OpenMP_CXX)
message(STATUS "EXAMPLE_CXX_FLAGS: " ${EXAMPLE_CXX_FLAGS})
message(STATUS "EXAMPLE_EXE_LINKER_FLAGS: " ${EXAMPLE_EXE_LINKER_FLAGS})
add_executable(simple example/simple.cpp)
target_link_libraries(simple ${EXAMPLE_EXE_LINKER_FLAGS})
add_executable(matrix example/matrix.cpp)
target_compile_options(matrix PRIVATE ${EXAMPLE_CXX_FLAGS})
target_link_libraries(matrix ${EXAMPLE_EXE_LINKER_FLAGS})
add_executable(parallel_for example/parallel_for.cpp)
target_compile_options(parallel_for PRIVATE ${EXAMPLE_CXX_FLAGS})
target_link_libraries(parallel_for ${EXAMPLE_EXE_LINKER_FLAGS})
# -----------------------------------------------------------------------------
# Unittest
# -----------------------------------------------------------------------------
enable_testing()
message(STATUS "Building unit tests ...")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/unittest)
add_executable(taskflow unittest/taskflow.cpp)
target_link_libraries(taskflow Threads::Threads)
add_test(builder ${PROJECT_SOURCE_DIR}/unittest/taskflow -tc=Taskflow.Builder)
add_test(dispatch ${PROJECT_SOURCE_DIR}/unittest/taskflow -tc=Taskflow.Dispatch)
add_test(parallel_for ${PROJECT_SOURCE_DIR}/unittest/taskflow -tc=Taskflow.ParallelFor)
#add_test(parallel_range ${PROJECT_SOURCE_DIR}/unittest/taskflow -tc=Taskflow.ParallelRange)