/[lmdze]/trunk/CMakeLists.txt
ViewVC logotype

Annotation of /trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 351 - (hide annotations)
Tue Jan 7 11:59:00 2020 UTC (4 years, 5 months ago) by guez
File MIME type: text/plain
File size: 1055 byte(s)
Simplify `CMakeLists.txt` files

Take advantage of improved building of libraries: use `find_package`
instead of `find_path` and `find_library`.

Link each executable to target `LMDZE_objects` instead of including the
corresponding objects in the definition of the target executable. This
way, the executable inherits the dependencies of `LMDZE_objects` and
we do not need them in `library_list`.

Remove the definition of `library_list`. Replace the reference to
`library_list` by references to just `netcdff_LIBRARY` and `NetCDF_LIBRARY`.

1 guez 329 cmake_minimum_required(VERSION 3.14)
2     project(LMDZE Fortran)
3    
4     find_path(netcdff_INCLUDE_DIR netcdf.mod)
5     find_library(netcdff_LIBRARY netcdff)
6    
7 guez 351 find_package(NR_util REQUIRED CONFIG)
8     find_package(Jumble REQUIRED CONFIG)
9     find_package(Numer_Rec_95 REQUIRED CONFIG)
10     find_package(NetCDF95 REQUIRED CONFIG)
11 guez 329
12     add_library(LMDZE_objects OBJECT dimensions.F90)
13    
14     set(CPP_IIM 16 CACHE STRING "iim, number of longitudes")
15 guez 330 set(CPP_JJM 12 CACHE STRING "jjm, number of latitudes")
16 guez 329 set(CPP_LLM 11 CACHE STRING "llm, number of vertical levels")
17    
18 guez 333 message(STATUS "Set iim to ${CPP_IIM}, jjm to ${CPP_JJM}, llm to ${CPP_LLM}")
19    
20     target_compile_definitions(LMDZE_objects PRIVATE CPP_IIM=${CPP_IIM}
21     CPP_JJM=${CPP_JJM} CPP_LLM=${CPP_LLM})
22    
23 guez 351 target_include_directories(LMDZE_objects PRIVATE ${netcdff_INCLUDE_DIR})
24     target_link_libraries(LMDZE_objects netcdf95 jumble numer_rec_95)
25 guez 329
26     foreach(my_dir dyn3d filtrez IOIPSL misc phylmd)
27     include(${my_dir}/CMakeLists.txt)
28     endforeach(my_dir)
29    
30 guez 335 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
31 guez 329 include(ConfigureCompilerFlags)
32     include(TAGS)

  ViewVC Help
Powered by ViewVC 1.1.21