Skip to content

Commit

Permalink
Replace IF statement with generator expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanBryan51 committed Jan 19, 2024
1 parent 849c655 commit 5c030f6
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,28 @@ project(

option(CABLE_MPI "Build the MPI executable" OFF)

# third party libs
find_package(PkgConfig REQUIRED)
pkg_check_modules(NETCDF REQUIRED IMPORTED_TARGET "netcdf-fortran")

set(CABLE_INTEL_Fortran_FLAGS -fp-model precise)
set(CABLE_INTEL_Fortran_FLAGS_DEBUG -O0 -g -traceback -fpe0)
set(CABLE_INTEL_Fortran_FLAGS_RELEASE -O2)

set(CABLE_EXE_NAME "$<IF:$<BOOL:${CABLE_MPI}>,cable-mpi,cable>")

set(
CABLE_SRCS_SERIAL
src/offline/cable_driver.F90
)
set(
CABLE_SRCS_MPI
src/offline/cable_mpidrv.F90
src/offline/cable_mpicommon.F90
src/offline/cable_mpimaster.F90
src/offline/cable_mpiworker.F90
src/science/pop/pop_mpi.F90
)
set(
CABLE_SRCS_COMMON
src/science/casa-cnp/bgcdriver.F90
Expand Down Expand Up @@ -122,30 +140,11 @@ set(
src/science/roughness/roughnessHGT_effLAI_cbl.F90
src/offline/spincasacnp.F90
)

find_package(PkgConfig REQUIRED)

pkg_check_modules(NETCDF REQUIRED IMPORTED_TARGET "netcdf-fortran")

if(CABLE_MPI)
set(
CABLE_SRCS
src/offline/cable_mpidrv.F90
src/offline/cable_mpicommon.F90
src/offline/cable_mpimaster.F90
src/offline/cable_mpiworker.F90
src/science/pop/pop_mpi.F90
${CABLE_SRCS_COMMON}
)
set(CABLE_EXE_NAME cable-mpi)
else()
set(
CABLE_SRCS
src/offline/cable_driver.F90
${CABLE_SRCS_COMMON}
)
set(CABLE_EXE_NAME cable)
endif()
set(
CABLE_SRCS
"$<IF:$<BOOL:${CABLE_MPI}>,${CABLE_SRCS_MPI},${CABLE_SRCS_SERIAL}>"
${CABLE_SRCS_COMMON}
)

add_executable(cable ${CABLE_SRCS})

Expand All @@ -161,7 +160,6 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
)
endif()

# third party libs
target_link_libraries(
cable
PkgConfig::NETCDF
Expand Down

0 comments on commit 5c030f6

Please sign in to comment.