-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
starting to rebuild cmake build system
- Loading branch information
1 parent
cc1457c
commit 1e1a142
Showing
4 changed files
with
151 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This is the cmake file for the aux_progs directory of wgrib2. | ||
# | ||
# Kyle Gerheiser, Edward Hartnett | ||
|
||
add_executable(gmerge gmerge.c uint8.c) | ||
add_executable(smallest_grib2 smallest_grib2.c uint8.c) | ||
add_executable(smallest_4 smallest_4.c uint8.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This is the cmake file for the ftn_api directory of wgrib2. | ||
# | ||
# Kyle Gerheiser, Edward Hartnett | ||
|
||
set(fortran_src wgrib2api.f90 wgrib2lowapi.f90) | ||
|
||
set(c_src fort_wgrib2.c) | ||
|
||
add_library(wgrib2_api ${fortran_src} ${c_src}) | ||
|
||
set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}") | ||
set_target_properties(wgrib2_api PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir}) | ||
|
||
target_include_directories(wgrib2_api | ||
PUBLIC $<BUILD_INTERFACE:${module_dir}> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}>) | ||
|
||
target_link_libraries(wgrib2_api PUBLIC wgrib2_lib) | ||
|
||
install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
|
||
install( | ||
TARGETS wgrib2_api | ||
EXPORT wgrib2_exports | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# This is the cmake file for the wgrib2 directory of wgrib2. | ||
# | ||
# Kyle Gerheiser, Edward Hartnett | ||
|
||
# sets lib_src | ||
include("source-files.cmake") | ||
|
||
set(callable_src | ||
wgrib2.c | ||
fatal_error.c | ||
wgrib2_api.c | ||
) | ||
|
||
# This subdirectory no longer present! | ||
#add_subdirectory(gctpc) | ||
|
||
# make this an object lib so we can re-use most of object files | ||
# The only files that differ are ${callable_src} which are compiled | ||
# with -DCALLABLE_WGRIB2 | ||
add_library(obj_lib OBJECT ${lib_src}) | ||
target_compile_definitions(obj_lib PUBLIC ${definitions_list}) | ||
|
||
if(BUILD_LIB) | ||
# with -DCALLABLE_WGRIB2 for the lib | ||
if(BUILD_SHARED_LIB) | ||
add_library(wgrib2_lib SHARED ${lib_src} $<TARGET_OBJECTS:gctpc> ${callable_src}) | ||
else() | ||
add_library(wgrib2_lib STATIC ${lib_src} $<TARGET_OBJECTS:gctpc> ${callable_src}) | ||
endif() | ||
|
||
# library and executable have same name (wgrib2) but different target names | ||
set_target_properties(wgrib2_lib PROPERTIES OUTPUT_NAME wgrib2) | ||
target_compile_definitions(wgrib2_lib PRIVATE CALLABLE_WGRIB2 USE_REGEX) | ||
endif() | ||
|
||
|
||
# without -DCALLABLE_WGRIB2 for the executable | ||
add_executable(wgrib2_exe ${callable_src}) | ||
set_target_properties(wgrib2_exe PROPERTIES OUTPUT_NAME wgrib2) | ||
|
||
if(USE_NETCDF4) | ||
target_link_libraries(obj_lib PUBLIC NetCDF::NetCDF_C) | ||
endif() | ||
|
||
if(USE_JASPER) | ||
target_include_directories(obj_lib PUBLIC ${JASPER_INCLUDE_DIR}) | ||
target_link_libraries(obj_lib PUBLIC ${JASPER_LIBRARIES}) | ||
endif() | ||
|
||
if(USE_PNG) | ||
target_link_libraries(obj_lib PUBLIC PNG::PNG) | ||
endif() | ||
|
||
if(OpenMP_C_FOUND) | ||
target_link_libraries(obj_lib PUBLIC OpenMP::OpenMP_C) | ||
endif() | ||
|
||
if(USE_G2CLIB) | ||
endif() | ||
|
||
if(USE_IPOLATES EQUAL 3) | ||
target_link_libraries(obj_lib PUBLIC ip2::ip2_d) | ||
|
||
# Link to the Fortran runtime library for each compiler if using ip2. | ||
# The wgrib2 exectuable is created using the C compiler and | ||
# doesn't link the necessary Fortran library required for ip2. | ||
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") | ||
target_link_libraries(wgrib2_exe PRIVATE "-lifcore") | ||
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") | ||
target_link_libraries(wgrib2_exe PRIVATE "-lgfortran") | ||
endif() | ||
|
||
endif() | ||
|
||
target_link_libraries(obj_lib PUBLIC gctpc -lm) | ||
|
||
# Link to gctpc directly because oobject libraries do not link transitively | ||
target_link_libraries(wgrib2_exe PRIVATE gctpc) | ||
target_link_libraries(wgrib2_exe PRIVATE obj_lib) | ||
|
||
if(BUILD_LIB) | ||
set(headers wgrib2_api.h wgrib2.h) | ||
target_link_libraries(wgrib2_lib PUBLIC gctpc) | ||
set_target_properties(wgrib2_lib PROPERTIES PUBLIC_HEADER "${headers}") | ||
|
||
install( | ||
TARGETS wgrib2_lib | ||
EXPORT wgrib2_exports | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
) | ||
|
||
endif() | ||
|
||
install( | ||
TARGETS wgrib2_exe obj_lib | ||
EXPORT wgrib2_exports | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
|
||
|
||
|
||
|
||
|