Skip to content

Commit

Permalink
Merge pull request #19 from jedwards4b/add_pkg_config
Browse files Browse the repository at this point in the history
remove custom netcdf find function
  • Loading branch information
jedwards4b authored Dec 4, 2024
2 parents fec7c42 + 0784ad1 commit 0b326fd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 676 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ endif()
project (cprnc Fortran C)
include (CheckFunctionExists)
include (ExternalProject)
find_package(PkgConfig REQUIRED)

#===== Local modules =====
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
Expand Down Expand Up @@ -74,17 +75,20 @@ foreach (SRC_FILE IN LISTS CPRNC_GenF90_SRCS)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FILE}.in genf90)
endforeach ()

#===== NetCDF =====
pkg_check_modules(NetCDF REQUIRED IMPORTED_TARGET netcdf)

#===== NetCDF-Fortran =====
INCLUDE(FindNetCDF)
pkg_check_modules(NetCDF_Fortran REQUIRED IMPORTED_TARGET netcdf-fortran)
add_executable (cprnc ${CPRNC_Fortran_SRCS} ${CPRNC_GenF90_SRCS})
target_include_directories(cprnc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${NetCDF_Fortran_INCLUDE_DIRS})
target_include_directories(cprnc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

add_dependencies (cprnc genf90)

# Always use -fPIC
set_property(TARGET cprnc PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries (cprnc
PUBLIC ${NetCDF_Fortran_LIBRARIES} ${NetCDF_C_LIBRARIES} ${NetCDF_LIBRARIES})
PUBLIC PkgConfig::NetCDF_Fortran PkgConfig::NetCDF)

# We do not want cprnc injecting ctests into parent projects
if (CPRNC_STANDALONE)
Expand Down
96 changes: 0 additions & 96 deletions cmake/FindNetCDF.cmake

This file was deleted.

143 changes: 0 additions & 143 deletions cmake/FindNetCDF.cmake~

This file was deleted.

104 changes: 0 additions & 104 deletions cmake/LibCheck.cmake

This file was deleted.

Loading

0 comments on commit 0b326fd

Please sign in to comment.