Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated CMakeLists to work with GEOS-ESM/ESMA_cmake#57 #226

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
4 changes: 1 addition & 3 deletions GMAO_pFIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ set (srcs
)

esma_add_library (${this} SRCS ${srcs})
target_link_libraries (${this} gftl gftl-shared ${NETCDF_LIBRARIES})
target_link_libraries (${this} PUBLIC Baselibs)

target_compile_options (${this} PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:${OpenMP_Fortran_FLAGS}>)
set_target_properties (${this} PROPERTIES Fortran_MODULE_DIRECTORY ${include_${this}})
target_link_libraries (${this} ${MPI_Fortran_LIBRARIES} ${OpenMP_Fortran_LIBRARIES})
# Kludge for OSX security and DYLD_LIBRARY_PATH ...
foreach(dir ${OSX_EXTRA_LIBRARY_PATH})
target_link_libraries(${this} "-Xlinker -rpath -Xlinker ${dir}")
Expand Down
3 changes: 1 addition & 2 deletions MAPL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ esma_set_this()

esma_add_library (${this}
SRCS MAPL.F90
DEPENDENCIES MAPL_Base GMAO_pFIO MAPL_cfio_r4
INCLUDES ${INC_ESMF}
DEPENDENCIES MAPL_Base GMAO_pFIO MAPL_cfio_r4 ESMF
)


Expand Down
8 changes: 5 additions & 3 deletions MAPL_Base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set (srcs
MAPL_GenericCplComp.F90 MAPL_Sort.F90
MAPL_Generic.F90 MAPL_sun_uc.F90 MAPL_SatVapor.F90
MAPL_HistoryCollection.F90
MAPL_HistoryGridComp.F90 MAPL_CapOptions.F90 MAPL_FlapCapOptions.F90
MAPL_HistoryGridComp.F90 MAPL_CapOptions.F90 $<$<BOOL:${FLAP_FOUND}>:MAPL_FlapCapOptions.F90>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm weak on CMake generator expressions. Does this construct build the source file only if FLAP is found? If so, very nice, though might be good to put it on a separate line if we need to make any other changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's correct. Personally, I prefer them to if() blocks because I find they simplify the logic of CMakeLists (e.g. you'd need a new variable to accomplish this otherwise).

Specifically, $<BOOL:${FLAP_FOUND}> evaluates ${FLAP_FOUND} to 0 or 1 according to CMake's if logic. Then the ouside generator expression evaluates to "MAPL_FlapCapOptions.F90" iff the inside generator expression was 1.

I just added it to a new line. How does that look?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FLAP_FOUND is the standard variable set by find_package(FLAP ...) (i.e. find_package(XXX) sets XXX_FOUND according to here)

MAPL_Cap.F90 hash.c
MAPL_CapGridComp.F90
MAPL_GridType.F90
Expand Down Expand Up @@ -63,8 +63,7 @@ set (srcs
FileMetadataUtilities.F90 FileMetadataUtilitiesVector.F90
)

esma_add_library(${this} SRCS ${srcs} DEPENDENCIES GMAO_pFIO MAPL_cfio_r4 gftl-shared FLAP::FLAP)
target_compile_options (${this} PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:${OpenMP_Fortran_FLAGS}>)
esma_add_library(${this} SRCS ${srcs} DEPENDENCIES GMAO_pFIO MAPL_cfio_r4 gftl-shared $<$<BOOL:${FLAP_IS_REQUIRED}>:FLAP::FLAP>)
target_compile_definitions (${this} PRIVATE TWO_SIDED_COMM MAPL_MODE)

# Kludge for OSX security and DYLD_LIBRARY_PATH ...
Expand All @@ -89,6 +88,9 @@ endif()
#--------------------
target_include_directories (${this} PUBLIC ${INC_ESMF} ${INC_NETCDF})
target_link_libraries (${this} PUBLIC ${ESMF_LIBRARIES} ${MPI_Fortran_LIBRARIES})
if(FLAP_FOUND)
target_compile_definitions(${this} PRIVATE USE_FLAP)
endif()

#--------------------
# Copy include files that are used by other libraries.
Expand Down
2 changes: 1 addition & 1 deletion MAPL_cfio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ esma_add_library (${lib}
SRCS ${srcs}
DEPENDENCIES ${ESMF_LIBRARIES}
)
target_include_directories (${lib} PUBLIC ${INC_NETCDF} ${INC_ESMF})
target_link_libraries(${lib} PUBLIC Baselibs)

if (precision MATCHES "r8")
string (REPLACE " " ";" flags ${FREAL8})
Expand Down