-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove custom netcdf find function #19
Conversation
I've used this PR plus the following diff diff --git a/CMakeLists.txt b/CMakeLists.txt
index 330c0fb..0404289 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,19 +76,19 @@ foreach (SRC_FILE IN LISTS CPRNC_GenF90_SRCS)
endforeach ()
#===== NetCDF =====
-pkg_check_modules(NetCDF REQUIRED netcdf)
+pkg_check_modules(NetCDF REQUIRED IMPORTED_TARGET netcdf)
#===== NetCDF-Fortran =====
-pkg_check_modules(NetCDF_Fortran REQUIRED netcdf-fortran)
+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_LIBRARIES})
+ PUBLIC PkgConfig::NetCDF_Fortran PkgConfig::NetCDF)
# We do not want cprnc injecting ctests into parent projects
if (CPRNC_STANDALONE) and verified that CMAKE_INSTALL_RPATH_USE_LINK_PATH works. The upside of |
I also ran the cime test_self_build_cprnc:(test_sys_cime_case.TestCimeCase) ... ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great change, thanks!
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work with static libraries?
Remove the custom code used to find netcdf and use pkg_config instead.