-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
FindMetaExamples.cmake
116 lines (95 loc) · 3.81 KB
/
FindMetaExamples.cmake
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
macro(read_config_header config_file)
if(EXISTS ${config_file})
FILE(READ ${config_file} SHOGUN_CONFIG)
else()
message(fatal_error "Could not locate config.h of shogun at: ${config_file}")
endif()
endmacro()
function(is_set CONFIG_FILE FLAG)
STRING(REGEX MATCH "\#define ${FLAG}" IS_SET_${FLAG} ${CONFIG_FILE})
if (IS_SET_${FLAG})
set(${FLAG} ON PARENT_SCOPE)
else()
set(${FLAG} OFF PARENT_SCOPE)
endif()
endfunction()
function(get_excluded_meta_examples)
read_config_header(${shogun_INCLUDE_DIR}/shogun/lib/config.h)
is_set(${SHOGUN_CONFIG} HAVE_NLOPT)
is_set(${SHOGUN_CONFIG} USE_GPL_SHOGUN)
is_set(${SHOGUN_CONFIG} HAVE_LAPACK)
is_set(${SHOGUN_CONFIG} USE_SVMLIGHT)
# TODO(geektoni): fix this meta example
LIST(APPEND EXCLUDED_META_EXAMPLES
evaluation/cross_validation_multiple_kernel_learning_weights_storage.sg.in)
IF(NOT USE_GPL_SHOGUN)
LIST(APPEND EXCLUDED_META_EXAMPLES
multiclass/logistic_regression.sg.in
statistical_testing/linear_time_maximum_mean_discrepancy.sg.in
statistical_testing/quadratic_time_maximum_mean_discrepancy.sg.in
gaussian_process/classifier.sg.in
binary/svmlin.sg.in
binary/svmsgd.sg.in
)
ENDIF()
IF(NOT HAVE_LAPACK)
LIST(APPEND EXCLUDED_META_EXAMPLES
)
ENDIF()
IF(NOT USE_SVMLIGHT)
LIST(APPEND EXCLUDED_META_EXAMPLES
regression/multiple_kernel_learning.sg.in
binary/multiple_kernel_learning.sg.in
binary/svmlight.sg.in
binary/svmlight_batch_linadd.sg.in
regression/svrlight.sg.in
)
ENDIF()
# remove double entries to avoid errors due to "double" removing
LIST(LENGTH EXCLUDED_META_EXAMPLES NUM_EXCLUDED)
IF(NUM_EXCLUDED GREATER 0)
LIST(REMOVE_DUPLICATES EXCLUDED_META_EXAMPLES)
ENDIF()
SET(EXCLUDED_META_EXAMPLES ${EXCLUDED_META_EXAMPLES} PARENT_SCOPE)
endfunction()
# Remove meta example that cannot be built because of missing dependencies
function(find_meta_examples)
FILE(GLOB_RECURSE META_EXAMPLE_LISTINGS ${CMAKE_SOURCE_DIR}/examples/meta/src/*.sg.in)
get_excluded_meta_examples()
FOREACH(META_EXAMPLE ${EXCLUDED_META_EXAMPLES})
SET(EXCLUDED_EXAMPLE_FNAME ${CMAKE_SOURCE_DIR}/examples/meta/src/${META_EXAMPLE})
LIST(FIND META_EXAMPLE_LISTINGS ${EXCLUDED_EXAMPLE_FNAME} HAS_EXAMPLE)
IF(HAS_EXAMPLE EQUAL -1)
MESSAGE(FATAL_ERROR "Guarded meta example ${META_EXAMPLE} does not exist.")
ENDIF()
LIST(REMOVE_ITEM META_EXAMPLE_LISTINGS ${EXCLUDED_EXAMPLE_FNAME})
ENDFOREACH()
SET(META_EXAMPLES ${META_EXAMPLE_LISTINGS} PARENT_SCOPE)
endfunction()
# Get the cookbook pages we want to exclude from build
function(find_excluded_cookbook_pages)
get_excluded_meta_examples()
FOREACH(META_EXAMPLE ${EXCLUDED_META_EXAMPLES})
# This is made since some meta example does not have
# a cookbook page.
STRING(REPLACE ".sg.in" ".rst" META_EXAMPLE ${META_EXAMPLE})
IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/source/examples/${META_EXAMPLE})
LIST(APPEND EXCLUDED_COOKBOOK_PAGES examples/${META_EXAMPLE})
ENDIF()
ENDFOREACH()
# Check to ensure we have cookbook pages to exclude
IF(EXCLUDED_COOKBOOK_PAGES)
# Generate a string with all the meta examples separated by commas.
# This is made since Sphinx's exclude_patterns option wants
# the list's items separated by commas, but cmake's lists use
# semicolons instead.
# See: https://cmake.org/cmake/help/v3.3/command/list.html
# See: http://www.sphinx-doc.org/en/stable/invocation.html#id2
SET(TEMP "${EXCLUDED_COOKBOOK_PAGES}")
STRING(REPLACE ".rst" ".rst," TEMP ${TEMP})
string(REGEX REPLACE ".rst,$" ".rst" TEMP ${TEMP})
SET(EXCLUDED_COOKBOOK_PAGES ${TEMP} PARENT_SCOPE)
ELSE()
SET(EXCLUDED_COOKBOOK_PAGES "" PARENT_SCOPE)
ENDIF()
endfunction()