1- # This file contains several helper functions to allow easy
1+ # This file contains several helper functions to allow easy
22# inclusion of the CommsChampion project in other cmake project.
33
44# Available functions are:
1515# - REPO - Override the default repository of the comms.
1616#
1717# ******************************************************
18- # - Build comms during cmake configuration stage. Use it
18+ # - Build comms during cmake configuration stage. Use it
1919# when the compilation process is light, i.e. only comms library is installed.
2020# cc_comms_build_during_config(
2121# SRC_DIR <src_dir>
3232# - REPO - Override the default repository of the comms.
3333# - CMAKE_ARGS - Extra cmake arguments to be passed to the comms project.
3434# Use CMAKE_INSTALL_PREFIX to specify where the output needs to be installed.
35- # - NO_DEFAULT_CMAKE_ARGS - Exclude passing the extra cmake arguments that copy the
35+ # - NO_DEFAULT_CMAKE_ARGS - Exclude passing the extra cmake arguments that copy the
3636# following values from the invoking project:
3737# * CMAKE_C_COMPILER
3838# * CMAKE_CXX_COMPILER
4242# * CMAKE_GENERATOR_TOOLSET
4343# * CMAKE_BUILD_TYPE
4444# * CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
45- # The default values are passed before ones specified in CMAKE_ARGS, which can overwrite
45+ # The default values are passed before ones specified in CMAKE_ARGS, which can overwrite
4646# some of the default values.
47- # - NO_REPO - Don't checkout sources, SRC_DIR must contain checkout out sources, suitable
47+ # - NO_REPO - Don't checkout sources, SRC_DIR must contain checkout out sources, suitable
4848# for this repo being a submodule.
4949#
5050# ******************************************************
6464# - TGT - Name of CMake target that can be used to establish dependencies.
6565# - SRC_DIR - A directory where comms sources will end up.
6666# - BUILD_DIR - A directory where comms will be build.
67- # - INSTALL_DIR - A directory where comms will be installed, also passed as
67+ # - INSTALL_DIR - A directory where comms will be installed, also passed as
6868# CMAKE_INSTALL_PREFIX in addition to provided CMAKE_ARGS.
6969# - TAG - Override the default tag to checkout (unless NO_REPO param is used).
7070# - REPO - Override the default repository of the comms (unless NO_REPO param is used).
7171# - CMAKE_ARGS - Extra cmake arguments to be passed to the comms project.
72- # - NO_REPO - Don't checkout sources, SRC_DIR must contain checkout out sources,
72+ # - NO_REPO - Don't checkout sources, SRC_DIR must contain checkout out sources,
7373# suitable for this repo being a submodule.
7474# - UPDATE_DISCONNECTED - Pass "UPDATE_DISCONNECTED 1" to ExternalProject_Add()
75- # - NO_DEFAULT_CMAKE_ARGS - Exclude passing the extra cmake arguments that copy the
75+ # - NO_DEFAULT_CMAKE_ARGS - Exclude passing the extra cmake arguments that copy the
7676# following values from the invoking project:
7777# * CMAKE_C_COMPILER
7878# * CMAKE_CXX_COMPILER
8282# * CMAKE_GENERATOR_TOOLSET
8383# * CMAKE_BUILD_TYPE
8484# * CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
85- # The default values are passed before ones specified in CMAKE_ARGS, which can overwrite
85+ # The default values are passed before ones specified in CMAKE_ARGS, which can overwrite
8686# some of the copied values.
8787#
8888# ******************************************************
@@ -99,15 +99,15 @@ function (cc_comms_pull_sources)
9999
100100 if (NOT CC_PULL_SRC_DIR)
101101 message (FATAL_ERROR "The SRC_DIR parameter is not provided" )
102- endif ()
102+ endif ()
103103
104104 if (NOT CC_PULL_REPO)
105105 set (CC_PULL_REPO ${CC_EXTERNAL_DEFAULT_REPO} )
106- endif ()
106+ endif ()
107107
108108 if (NOT CC_PULL_TAG)
109109 set (CC_PULL_TAG ${CC_EXTERNAL_DEFAULT_TAG} )
110- endif ()
110+ endif ()
111111
112112 if (NOT GIT_FOUND)
113113 find_package (Git REQUIRED )
@@ -116,16 +116,16 @@ function (cc_comms_pull_sources)
116116 if (EXISTS "${CC_PULL_SRC_DIR} /.git" )
117117 message (STATUS "Updating existing comms repository" )
118118 execute_process (
119- COMMAND ${GIT_EXECUTABLE} pull
119+ COMMAND ${GIT_EXECUTABLE} pull
120120 WORKING_DIRECTORY ${CC_PULL_SRC_DIR}
121121 )
122-
122+
123123 execute_process (
124124 COMMAND ${GIT_EXECUTABLE} checkout ${CC_PULL_TAG}
125125 WORKING_DIRECTORY ${CC_PULL_SRC_DIR}
126126 RESULT_VARIABLE git_result
127127 )
128-
128+
129129 if (NOT "${git_result} " STREQUAL "0" )
130130 message (WARNING "git checkout failed" )
131131 endif ()
@@ -138,13 +138,13 @@ function (cc_comms_pull_sources)
138138 execute_process (
139139 COMMAND ${CMAKE_COMMAND} -E remove_directory "${CC_PULL_SRC_DIR} "
140140 )
141-
141+
142142 execute_process (
143143 COMMAND ${CMAKE_COMMAND} -E make_directory "${CC_PULL_SRC_DIR} "
144- )
145-
144+ )
145+
146146 execute_process (
147- COMMAND
147+ COMMAND
148148 ${GIT_EXECUTABLE} clone -b ${CC_PULL_TAG} ${CC_PULL_REPO} ${CC_PULL_SRC_DIR}
149149 RESULT_VARIABLE git_result
150150 )
@@ -163,22 +163,22 @@ function (cc_comms_build_during_config)
163163
164164 if (NOT CC_BUILD_SRC_DIR)
165165 message (FATAL_ERROR "The SRC_DIR parameter is not provided" )
166- endif ()
166+ endif ()
167167
168168 if (NOT CC_BUILD_BUILD_DIR)
169169 set (CC_BUILD_BUILD_DIR ${PROJECT_BINARY_DIR} /comms)
170- endif ()
170+ endif ()
171171
172172 if (NOT CC_BUILD_REPO)
173173 set (CC_BUILD_REPO ${CC_EXTERNAL_DEFAULT_REPO} )
174- endif ()
174+ endif ()
175175
176176 if (NOT CC_BUILD_TAG)
177177 set (CC_BUILD_TAG ${CC_EXTERNAL_DEFAULT_TAG} )
178- endif ()
178+ endif ()
179179
180180 if (NOT CC_BUILD_NO_REPO)
181- cc_comms_pull_sources (SRC_DIR ${CC_BUILD_SRC_DIR} REPO ${CC_BUILD_REPO} TAG ${CC_BUILD_TAG} )
181+ cc_comms_pull_sources (SRC_DIR ${CC_BUILD_SRC_DIR} REPO ${CC_BUILD_REPO} TAG ${CC_BUILD_TAG} )
182182 endif ()
183183
184184 execute_process (
@@ -188,7 +188,7 @@ function (cc_comms_build_during_config)
188188 set (extra_cmake_args)
189189 if (NOT CC_BUILD_NO_DEFAULT_CMAKE_ARGS)
190190 set (extra_cmake_args
191- -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
191+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
192192 -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
193193 -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
194194 -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
@@ -218,7 +218,7 @@ function (cc_comms_build_during_config)
218218
219219 if (NOT ${cc_build_result} EQUAL 0)
220220 message (FATAL_ERROR "Build of comms has failed with result ${cc_build_result} " )
221- endif ()
221+ endif ()
222222endfunction ()
223223
224224macro (cc_comms_define_external_project_target inst_dir )
@@ -229,7 +229,7 @@ macro (cc_comms_define_external_project_target inst_dir)
229229 add_library (cc::comms INTERFACE IMPORTED GLOBAL )
230230 execute_process (
231231 COMMAND ${CMAKE_COMMAND} -E make_directory ${CC_INCLUDE_DIRS}
232- )
232+ )
233233 target_include_directories (cc::comms INTERFACE ${CC_INCLUDE_DIRS} )
234234endmacro ()
235235
@@ -242,27 +242,26 @@ function (cc_comms_build_as_external_project)
242242
243243 if (NOT CC_EXTERNAL_PROJ_SRC_DIR)
244244 message (FATAL_ERROR "The SRC_DIR parameter is not provided" )
245- endif ()
245+ endif ()
246246
247247 if (NOT CC_EXTERNAL_PROJ_BUILD_DIR)
248248 set (CC_EXTERNAL_PROJ_BUILD_DIR ${PROJECT_BINARY_DIR} /comms)
249- endif ()
249+ endif ()
250250
251251 if (NOT CC_EXTERNAL_PROJ_INSTALL_DIR)
252252 set (CC_EXTERNAL_PROJ_INSTALL_DIR ${CC_EXTERNAL_PROJ_BUILD_DIR} /install)
253- endif ()
253+ endif ()
254254
255255 set (repo_param)
256256 set (repo_tag_param)
257257 if (NOT CC_EXTERNAL_PROJ_NO_REPO)
258258 if (NOT CC_EXTERNAL_PROJ_REPO)
259259 set (CC_EXTERNAL_PROJ_REPO ${CC_EXTERNAL_DEFAULT_REPO} )
260- endif ()
260+ endif ()
261261
262262 if (NOT CC_EXTERNAL_PROJ_TAG)
263263 set (CC_EXTERNAL_PROJ_TAG ${CC_EXTERNAL_DEFAULT_TAG} )
264- endif ()
265-
264+ endif ()
266265
267266 set (repo_param GIT_REPOSITORY "${CC_EXTERNAL_PROJ_REPO} " )
268267 set (repo_tag_param GIT_TAG "${CC_EXTERNAL_PROJ_TAG} " )
@@ -275,17 +274,17 @@ function (cc_comms_build_as_external_project)
275274 set (cc_update_disconnected_opt)
276275 if (CC_EXTERNAL_PROJ_UPDATE_DISCONNECTED)
277276 set (cc_update_disconnected_opt "UPDATE_DISCONNECTED 1" )
278- endif ()
277+ endif ()
279278
280279 set (extra_cmake_args)
281280 if (NOT CC_EXTERNAL_PROJ_NO_DEFAULT_CMAKE_ARGS)
282281 set (extra_cmake_args
283- -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
282+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
284283 -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
285284 -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
286285 -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
287286 -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
288- -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
287+ -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
289288 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
290289 -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
291290 )
@@ -301,11 +300,11 @@ function (cc_comms_build_as_external_project)
301300 BINARY_DIR "${CC_EXTERNAL_PROJ_BUILD_DIR} "
302301 INSTALL_DIR "${CC_EXTERNAL_PROJ_INSTALL_DIR} "
303302 ${cc_update_disconnected_opt}
304- CMAKE_ARGS
303+ CMAKE_ARGS
305304 ${extra_cmake_args}
306305 -DCMAKE_INSTALL_PREFIX=${CC_EXTERNAL_PROJ_INSTALL_DIR}
307306 ${CC_EXTERNAL_PROJ_CMAKE_ARGS}
308- )
307+ )
309308 cc_comms_define_external_project_target (${CC_EXTERNAL_PROJ_INSTALL_DIR} )
310309
311310 if (TARGET cc::comms)
0 commit comments