1
-
2
1
# @file: flux_sdk_init.cmake
3
2
4
- ############################################################################
3
+ # ### ###########################################################################
5
4
# flux_sdk_version()
6
5
include (${CMAKE_CURRENT_LIST_DIR} /flux_sdk_version.cmake )
7
6
8
- # set language to NONE- disables compiler checks - too
9
- # project(${CMAKE_PROJECT_NAME} NONE)
10
-
11
- ############################################################################
7
+ # ##############################################################################
12
8
# flux_sdk_set_project_directory()
13
9
#
14
10
macro (flux_sdk_set_project_directory project_directory )
15
11
16
- set (PROJECT_FLUX_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /${project_directory}/Flux )
12
+ set (PROJECT_FLUX_DIRECTORY
13
+ ${CMAKE_CURRENT_SOURCE_DIR} /${project_directory}/Flux )
17
14
18
- if ( NOT EXISTS ${PROJECT_FLUX_DIRECTORY} )
19
- message (STATUS "Creating directory: ${PROJECT_FLUX_DIRECTORY} " )
20
- file (MAKE_DIRECTORY ${PROJECT_FLUX_DIRECTORY} )
21
- endif ()
15
+ if ( NOT EXISTS ${PROJECT_FLUX_DIRECTORY} )
16
+ message (STATUS "Creating directory: ${PROJECT_FLUX_DIRECTORY} " )
17
+ file (MAKE_DIRECTORY ${PROJECT_FLUX_DIRECTORY} )
18
+ endif ()
22
19
23
20
endmacro ()
24
- ############################################################################
21
+ # ### ###########################################################################
25
22
# flux_sdk_add_module()
26
23
#
27
- ## macro to add "modules" to our list of modules to add to the build
24
+ # macro to add "modules" to our list of modules to add to the build
28
25
macro (flux_sdk_add_module )
29
- set (list_var "${ARGN} " )
30
- foreach (arg IN LISTS list_var )
31
- list (APPEND FLUX_MODULES_TO_ADD ${arg} )
32
- endforeach ()
26
+ set (list_var "${ARGN} " )
27
+ foreach (arg IN LISTS list_var )
28
+ list (APPEND FLUX_MODULES_TO_ADD ${arg} )
29
+ endforeach ()
33
30
endmacro ()
34
31
35
32
function (flux_sdk_get_directory_name result_name )
36
- get_filename_component (THIS_MODULE ${CMAKE_CURRENT_SOURCE_DIR} NAME )
37
- set (${result_name} ${THIS_MODULE} PARENT_SCOPE )
33
+ get_filename_component (THIS_MODULE ${CMAKE_CURRENT_SOURCE_DIR} NAME )
34
+ set (${result_name}
35
+ ${THIS_MODULE}
36
+ PARENT_SCOPE )
38
37
endfunction ()
39
38
40
- ############################################################################
39
+ # ### ###########################################################################
41
40
# flux_sdk_add_source_files()
42
41
#
43
- ## Macro to add a file to our build system file list
42
+ # Macro to add a file to our build system file list
44
43
macro (flux_sdk_add_source_files )
45
- set (list_var "${ARGN} " )
46
- foreach (arg IN LISTS list_var )
47
- configure_file (${arg} ${PROJECT_FLUX_DIRECTORY} COPYONLY )
48
- endforeach ()
44
+ set (list_var "${ARGN} " )
45
+ foreach (arg IN LISTS list_var )
46
+ configure_file (${arg} ${PROJECT_FLUX_DIRECTORY} COPYONLY )
47
+ endforeach ()
49
48
endmacro ()
50
49
51
- ############################################################################
50
+ # ### ###########################################################################
52
51
# flux_sdk_is_module_enabled()
53
52
#
54
- # Define a function that will check if a module is enabled in the list
55
- # of enabled modules
53
+ # Define a function that will check if a module is enabled in the list of
54
+ # enabled modules
56
55
57
56
function (flux_sdk_is_module_enabled module_name result )
58
- if (${module_name} IN_LIST FLUX_MODULES_TO_ADD )
59
- set (${result} TRUE PARENT_SCOPE )
60
- else ()
61
- set (${result} FALSE PARENT_SCOPE )
62
- endif ()
57
+ if (${module_name} IN_LIST FLUX_MODULES_TO_ADD )
58
+ set (${result}
59
+ TRUE
60
+ PARENT_SCOPE )
61
+ else ()
62
+ set (${result}
63
+ FALSE
64
+ PARENT_SCOPE )
65
+ endif ()
63
66
endfunction ()
64
67
65
-
66
- ############################################################################
68
+ # ##############################################################################
67
69
# flux_sdk_process_subdirectories()
68
70
#
69
- # Define a function that will cacade down subdirectories if that directory
70
- # is a module desired, and has a CMakeLists.txt file.
71
+ # Define a function that will cacade down subdirectories if that directory is a
72
+ # module desired, and has a CMakeLists.txt file.
71
73
#
72
- # Note: If the <directory>_all_modules flag is set, then all submodules of that
73
- # directory will be processed
74
+ # Note: If the <directory>_all_modules flag is set, then all submodules of that
75
+ # directory will be processed
74
76
75
77
function (flux_sdk_process_subdirectories )
76
-
77
- # get our place in the SDK - print a value
78
- file (RELATIVE_PATH local_path ${FLUX_SDK_PATH} ${CMAKE_CURRENT_SOURCE_DIR} )
79
- message ("Processing:\t\$ FLUX_SDK/${local_path} " )
80
78
81
- # Get the name of the current directory - basename. We use this
82
- # to build our "all submodules" flag for this directory
83
- get_filename_component (CurrentDir ${CMAKE_CURRENT_SOURCE_DIR} NAME )
84
- set (all_modules_flag "${CurrentDir} _all_modules" )
79
+ # get our place in the SDK - print a value
80
+ file (RELATIVE_PATH local_path ${FLUX_SDK_PATH} ${CMAKE_CURRENT_SOURCE_DIR} )
81
+ message ("Processing:\t\$ FLUX_SDK/${local_path} " )
85
82
86
- # is the flag set?
87
- flux_sdk_is_module_enabled (${all_modules_flag} process_all_submodules )
83
+ # Get the name of the current directory - basename. We use this to build our
84
+ # "all submodules" flag for this directory
85
+ get_filename_component (CurrentDir ${CMAKE_CURRENT_SOURCE_DIR} NAME )
86
+ set (all_modules_flag "${CurrentDir} _all_modules" )
88
87
89
- # is everything enabled?
90
- flux_sdk_is_module_enabled (flux_all_modules process_all_modules )
88
+ # is the flag set?
89
+ flux_sdk_is_module_enabled (${all_modules_flag} process_all_submodules )
91
90
92
- message ("Module flag:\t ${all_modules_flag} = ${process_all_submodules} " )
91
+ # is everything enabled?
92
+ flux_sdk_is_module_enabled (flux_all_modules process_all_modules )
93
93
94
- # are we loading all submodules?
95
- if ( process_all_submodules OR process_all_modules )
96
- set (load_all_modules TRUE )
97
- endif ()
94
+ message ("Module flag:\t ${all_modules_flag} = ${process_all_submodules} " )
95
+
96
+ # are we loading all submodules?
97
+ if (process_all_submodules OR process_all_modules )
98
+ set (load_all_modules TRUE )
99
+ endif ()
98
100
99
- # Get all the children of this directory
100
- file (GLOB children RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} /* )
101
-
102
- # Iterate over all the children
103
- foreach (child ${children} )
104
-
105
- # Sanity check
106
- if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /${child} AND
107
- EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /${child}/CMakeLists.txt )
108
-
109
- # add this module - in list, or all devices flag set
110
- if (load_all_modules OR ${child} IN_LIST FLUX_MODULES_TO_ADD )
111
- message (STATUS "Adding: ${child} " )
112
- add_subdirectory (${child} )
113
- endif ()
114
- endif ()
115
- endforeach ()
116
- message ("" )
101
+ # Get all the children of this directory
102
+ file (
103
+ GLOB children
104
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
105
+ ${CMAKE_CURRENT_SOURCE_DIR} /* )
106
+
107
+ # Iterate over all the children
108
+ foreach (child ${children} )
109
+
110
+ # Sanity check
111
+ if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /${child}
112
+ AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /${child}/CMakeLists.txt )
113
+
114
+ # add this module - in list, or all devices flag set
115
+ if (load_all_modules OR ${child} IN_LIST FLUX_MODULES_TO_ADD )
116
+ message (STATUS "Adding: ${child} " )
117
+ add_subdirectory (${child} )
118
+ endif ()
119
+ endif ()
120
+ endforeach ()
121
+ message ("" )
117
122
endfunction ()
118
123
119
- ############################################################################
124
+ # ### ###########################################################################
120
125
# flux_sdk_init()
121
126
#
122
- # Called to start the SDK build process. This should be called after the flux_sdk
123
- # import cmake file is loaded (of course)
127
+ # Called to start the SDK build process. This should be called after the
128
+ # flux_sdk import cmake file is loaded (of course)
124
129
macro (flux_sdk_init )
125
- if (NOT CMAKE_PROJECT_NAME )
126
- message (WARNING "flux_sdk_init() should be called after the project is created" )
127
- endif ()
130
+ if (NOT CMAKE_PROJECT_NAME )
131
+ message (
132
+ WARNING "flux_sdk_init() should be called after the project is created" )
133
+ endif ()
134
+
135
+ # write some info!
136
+ message ("\n -----------------------------------------------------" )
137
+ message ("SparkFun Flux SDK - Version: ${FLUX_SDK_VERSION} " )
138
+ message ("-----------------------------------------------------\n " )
139
+ message ("SDK Path:\t ${FLUX_SDK_PATH} " )
140
+ message ("Project Name:\t ${CMAKE_PROJECT_NAME} " )
141
+ message ("Destination:\t ${PROJECT_FLUX_DIRECTORY} " )
142
+ message ("" )
143
+
144
+ # is everything enabled?
145
+ flux_sdk_is_module_enabled (flux_all_modules process_all_modules )
146
+ message ("Module flag:\t flux_all_modules = ${process_all_modules} " )
147
+ string (TIMESTAMP COMPILE_TIME "%Y-%m-%d %H:%M:%S" )
148
+ message ("Build Time:\t ${COMPILE_TIME} " )
149
+ message ("" )
150
+
151
+ # load the root directory of the SDK
152
+ add_subdirectory (${FLUX_SDK_PATH} flux-sdk )
128
153
129
- # write some info!
130
- message ("\n -----------------------------------------------------" )
131
- message ("SparkFun Flux SDK - Version: ${FLUX_SDK_VERSION} " )
132
- message ("-----------------------------------------------------\n " )
133
- message ("SDK Path:\t ${FLUX_SDK_PATH} " )
134
- message ("Project Name:\t ${CMAKE_PROJECT_NAME} " )
135
- message ("Destination:\t ${PROJECT_FLUX_DIRECTORY} " )
136
- message ("" )
137
-
138
- # is everything enabled?
139
- flux_sdk_is_module_enabled (flux_all_modules process_all_modules )
140
- message ("Module flag:\t flux_all_modules = ${process_all_modules} " )
141
- string (TIMESTAMP COMPILE_TIME "%Y-%m-%d %H:%M:%S" )
142
- message ("Build Time:\t ${COMPILE_TIME} " )
143
- message ("" )
144
-
145
- # load the root directory of the SDK
146
- add_subdirectory (${FLUX_SDK_PATH} flux-sdk )
147
-
148
- endmacro ()
154
+ endmacro ()
0 commit comments