Skip to content

Commit

Permalink
Merge pull request #434 from ZedThree/fix-cmake-nf-config
Browse files Browse the repository at this point in the history
Use consistent `nf-config.in` template for both CMake/autotools
  • Loading branch information
WardF authored Mar 14, 2024
2 parents 9c4cb9b + 3fa1f1f commit b84141a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 156 deletions.
47 changes: 24 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1021,26 +1021,6 @@ IF(CMAKE_LINK_FLAGS)
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_LINK_FLAGS}")
ENDIF()

# Set
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(exec_prefix ${CMAKE_INSTALL_PREFIX})
SET(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
SET(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
SET(CC ${CMAKE_C_COMPILER})
SET(FC ${CMAKE_Fortran_COMPILER})

configure_file(
${CMAKE_SOURCE_DIR}/netcdf-fortran.pc.in
${CMAKE_BINARY_DIR}/netcdf-fortran.pc @ONLY)

INSTALL(FILES ${CMAKE_BINARY_DIR}/netcdf-fortran.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT utilities)

INSTALL(PROGRAMS ${NC4F_BINARY_DIR}/nf-config
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT utilities)

# End autotools-style checks for config.h

# Recurse into other subdirectories.
Expand Down Expand Up @@ -1165,14 +1145,35 @@ INSTALL(FILES "${CMAKE_BINARY_DIR}/libnetcdff.settings"
# End libnetcdff.settings section.
#####

# Generate nf-config form template.
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/nf-config.cmake.in"
# Set variables used in nf-config and pkgconfig templates
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
set(fmoddir "${CMAKE_INSTALL_PREFIX}/${Fortran_INSTALL_MODDIR}")
set(CC "${CMAKE_C_COMPILER}")
set(FC "${CMAKE_Fortran_COMPILER}")
set(CPPFLAGS "${CMAKE_C_FLAGS} ${CMAKE_CPP_FLAGS}")

# Generate nf-config from template
configure_file("${CMAKE_SOURCE_DIR}/nf-config.in"
"${CMAKE_BINARY_DIR}/tmp/nf-config" @ONLY
NEWLINE_STYLE LF)
FILE(COPY "${CMAKE_BINARY_DIR}/tmp/nf-config"
file(COPY "${CMAKE_BINARY_DIR}/tmp/nf-config"
DESTINATION ${CMAKE_BINARY_DIR}/
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

configure_file(
${CMAKE_SOURCE_DIR}/netcdf-fortran.pc.in
${CMAKE_BINARY_DIR}/netcdf-fortran.pc @ONLY)

install(FILES ${CMAKE_BINARY_DIR}/netcdf-fortran.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT utilities)

install(PROGRAMS ${NC4F_BINARY_DIR}/nf-config
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT utilities)

include(CMakePackageConfigHelpers)

Expand Down
133 changes: 0 additions & 133 deletions nf-config.cmake.in

This file was deleted.

0 comments on commit b84141a

Please sign in to comment.