Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
bcf4097
Re-adding pylint test.
mwaxmonsky Oct 26, 2024
340c2f9
Simplifying arg parser.
mwaxmonsky Oct 26, 2024
1285ea9
First pass refactor of tests into integrated stack.
mwaxmonsky Oct 30, 2024
c707b20
Updating MPI cmake find with components.
mwaxmonsky Oct 30, 2024
fd66d0f
Adding mpi library.
mwaxmonsky Oct 30, 2024
278b2bd
Updating mpi library.
mwaxmonsky Oct 30, 2024
9ce27bf
Adding missing cmake.
mwaxmonsky Oct 30, 2024
68f2575
Actually building.
mwaxmonsky Oct 30, 2024
c256bed
Adding pytest dependency.
mwaxmonsky Oct 30, 2024
e7f84f4
Updating pytest binary name.
mwaxmonsky Oct 30, 2024
c886348
Updating pytest install.
mwaxmonsky Oct 30, 2024
20feac2
Updating pytest binary name.
mwaxmonsky Oct 30, 2024
efff984
Updating test binary name in ctest to distinguish between other tests…
mwaxmonsky Oct 30, 2024
84cdd96
Minor CMake cleanup and temporarily removing MPI dependency.
mwaxmonsky Nov 4, 2024
cc43fda
Re-adding MPI for testing.
mwaxmonsky Nov 4, 2024
890ea0e
Resolving merge conflicts merging develop into testing-refactor branch.
mwaxmonsky Nov 11, 2024
cfe3921
Re-adding MPI linking and minor CMake cleanup.
mwaxmonsky Nov 11, 2024
9b66008
Fixing CI job failure.
mwaxmonsky Nov 11, 2024
df44e3a
Removing pylint workflow for different PR.
mwaxmonsky Nov 11, 2024
585405f
Resolving merge conflict merging 'develop' into 'testing-refactor'
mwaxmonsky Jan 30, 2025
afee04c
Removing pfunit fetch content call and only setting additional compil…
mwaxmonsky Jan 30, 2025
8270b07
Fixing whitespace.
mwaxmonsky Jan 30, 2025
96dd11a
Converting MATCHES to STREQUAL for compiler ID checks as not using re…
mwaxmonsky Jan 30, 2025
d4c4fb8
Adding back pfunit find_package.
mwaxmonsky Jan 30, 2025
ad60987
Adding pfunit into workflow instead of cmake.
mwaxmonsky Jan 30, 2025
5346e6a
Converting advection_test to new test setup and associated changes to…
mwaxmonsky Jan 30, 2025
d536aa7
Attempt consolidating of cmake.
mwaxmonsky Jan 31, 2025
eee0f1d
Fix cmake issues.
mwaxmonsky Jan 31, 2025
9f90b8e
Making advection test name unique for ctest.
mwaxmonsky Jan 31, 2025
c0ccfaf
Fix CMake casing.
mwaxmonsky Jan 31, 2025
84a2e3e
Adding advection tests to pytest workflow.
mwaxmonsky Jan 31, 2025
b447039
Removing un-needed gitignore.
mwaxmonsky Jan 31, 2025
d6218a3
CMake cleanup and support for building multiple tests.
mwaxmonsky Jan 31, 2025
6959e43
Make unique pytest targets.
mwaxmonsky Jan 31, 2025
2fe885b
Remove unused set statement.
mwaxmonsky Jan 31, 2025
4b15859
Adding ddt_host tests to cmake build workflow.
mwaxmonsky Jan 31, 2025
cfb1fdb
Adding var_compatibility_test to cmake workflow.
mwaxmonsky Jan 31, 2025
4006597
Remove unused .gitignore
mwaxmonsky Jan 31, 2025
fc79f04
Renaming pytest files to avoid collision.
mwaxmonsky Jan 31, 2025
e802031
adding advection pytests to workflow.
mwaxmonsky Jan 31, 2025
082c332
Adding missing imports.
mwaxmonsky Jan 31, 2025
dfc0ec1
Updating advection pytest.
mwaxmonsky Jan 31, 2025
c0e01f1
Fixing ddthost datatable build file location not being put in ddthost…
mwaxmonsky Feb 1, 2025
b4d3ae1
Re-add pytest version of ddthost tests.
mwaxmonsky Feb 1, 2025
d8a5731
Fixing ddthost missing python test and adding to github workflow.
mwaxmonsky Feb 1, 2025
9f82c57
Adding var_compatibility tests to pytest.
mwaxmonsky Feb 1, 2025
8b5ead1
Moving var_compatibility test filename to avoid collision and adding …
mwaxmonsky Feb 1, 2025
cfe8c54
Fix ddt test name.
mwaxmonsky Feb 1, 2025
a801b9a
Adding missing dependencies check.
mwaxmonsky Feb 1, 2025
ce104f9
Adding missing dependencies test.
mwaxmonsky Feb 1, 2025
a5c6884
Initial pfunit integration.
mwaxmonsky Feb 8, 2025
a9a21c6
Fixing missing newline at end of files.
mwaxmonsky Feb 8, 2025
a1bbde0
Additional conversion of test programs to pfunit tests.
mwaxmonsky Feb 8, 2025
af03ea5
Adding missing CMakeLists.txt update from previous commit.
mwaxmonsky Feb 8, 2025
15646da
Resolve merge conflicts merging 'develop' into 'testing-refactor'.
mwaxmonsky Feb 8, 2025
8155f81
Initial test_utils integration.
mwaxmonsky Feb 10, 2025
f5b4af2
Creating re-usable test stub and removing commented out previous styl…
mwaxmonsky Feb 15, 2025
1e38c9f
Resolving merge conflicts merging 'develop' into 'testing-refactor'.
mwaxmonsky Feb 15, 2025
675dec7
Convert DDT python tests to shared test harness.
mwaxmonsky Feb 15, 2025
4deed39
Fixing whitespace.
mwaxmonsky Feb 15, 2025
9603f77
Remove unused imports and fix spacing.
mwaxmonsky Feb 18, 2025
48e2f2a
Consolidate host tests to use shared test backend.
mwaxmonsky Feb 20, 2025
f4fab29
Replace semicolon seperator with standard seperator.
mwaxmonsky Feb 20, 2025
7e8ea47
Use dataclass to represent command line options.
mwaxmonsky Apr 11, 2025
8c5ee10
Resolving merge conflicts.
mwaxmonsky Apr 11, 2025
6fb121e
Use workspace path instead of hardcoded file path.
mwaxmonsky Apr 11, 2025
a175756
Resolving merge conflicts merging 'development' into 'testing-refactor'.
mwaxmonsky Apr 11, 2025
017da94
Fixing CMakeLists.txt find_package convention and adding Fortran to p…
mwaxmonsky Apr 11, 2025
f11f92d
Initial removal of scheme text file parsing.
mwaxmonsky Apr 11, 2025
142381e
Moving appending host meta file.
mwaxmonsky Apr 11, 2025
1d0d0db
Removing .txt files from advection test build.
mwaxmonsky Apr 11, 2025
a3fd180
Remove .txt files from DDT test build.
mwaxmonsky Apr 11, 2025
2ba46ea
Removing un-needed message.
mwaxmonsky Apr 11, 2025
74bde66
Removing .txt file from var_compatability test.
mwaxmonsky Apr 11, 2025
40ecc20
Fixing warning message.
mwaxmonsky Apr 12, 2025
d1e5195
Revert OpenMP flag rename.
mwaxmonsky Apr 12, 2025
6b6a410
Adding missing variables missed during merge.
mwaxmonsky Apr 12, 2025
bd52ac5
Fixing ordering missed during merge.
mwaxmonsky Apr 12, 2025
32b75e6
Fixing array dimension update.
mwaxmonsky Apr 12, 2025
f45f3fd
Revert datafile changes.
mwaxmonsky Apr 12, 2025
29b657d
Minor comment and new line cleanup.
mwaxmonsky Apr 12, 2025
d0e1095
Removing un-needed enable_languages call.
mwaxmonsky Apr 17, 2025
c8b3568
Reducing test_host hard coded name with cmake variable.
mwaxmonsky Apr 18, 2025
3c896c4
Resolving merge conflicts merging 'develop' into 'testing-refactor'
mwaxmonsky Apr 24, 2025
7b96750
Formatting updates.
mwaxmonsky Apr 24, 2025
1f30515
Fixing default build type to match documentation.
mwaxmonsky Apr 25, 2025
cf398b5
Remove most ifort deprecation warnings from cmake build log.
mwaxmonsky Apr 29, 2025
dfa3bf0
Re-adding deleted file.
mwaxmonsky May 2, 2025
2071507
Removing redundant error message for Doxygen.
mwaxmonsky May 2, 2025
23f6ce7
Removing dead code.
mwaxmonsky May 2, 2025
eda7676
Fixing typo.
mwaxmonsky May 2, 2025
fd9d58e
Fixing typo.
mwaxmonsky May 2, 2025
fe9da6e
Resolving merge conflicts merging 'develop' into 'testing-refactor'.
mwaxmonsky Jun 26, 2025
00fc8a9
Fixing build errors missed in previous merge conflict resolution.
mwaxmonsky Jun 26, 2025
6ff1205
Removing pfunit dependency.
mwaxmonsky Jul 1, 2025
4b7f00e
Adding explicit test flags to allow building singular regression test…
mwaxmonsky Jul 2, 2025
6f87d73
Updating CMake variables to be project prefixed and removing unused p…
mwaxmonsky Jul 2, 2025
1df0d8a
Making comment more explicit.
mwaxmonsky Jul 2, 2025
9533fca
Add error message for missing file.
mwaxmonsky Jul 2, 2025
850a295
Minor documentation update.
mwaxmonsky Jul 2, 2025
d3a2eb2
CMake cleanup and simplifcation.
mwaxmonsky Jul 7, 2025
c5a615d
Fixing test directive check.
mwaxmonsky Jul 7, 2025
20956e6
Fixing grouping.
mwaxmonsky Jul 7, 2025
b52536a
Initial test README.md
mwaxmonsky Jul 7, 2025
ab128aa
Removing unneeded override of CMAKE_MODULE_PATH.
mwaxmonsky Jul 7, 2025
0cb54ce
Added documentation for building docs.
mwaxmonsky Jul 7, 2025
5a4b60b
Documentation update/cleanup.
mwaxmonsky Jul 7, 2025
996c108
Add individual test run instructions.
mwaxmonsky Jul 7, 2025
fd910da
Updating unit-test README
mwaxmonsky Jul 8, 2025
8b33cb8
Adding docs to run doctests.
mwaxmonsky Jul 8, 2025
674de31
Minor formatting update.
mwaxmonsky Jul 8, 2025
ebff27f
Merge branch 'develop' into testing-refactor
mwaxmonsky Jul 10, 2025
e10df98
Adding missing newlines.
mwaxmonsky Jul 11, 2025
6cfd499
Addressing formatting and BUILD_SHARED_LIBS comment from PR review.
mwaxmonsky Jul 11, 2025
b8f5334
Removing un-needed flags.
mwaxmonsky Jul 11, 2025
461f42e
Suggestions to clean up OpenMP cmake integration and cmake diagnostic…
climbfuji Jul 11, 2025
9e8498e
Adding ignore line for build directory.
mwaxmonsky Jul 11, 2025
cda0028
Revert "Adding ignore line for build directory."
mwaxmonsky Jul 11, 2025
3013128
Merge pull request #1 from climbfuji/feature/refactor_feedback_dom
mwaxmonsky Jul 11, 2025
da2d9d2
Adding missing newline.
mwaxmonsky Jul 11, 2025
d2577a2
Adding demo cmake command.
mwaxmonsky Jul 14, 2025
75cbe98
Minor comment cleanup.
mwaxmonsky Jul 14, 2025
ca34e38
Adding case specific documentation for regression tests.
mwaxmonsky Jul 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions .github/workflows/capgen_unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,38 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: update repos and install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential ${{matrix.fortran-compiler}} cmake python3 git libxml2-utils
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libopenmpi-dev \
${{matrix.fortran-compiler}} \
cmake \
python3 \
git \
libxml2-utils
pip install --user pytest

- name: Build the framework
run: |
cmake -S. -B./build -DOPENMP=ON -DCCPP_FRAMEWORK_ENABLE_TESTS=ON
cd build
make

- name: Run unit tests
run: cd test && ./run_fortran_tests.sh
run: |
cd build
ctest --rerun-failed --output-on-failure . --verbose

- name: Run python tests
run: |
BUILD_DIR=./build \
PYTHONPATH=test/:scripts/ \
pytest \
test/capgen_test/capgen_test_reports.py \
test/advection_test/advection_test_reports.py \
test/ddthost_test/ddthost_test_reports.py \
test/var_compatibility_test/var_compatibility_test_reports.py

- name: Run Fortran to metadata test
run: cd test && ./test_fortran_to_metadata.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# All compiled Python modules
*.pyc

# CMake build directory
build/
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

107 changes: 89 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,117 @@ project(ccpp_framework
VERSION 5.0.0
LANGUAGES Fortran)

include(cmake/ccpp_capgen.cmake)

#------------------------------------------------------------------------------
# Set package definitions
set(PACKAGE "ccpp-framework")
set(AUTHORS "Dom Heinzeller" "Grant Firl" "Mike Kavulich" "Dustin Swales" "Courtney Peverley")
string(TIMESTAMP YEAR "%Y")

option(OPENMP "Enable OpenMP support for the framework" OFF)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(CCPP_FRAMEWORK_BUILD_DOCUMENTATION
"Create and install the HTML documentation (requires Doxygen)" OFF)
option(CCPP_FRAMEWORK_ENABLE_TESTS "Enable building/running CCPP regression tests" OFF)
option(CCPP_RUN_ADVECTION_TEST "Enable advection regression test" OFF)
option(CCPP_RUN_CAPGEN_TEST "Enable capgen regression test" OFF)
option(CCPP_RUN_DDT_HOST_TEST "Enable ddt host regression test" OFF)
option(CCPP_RUN_VAR_COMPATIBILITY_TEST "Enable variable compatibility regression test" OFF)

message("")
message("OPENMP .............................. ${OPENMP}")
message("BUILD_SHARED_LIBS ................... ${BUILD_SHARED_LIBS}")
message("")
message("CCPP_FRAMEWORK_BUILD_DOCUMENTATION ...${CCPP_FRAMEWORK_BUILD_DOCUMENTATION}")
message("CCPP_FRAMEWORK_ENABLE_TESTS ......... ${CCPP_FRAMEWORK_ENABLE_TESTS}")
message("CCPP_RUN_ADVECTION_TEST ............. ${CCPP_RUN_ADVECTION_TEST}")
message("CCPP_RUN_CAPGEN_TEST ................ ${CCPP_RUN_CAPGEN_TEST}")
message("CCPP_RUN_DDT_HOST_TEST .............. ${CCPP_RUN_DDT_HOST_TEST}")
message("CCPP_RUN_VAR_COMPATIBILITY_TEST ..... ${CCPP_RUN_VAR_COMPATIBILITY_TEST}")
message("")

set(CCPP_VERBOSITY "0" CACHE STRING "Verbosity level of output (default: 0)")

# Warn user on conflicting test options
if(CCPP_RUN_ADVECTION_TEST OR
CCPP_RUN_CAPGEN_TEST OR
CCPP_RUN_DDT_HOST_TEST OR
CCPP_RUN_VAR_COMPATIBILITY_TEST)
set(CCPP_MANUALLY_DECLARED_TEST ON BOOL)
endif()
if(CCPP_MANUALLY_DECLARED_TEST AND CCPP_FRAMEWORK_ENABLE_TESTS)
message(WARNING "Detected a manual test flag and the flag to run all tests. If only expected to run a single test, please unset CCPP_FRAMEWORK_ENABLE_TESTS option.")
endif()
set(CCPP_RUNNING_TESTS CCPP_FRAMEWORK_ENABLE_TESTS OR CCPP_MANUALLY_DECLARED_TEST)

# If running tests, set appropriate flags to help with debugging test issues.
if(CCPP_RUNNING_TESTS)
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
ADD_COMPILE_OPTIONS(-fcheck=all)
ADD_COMPILE_OPTIONS(-fbacktrace)
ADD_COMPILE_OPTIONS(-ffpe-trap=zero)
ADD_COMPILE_OPTIONS(-finit-real=nan)
ADD_COMPILE_OPTIONS(-ggdb)
ADD_COMPILE_OPTIONS(-ffree-line-length-none)
ADD_COMPILE_OPTIONS(-cpp)
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
ADD_COMPILE_OPTIONS(-fpe0)
ADD_COMPILE_OPTIONS(-warn)
ADD_COMPILE_OPTIONS(-traceback)
ADD_COMPILE_OPTIONS(-debug extended)
ADD_COMPILE_OPTIONS(-fpp)
ADD_COMPILE_OPTIONS(-diag-disable=10448)
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "IntelLLVM")
ADD_COMPILE_OPTIONS(-fpe0)
ADD_COMPILE_OPTIONS(-warn)
ADD_COMPILE_OPTIONS(-traceback)
ADD_COMPILE_OPTIONS(-debug full)
ADD_COMPILE_OPTIONS(-fpp)
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "NVIDIA" OR ${CMAKE_Fortran_COMPILER_ID} STREQUAL "NVHPC")
ADD_COMPILE_OPTIONS(-Mnoipa)
ADD_COMPILE_OPTIONS(-traceback)
ADD_COMPILE_OPTIONS(-Mfree)
ADD_COMPILE_OPTIONS(-Ktrap=fp)
ADD_COMPILE_OPTIONS(-Mpreprocess)
else()
message (WARNING "This program may not be able to be compiled with compiler :${CMAKE_Fortran_COMPILER_ID}")
endif()
endif()

# Use rpaths on MacOSX
set(CMAKE_MACOSX_RPATH 1)

#------------------------------------------------------------------------------
# Set MPI flags for Fortran with MPI F08 interface
find_package(MPI REQUIRED Fortran)
find_package(MPI COMPONENTS Fortran REQUIRED)
if(NOT MPI_Fortran_HAVE_F08_MODULE)
message(FATAL_ERROR "MPI implementation does not support the Fortran 2008 mpi_f08 interface")
endif()

#------------------------------------------------------------------------------
# Set OpenMP flags for C/C++/Fortran
if (OPENMP)
if(OPENMP)
find_package(OpenMP REQUIRED)
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
endif (OPENMP)
endif()

#------------------------------------------------------------------------------
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "Coverage")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()

#------------------------------------------------------------------------------
# Pass debug/release flag to Fortran files for preprocessor
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEBUG)
# Add the sub-directories
add_subdirectory(src)

if(CCPP_RUNNING_TESTS)
enable_testing()
add_subdirectory(test)
endif()

#------------------------------------------------------------------------------
# Request a static build
option(BUILD_SHARED_LIBS "Build a static library" OFF)
if (CCPP_FRAMEWORK_BUILD_DOCUMENTATION)
find_package(Doxygen REQUIRED)
add_subdirectory(doc)
endif()

#------------------------------------------------------------------------------
# Add the sub-directories
add_subdirectory(src)
add_subdirectory(doc)
129 changes: 129 additions & 0 deletions cmake/ccpp_capgen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# CMake wrapper for ccpp_capgen.py
# Currently meant to be a CMake API needed for generating caps for regression tests.
#
# CAPGEN_DEBUG - ON/OFF (Default: OFF) - Enables debug capability through ccpp_capgen.py
# CAPGEN_EXPECT_THROW_ERROR - ON/OFF (Default: OFF) - Scans ccpp_capgen.py log for error string and errors if not found.
# HOST_NAME - String name of host
# OUTPUT_ROOT - String path to put generated caps
# VERBOSITY - Number of --verbose flags to pass to capgen
# HOSTFILES - CMake list of host metadata filenames
# SCHEMEFILES - CMake list of scheme metadata files
# SUITES - CMake list of suite xml files
function(ccpp_capgen)
set(optionalArgs CAPGEN_DEBUG CAPGEN_EXPECT_THROW_ERROR)
set(oneValueArgs HOST_NAME OUTPUT_ROOT VERBOSITY)
set(multi_value_keywords HOSTFILES SCHEMEFILES SUITES)

cmake_parse_arguments(arg "${optionalArgs}" "${oneValueArgs}" "${multi_value_keywords}" ${ARGN})

# Error if script file not found.
set(CCPP_CAPGEN_CMD_LIST "${CMAKE_SOURCE_DIR}/scripts/ccpp_capgen.py")
if(NOT EXISTS ${CCPP_CAPGEN_CMD_LIST})
message(FATAL_ERROR "function(ccpp_capgen): Could not find ccpp_capgen.py. Looked for ${CCPP_CAPGEN_CMD_LIST}.")
endif()

# Interpret parsed arguments
if(DEFINED arg_CAPGEN_DEBUG)
list(APPEND CCPP_CAPGEN_CMD_LIST "--debug")
endif()
if(DEFINED arg_HOSTFILES)
list(JOIN arg_HOSTFILES "," HOSTFILES_SEPARATED)
list(APPEND CCPP_CAPGEN_CMD_LIST "--host-files" "${HOSTFILES_SEPARATED}")
endif()
if(DEFINED arg_SCHEMEFILES)
list(JOIN arg_SCHEMEFILES "," SCHEMEFILES_SEPARATED)
list(APPEND CCPP_CAPGEN_CMD_LIST "--scheme-files" "${SCHEMEFILES_SEPARATED}")
endif()
if(DEFINED arg_SUITES)
list(JOIN arg_SUITES "," SUITES_SEPARATED)
list(APPEND CCPP_CAPGEN_CMD_LIST "--suites" "${SUITES_SEPARATED}")
endif()
if(DEFINED arg_HOST_NAME)
list(APPEND CCPP_CAPGEN_CMD_LIST "--host-name" "${arg_HOST_NAME}")
endif()
if(DEFINED arg_OUTPUT_ROOT)
message(STATUS "Creating output directory: ${arg_OUTPUT_ROOT}")
file(MAKE_DIRECTORY "${arg_OUTPUT_ROOT}")
list(APPEND CCPP_CAPGEN_CMD_LIST "--output-root" "${arg_OUTPUT_ROOT}")
endif()
if(DEFINED arg_VERBOSITY)
string(REPEAT "--verbose" ${arg_VERBOSITY} VERBOSE_PARAMS_SEPERATED)
separate_arguments(VERBOSE_PARAMS UNIX_COMMAND "${VERBOSE_PARAMS_SEPERATED}")
list(APPEND CCPP_CAPGEN_CMD_LIST ${VERBOSE_PARAMS})
endif()

message(STATUS "Running ccpp_capgen.py from ${CMAKE_CURRENT_SOURCE_DIR}")

unset(CAPGEN_OUT) # Unset CAPGEN_OUT to prevent incorrect output on subsequent ccpp_capgen(...) calls.
execute_process(COMMAND ${CCPP_CAPGEN_CMD_LIST}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE CAPGEN_OUT
ERROR_VARIABLE CAPGEN_OUT
RESULT_VARIABLE RES
COMMAND_ECHO STDOUT)

message(STATUS "ccpp-capgen stdout: ${CAPGEN_OUT}")

if(arg_CAPGEN_EXPECT_THROW_ERROR)
# Determine if the process succeeded but had an expected string in the process log.
string(FIND "${CAPGEN_OUT}" "Variables of type ccpp_constituent_properties_t only allowed in register phase" ERROR_INDEX)

if (ERROR_INDEX GREATER -1)
message(STATUS "Capgen build produces expected error message.")
else()
message(FATAL_ERROR "CCPP cap generation did not generate expected error. Expected 'Variables of type constituent_properties_t only allowed in register phase.")
endif()
else()
if(RES EQUAL 0)
message(STATUS "ccpp-capgen completed successfully")
else()
message(FATAL_ERROR "CCPP cap generation FAILED: result = ${RES}")
endif()
endif()
endfunction()

# CMake wrapper for ccpp_datafile.py
# Currently meant to be a CMake API needed for generating caps for regression tests.
#
# DATATABLE - Path to generated datatable.xml file
# REPORT_NAME - String report name to get list of generated files form capgen (typically --ccpp-files)
function(ccpp_datafile)
set(oneValueArgs DATATABLE REPORT_NAME)
cmake_parse_arguments(arg "" "${oneValueArgs}" "" ${ARGN})

set(CCPP_DATAFILE_CMD "${CMAKE_SOURCE_DIR}/scripts/ccpp_datafile.py")

if(NOT EXISTS ${CCPP_DATAFILE_CMD})
message(FATAL_ERROR "function(ccpp_datafile): Could not find ccpp_datafile.py. Looked for ${CCPP_DATAFILE_CMD}.")
endif()

if(NOT DEFINED arg_REPORT_NAME)
message(FATAL_ERROR "function(ccpp_datafile): REPORT_NAME not set. Must specify the report to generate to run cpp_datafile.py")
endif()
list(APPEND CCPP_DATAFILE_CMD "${arg_REPORT_NAME}")

if(NOT DEFINED arg_DATATABLE)
message(FATAL_ERROR "function(ccpp_datafile): DATATABLE not set. A datatable file must be configured to call ccpp_datafile.")
endif()
list(APPEND CCPP_DATAFILE_CMD "${arg_DATATABLE}")

message(STATUS "Running ccpp_datafile from ${CMAKE_CURRENT_SOURCE_DIR}")

unset(CCPP_CAPS) # Unset CCPP_CAPS to prevent incorrect output on subsequent ccpp_datafile(...) calls.
execute_process(COMMAND ${CCPP_DATAFILE_CMD}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE CCPP_CAPS
RESULT_VARIABLE RES
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
COMMAND_ECHO STDOUT)
message(STATUS "CCPP_CAPS = ${CCPP_CAPS}")
if(RES EQUAL 0)
message(STATUS "CCPP cap files retrieved")
else()
message(FATAL_ERROR "CCPP cap file retrieval FAILED: result = ${RES}")
endif()
string(REPLACE "," ";" CCPP_CAPS_LIST ${CCPP_CAPS}) # Convert "," separated list from python back to ";" separated list for CMake.
set(CCPP_CAPS_LIST "${CCPP_CAPS_LIST}" PARENT_SCOPE)
endfunction()

28 changes: 8 additions & 20 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,16 @@
# Doxygen rules
#
# Add a target to generate API documentation with Doxygen
find_package(Doxygen)
option(BUILD_DOCUMENTATION
"Create and install the HTML documentation (requires Doxygen)"
${DOXYGEN_FOUND})
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

#
if(BUILD_DOCUMENTATION)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
endif()

set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

configure_file(${doxyfile_in} ${doxyfile} @ONLY)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)

add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
endif()
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)

set(gmtb_sty_in ${CMAKE_CURRENT_SOURCE_DIR}/DevelopersGuide/gmtb.sty)
set(gmtb_sty ${CMAKE_CURRENT_BINARY_DIR}/DevelopersGuide/gmtb.sty)
Expand Down
11 changes: 11 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Building the documentation

Similar to building the source code, building the documentation can be done by:

```bash
$ cmake -S<project_root_source_directory> -B<build_directory> -DCCPP_FRAMEWORK_BUILD_DOCUMENTATION=ON
cd build_directory
make doc
```

and the compiled documentation should be in `<build_directory>/doc/html`.
Loading