Skip to content
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

Use consistent nf-config.in template for both CMake/autotools #434

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.