Skip to content

Commit

Permalink
Fixed CMake error to prevent KPP standalone being built in carbon sim
Browse files Browse the repository at this point in the history
src/CMakeLists.txt
- Defined the KPPSA_FILE_NAME variable for all mechanisms
- Call "add_executable(KPPSA_FILE_NAME ...) for all mechanisms
- Added an else block to disable the KPPSA_FILE_NAME executable
  from being built except for fullchem & custom mechanisms
- Wrapped the installation command for the KPPSA_FILE_NAME executable
  in an if block to ensure it is only built for fullchem & custom
  mechanisms.

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Dec 16, 2024
1 parent f866ce2 commit 7f7b6ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Changed
- Changed `submodules: true` to `submodules: recursive` in `.ci-pipelines/*.yml` files, which will fetch all levels of submodules in Azure CI tests.

### Fixed
- Fixed logic error in `src/CMakeLists.txt` that attempted to build the KPP standalone for the carbon simulation (see geoschem/GCClassic #78)

## [14.5.0] - 2024-11-08
### Changed
- Updated GEOS-Chem to 14.5.0
Expand Down
29 changes: 21 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,20 @@ set_target_properties(${EXE_FILE_NAME}
# 2. Specify the location of the main program
# 3. Specify libraries that the main program depends on
# 4. Store the binary exectuable file in the bin folder (pre-install)
# 5. If not fullchem or custom mechanism, prevent executable from being built
#
# At present build KPP standalone only for fullchem or custom mechanisms.
#
# This should now fix the issue reported by @msulprizio in:
# https://github.com/geoschem/GCClassic/issues/78
#-----------------------------------------------------------------------------
set(KPPSA_FILE_NAME kpp_standalone CACHE STRING
"Default name for the KPP standalone executable file")
mark_as_advanced(KPPSA_FILE_NAME)
add_executable(${KPPSA_FILE_NAME}
GEOS-Chem/KPP/standalone/kpp_standalone.F90
)
if("${MECH}" STREQUAL fullchem OR "${MECH}" STREQUAL custom)
set(KPPSA_FILE_NAME kpp_standalone CACHE STRING
"Default name for the KPP standalone executable file")
mark_as_advanced(KPPSA_FILE_NAME)

add_executable(${KPPSA_FILE_NAME}
GEOS-Chem/KPP/standalone/kpp_standalone.F90
)
target_link_libraries(${KPPSA_FILE_NAME}
PUBLIC
KPPStandalone
Expand All @@ -63,6 +66,11 @@ if("${MECH}" STREQUAL fullchem OR "${MECH}" STREQUAL custom)
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
else()
set_target_properties(${KPPSA_FILE_NAME}
PROPERTIES
EXCLUDE_FROM_ALL TRUE
)
endif()

#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -98,7 +106,12 @@ foreach(INSTALL_PATH ${COMBINED_INSTALL_DIRS})
# Installation path is a GEOS-Chem run directory,
# Therefore we will install the executable there.
install(TARGETS ${EXE_FILE_NAME} RUNTIME DESTINATION ${INSTALL_PATH})
install(TARGETS ${KPPSA_FILE_NAME} RUNTIME DESTINATION ${INSTALL_PATH})

# Only install KPP standalone for fullchem/custom mechanisms.
# See: htps://github.com/geoschem/GCClassic/issues/78
if("${MECH}" STREQUAL fullchem OR "${MECH}" STREQUAL custom)
install(TARGETS ${KPPSA_FILE_NAME} RUNTIME DESTINATION ${INSTALL_PATH})
endif()
endif()

endforeach()

0 comments on commit 7f7b6ff

Please sign in to comment.