Skip to content

Commit

Permalink
improve libpio settings output from cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Jul 24, 2020
1 parent f6ad7c5 commit 5dc5719
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,8 @@ SET(abs_top_builddir "${CMAKE_CURRENT_BINARY_DIR}")
SET(abs_top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")

SET(CC_VERSION "${CMAKE_C_COMPILER}")

# Build *FLAGS for libpio.settings.
SET(CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}")
SET(CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${CMAKE_BUILD_TYPE}}")
SET(FC_VERSION "${CMAKE_Fortran_COMPILER}")
# Build *FLAGS for libpio.settings. (CFLAGS, CPPFLAGS, FFLAGS promoted from src)
SET(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE}}")

is_disabled(BUILD_SHARED_LIBS enable_static)
Expand Down
4 changes: 3 additions & 1 deletion libpio.settings.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ Shared Library: @enable_shared@
Static Library: @enable_static@
Extra libraries: @LIBS@

Fortran Compiler: @FC_VERSION@
FFLAGS: @FFLAGS@

# Features
--------
PnetCDF Support: @HAS_PNETCDF@
SZIP Write Support: @HAS_SZIP_WRITE@
Parallel Filters: @HAS_PAR_FILTERS@

4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ endif ()

# Build the C library
add_subdirectory (clib)
set(CFLAGS ${CFLAGS} PARENT_SCOPE)
set(CPPFLAGS ${CPPFLAGS} PARENT_SCOPE)


# Build the Fortran library
if (PIO_ENABLE_FORTRAN)
add_subdirectory (flib)
set(FFLAGS ${FFLAGS} PARENT_SCOPE)
endif ()
16 changes: 8 additions & 8 deletions src/clib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ target_compile_definitions (pioc

# Compiler-specific compiler options
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
target_compile_options (pioc
PRIVATE -std=c99)
list(INSERT CMAKE_C_FLAGS 0 "-std=c99 ")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "PGI")
target_compile_options (pioc
PRIVATE -c99)
list(INSERT CMAKE_C_FLAGS 0 "-c99 ")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
target_compile_options (pioc
PRIVATE -std=c99 -debug minimal)
list(INSERT CMAKE_C_FLAGS 0 "-std=c99 -debug minimal")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
target_compile_options (pioc
PRIVATE -std=c99)
list(INSERT CMAKE_C_FLAGS 0 "-std=c99 ")
endif()
target_compile_options (pioc PRIVATE ${CMAKE_C_FLAGS})

#==============================================================================
# DEFINE THE INSTALL
Expand Down Expand Up @@ -161,3 +158,6 @@ CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
if (NOT ${SIZEOF_SIZE_T} EQUAL ${SIZEOF_LONG_LONG})
message (FATAL_ERROR "size_t and long long must be the same size!")
endif ()

set(CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}" PARENT_SCOPE)
set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${CMAKE_BUILD_TYPE}}" PARENT_SCOPE)
1 change: 1 addition & 0 deletions src/flib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,4 @@ endif ()
if (NOT PnetCDF_Fortran_FOUND AND NOT NetCDF_Fortran_FOUND)
message (FATAL_ERROR "Must have PnetCDF and/or NetCDF Fortran libraries")
endif ()
set(FFLAGS ${CMAKE_Fortran_FLAGS} PARENT_SCOPE)

0 comments on commit 5dc5719

Please sign in to comment.