Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / external / io_adios2 / CMakeLists.txt
bloba63a7e79146b3596d183f260d2e16303bcdf280a
1 # WRF CMake Build
3 get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
5 add_library(
6             ${FOLDER_COMPILE_TARGET}
7               STATIC
8               )
10 # Do this first to simplify steps later
11 set_target_properties( 
12                       ${FOLDER_COMPILE_TARGET} 
13                         PROPERTIES
14                           Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET}
15                           EXPORT_PROPERTIES        Fortran_MODULE_DIRECTORY
16                       )
19 target_link_libraries(  ${FOLDER_COMPILE_TARGET}
20                           PRIVATE
21                             $<$<BOOL:${USE_MPI}>:$<TARGET_NAME_IF_EXISTS:MPI::MPI_Fortran>>
22                             $<$<BOOL:${USE_OPENMP}>:$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_Fortran>>
23                         )
25 target_include_directories( ${FOLDER_COMPILE_TARGET}
26                             PRIVATE
27                               ${CMAKE_CURRENT_SOURCE_DIR}/../ioapi_share
28                               ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET}
29                             )
32 # First preprocess
33 get_target_property   ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES )
34 wrf_c_preproc_fortran( 
35                         TARGET_NAME     ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io
36                         OUTPUT_DIR      ${CMAKE_CURRENT_BINARY_DIR}/preproc/
37                         EXTENSION       ".f90"
38                         INCLUDES        ${FOLDER_COMPILE_TARGET_INCLUDES}
39                         DEFINITIONS     ${PROJECT_COMPILE_DEFINITIONS}
40                         SOURCES         wrf_io.F90
41                         )
43 # Now M4 preprocess
44 wrf_m4_preproc_fortran( 
45                         TARGET_NAME     ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io
46                         OUTPUT_DIR      ${CMAKE_CURRENT_BINARY_DIR}/preproc/
47                         PREFIX          "m4_preproc_"
48                         EXTENSION       ".f90"
49                         SOURCES         ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90
50                         DEPENDENCIES    ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io
51                         TARGET_SCOPE    ${FOLDER_COMPILE_TARGET}
52                         FLAGS           ${M4_FLAGS}
53                         )
55 add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io )
57 target_sources(
58                 ${FOLDER_COMPILE_TARGET}
59                 PRIVATE
60                   ${CMAKE_CURRENT_BINARY_DIR}/preproc/m4_preproc_wrf_io.f90
61                   field_routines.F90
62                   )
64 install(
65         TARGETS ${FOLDER_COMPILE_TARGET}
66         EXPORT  ${EXPORT_NAME}Targets
67         RUNTIME DESTINATION bin/
68         ARCHIVE DESTINATION lib/
69         LIBRARY DESTINATION lib/
70         )