Skip to content

Commit c7f3520

Browse files
committed
Implement build_type "cmake.external" as per core call today. This
brings back the explicit cmake build procedure for components with that build_type. Also update documentation on the component build_type option.
1 parent f299ff8 commit c7f3520

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

src/addon/ESMX/Driver/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,48 @@ foreach(CMP IN ITEMS ${COMPS})
333333
if(${CMP_BUILD_TYPE} STREQUAL "cmake")
334334
# CMake builds are only configured at this stage!
335335

336+
# build component with cmake.external
337+
elseif(${CMP_BUILD_TYPE} STREQUAL "cmake.external")
338+
message(STATUS "ESMX building (CMAKE external) - ${CMP} - ${CMP_SOURCE_DIR}")
339+
find_file(FND_CMAKE_LISTS
340+
NAMES CMakeLists.txt cmakelists.txt CMAKELISTS.txt
341+
PATHS ${CMP_SOURCE_DIR}
342+
NO_CACHE NO_DEFAULT_PATH
343+
)
344+
if(NOT FND_CMAKE_LISTS)
345+
message(FATAL_ERROR "Could not find CMakeLists.txt"
346+
" in ${CMP_SOURCE_DIR}."
347+
" Check source_dir in build configuration."
348+
)
349+
endif()
350+
unset(FND_CMAKE_LISTS)
351+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${CMP})
352+
execute_process(
353+
COMMAND ${CMAKE_COMMAND} -S${CMP_SOURCE_DIR}
354+
${ESMX_CMAKE_BUILD_ARGS}
355+
${ESMX_BUILD_ARGS}
356+
${CMP_BUILD_ARGS}
357+
-DCMAKE_INSTALL_PREFIX=${CMP_INSTALL_PREFIX}
358+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
359+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CMP}
360+
RESULT_VARIABLE ret
361+
)
362+
esmx_check_ret(${ret} "cmake generate failed for ${CMP}")
363+
execute_process(
364+
COMMAND ${CMAKE_COMMAND} --build .
365+
${ESMX_CMAKE_BUILD_VERBOSE}
366+
${ESMX_CMAKE_BUILD_JOBS}
367+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CMP}
368+
RESULT_VARIABLE ret
369+
)
370+
esmx_check_ret(${ret} "cmake build failed for ${CMP}")
371+
execute_process(
372+
COMMAND ${CMAKE_COMMAND} --install .
373+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CMP}
374+
RESULT_VARIABLE ret
375+
)
376+
esmx_check_ret(${ret} "cmake install failed for ${CMP}")
377+
336378
# build component with make
337379
elseif(${CMP_BUILD_TYPE} STREQUAL "make")
338380
message(STATUS "ESMX building (MAKE) - ${CMP} - ${CMP_SOURCE_DIR}")

src/addon/ESMX/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ This section contains a key for for each *component-name*, specifying component
224224

225225
| Option key | Description / Value options | Default |
226226
| ---------------- | --------------------------------------------- | ---------------------- |
227-
| `build_type` | [build type:](#build-types) `auto`, `cmake`, `make`, `script`, `none` | `auto` |
227+
| `build_type` | [build type:](#build-types) `auto`, `cmake`, `cmake.external`, `make`, `script`, `none` | `auto` |
228228
| `build_script` | build script | `compile` |
229229
| `build_args` | scalar or list of arguments for building component | *None* |
230230
| `source_dir` | source directory for build | *component-name* |
@@ -250,19 +250,22 @@ This section contains a key for for each *component-name*, specifying component
250250
##### Build Types:
251251

252252
**`auto`** -
253-
The ESMX build system searches for `CMakeLists.txt`, `Makefile`, and a build_script in order in the `source_dir` and uses the first build option it finds. If no build files are found then the ESMX build system searches for the CMake configuration file, fortran module, and libraries in the `install_prefix` directory but does not build the model. If no build option, CMake configuration, or libraries are found then the build fails.
253+
The ESMX build system searches for `CMakeLists.txt` (cmake), `Makefile` (make), and a build_script (script) in order in the `source_dir` and uses the first build option it finds. If no build files are found then the component's `build_type` is set to `none`.
254254

255255
**`cmake`** -
256-
The ESMX build system searches for `CMakeLists.txt` in the `source_dir` and builds using CMake. Once built, the ESMX build system searches for the CMake configuration file and libraries in the `install_prefix` directory.
256+
The ESMX build system integrates the component's `source_dir` into the ESMX CMake build using the CMake `add_subdirectory()` function. This ensures a shared build environment and consistent package handling between components and ESMX.
257+
258+
**`cmake.external`** -
259+
The ESMX build system attempts to configure/build/install the component externally by calling CMake on the component's `source_dir`. Once built, the ESMX build system searches for the CMake configuration file, Fortran module, and libraries in the `install_prefix` directory.
257260

258261
**`make`** -
259-
The ESMX build system searches for `Makefile` in the `source_dir` and builds using Make without a target. If a specific target is desired then it can be configured using `build_args`. Once built, the ESMX build system searches for libraries and fortran modules in the `install_prefix` directory.
262+
The ESMX build system uses GNU Make on the component's `source_dir` without a target. If a specific target is desired then it can be configured using `build_args`. Once built, the ESMX build system searches for libraries and Fortran modules in the `install_prefix` directory.
260263

261264
**`script`** -
262-
The ESMX build system searches for a `build_script` in the `source_dir` and builds using this script. Once built, the ESMX build system searches for libraries and fortran modules in the `install_prefix` directory.
265+
The ESMX build system uses `build_script` in the component's `source_dir` to build the component. Once built, the ESMX build system searches for the CMake configuration file, Fortran module, and libraries in the `install_prefix` directory.
263266

264267
**`none`** -
265-
The ESMX build system will not build the component. The ESMX build system searches for the CMake configuration file, fortran module, and libraries in the install_prefix directory.
268+
The ESMX build system will not build the component. The ESMX build system searches for the CMake configuration file, Fortran module, and libraries in the `install_prefix` directory.
266269

267270

268271
#### Test Options (`tests` key)

0 commit comments

Comments
 (0)