Merge branch 'cmakeBuild' into develop (PR #230)
[WPS.git] / util / CMakeLists.txt
blob684ecae313c48d8b0c5afbbb70b5afcaee609d4a
1 add_library( util_common STATIC )
2 # todo - Find how to compile this with NCAR Graphics, will need to write a find_package() module
3 # add_executable( plotgrids )
4 add_executable( rd_intermediate )
5 add_executable( avg_tsfc )
6 # Find out if this needs compiling, ./compile suggests no
7 # add_executable( elev_angle )
8 add_executable( calc_ecmwf_p )
9 # Same thing as plotgrids
10 # add_executable( plotfmt )
11 add_executable( mod_levs )
12 if ( DEFINED WRF_DIR )
13   add_executable( int2nc )
14 endif()
15 add_executable( height_ukmo )
17 set(
18     ALL_UTIL_TARGETS
19       # plotgrids
20       rd_intermediate
21       avg_tsfc
22       # elev_angle
23       calc_ecmwf_p
24       # plotfmt
25       mod_levs
26       height_ukmo
27       )
29 if ( DEFINED WRF_DIR )
30   list( APPEND ALL_UTIL_TARGETS int2nc )
31 endif()
33 add_subdirectory( src )
35 # Specific linking
36 # target_link_libraries(
37 #                       elev_angle
38 #                       PRIVATE
39 #                         ${netCDF_LIBRARIES}
40 #                       )
41 # target_include_directories(
42 #                             elev_angle
43 #                             PRIVATE
44 #                               ${netCDF_INCLUDE_DIRS}
45 #                             )
47 if ( DEFINED WRF_DIR )
48   target_link_libraries(
49                         int2nc
50                         PRIVATE
51                           WRF::WRF_Core
52                           ${netCDF_LIBRARIES}
53                         )
54   target_include_directories(
55                             int2nc
56                             PRIVATE
57                               ${netCDF_INCLUDE_DIRS}
58                             )
59 endif()
61 # Every single target
62 foreach( TARGET ${ALL_UTIL_TARGETS} util_common )
64   # Set the mod dir
65   set_target_properties( 
66                         ${TARGET}
67                         PROPERTIES
68                           # Just dump everything in here
69                           Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/util/
70                           Fortran_FORMAT           FREE
71                         )
73   # Everything except util_common
74   if ( NOT "${TARGET}" STREQUAL util_common )
75     target_link_libraries(
76                           ${TARGET}
77                           PRIVATE
78                             util_common
79                           )
80   endif()
82   # Add these to the export targets
83   install(
84           TARGETS ${TARGET}
85           EXPORT ${EXPORT_NAME}Targets
86           RUNTIME DESTINATION bin/
87           ARCHIVE DESTINATION lib/
88           LIBRARY DESTINATION lib/
89           )
91 endforeach()