Skip to content

Commit

Permalink
Merge pull request #170 from NOAA-EMC/ejh_shared_1_31
Browse files Browse the repository at this point in the history
build with shared, also handle extra dependencies on NCEPLIBS-bufr and mystery libraries
  • Loading branch information
edwardhartnett authored Feb 28, 2023
2 parents 34c1f52 + c36bd62 commit f290fe3
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 15 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/Intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,29 @@ jobs:
make -j2
make install
- name: checkout-bufr
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-bufr
path: bufr
ref: bufr_v11.7.1

- name: cache-bufr
id: cache-bufr
uses: actions/cache@v2
with:
path: ~/bufr
key: bufr-Linux_options_${{ runner.os }}-v11.7.1

- name: build-bufr
if: steps.cache-bufr.outputs.cache-hit != 'true'
run: |
cd bufr
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/bufr ..
make -j2
make install
- name: checkout
uses: actions/checkout@v2
with:
Expand All @@ -64,7 +87,7 @@ jobs:
run: |
cd w3emc
mkdir build && cd build
cmake .. -DOPENMP=ON -DCMAKE_PREFIX_PATH=~/bacio
cmake -DOPENMP=ON -DCMAKE_PREFIX_PATH="~/bacio;~/bufr" ..
make -j2
- name: test-w3emc
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/Linux_options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
CC: gcc-11
strategy:
matrix:
options: [-DBUILD_D=OFF, -DBUILD_4=OFF]
options: [-DBUILD_D=OFF, -DBUILD_4=OFF, '-D-DBUILD_SHARED_LIBS=ON -DBUILD_WITH_BUFR=OFF -DBUILD_WITH_EXTRA_DEPS=OFF']

steps:

Expand All @@ -47,6 +47,29 @@ jobs:
make -j2
make install
- name: checkout-bufr
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-bufr
path: bufr
ref: bufr_v11.7.1

- name: cache-bufr
id: cache-bufr
uses: actions/cache@v2
with:
path: ~/bufr
key: bufr-Linux_options_${{ runner.os }}-v11.7.1

- name: build-bufr
if: steps.cache-bufr.outputs.cache-hit != 'true'
run: |
cd bufr
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/bufr ..
make -j2
make install
- name: checkout-w3emc
uses: actions/checkout@v2
with:
Expand All @@ -57,7 +80,7 @@ jobs:
cd w3emc
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=~/bacio ${{ matrix.options }} ..
cmake -DCMAKE_PREFIX_PATH="~/bacio;~/bufr" ${{ matrix.options }} ..
make -j2
- name: test-w3emc
Expand Down
25 changes: 24 additions & 1 deletion .github/workflows/Linux_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ jobs:
make -j2
make install
- name: checkout-bufr
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-bufr
path: bufr
ref: bufr_v11.7.1

- name: cache-bufr
id: cache-bufr
uses: actions/cache@v2
with:
path: ~/bufr
key: bufr-Linux_options_${{ runner.os }}-v11.7.1

- name: build-bufr
if: steps.cache-bufr.outputs.cache-hit != 'true'
run: |
cd bufr
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/bufr ..
make -j2
make install
- name: checkout-w3emc
uses: actions/checkout@v2
with:
Expand All @@ -58,7 +81,7 @@ jobs:
cd w3emc
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=~/bacio
cmake -DCMAKE_PREFIX_PATH="~/bacio;~/bufr" ..
make -j2
- name: test-w3emc
Expand Down
25 changes: 24 additions & 1 deletion .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ jobs:
make -j2
make install
- name: checkout-bufr
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-bufr
path: bufr
ref: bufr_v11.7.1

- name: cache-bufr
id: cache-bufr
uses: actions/cache@v2
with:
path: ~/bufr
key: bufr-Linux_options_${{ runner.os }}-v11.7.1

- name: build-bufr
if: steps.cache-bufr.outputs.cache-hit != 'true'
run: |
cd bufr
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/bufr ..
make -j2
make install
- name: checkout-w3emc
uses: actions/checkout@v2
with:
Expand All @@ -56,7 +79,7 @@ jobs:
cd w3emc
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=~/bacio ..
cmake -DCMAKE_PREFIX_PATH="~/bacio;~/bufr" ..
make -j2
- name: test-w3emc
Expand Down
25 changes: 24 additions & 1 deletion .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@ jobs:
make -j2
make install
- name: checkout-bufr
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-bufr
path: bufr
ref: bufr_v11.7.1

- name: cache-bufr
id: cache-bufr
uses: actions/cache@v2
with:
path: ~/bufr
key: bufr-Linux_options_${{ runner.os }}-v11.7.1

- name: build-bufr
if: steps.cache-bufr.outputs.cache-hit != 'true'
run: |
cd bufr
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/bufr ..
make -j2
make install
- name: checkout-w3emc
uses: actions/checkout@v2
with:
Expand All @@ -54,7 +77,7 @@ jobs:
cd w3emc
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="~/;~/bacio" -DENABLE_DOCS=ON -DCMAKE_Fortran_FLAGS="-g -fprofile-arcs -ftest-coverage -O0 -fsanitize=address -Wall" -DCMAKE_BUILD_TYPE=Debug ..
cmake -DCMAKE_PREFIX_PATH="~/;~/bacio;~/bufr" -DENABLE_DOCS=ON -DCMAKE_Fortran_FLAGS="-g -fprofile-arcs -ftest-coverage -O0 -fsanitize=address -Wall" -DCMAKE_BUILD_TYPE=Debug ..
make -j2
- name: test-w3emc
Expand Down
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ project(w3emc VERSION ${pVersion} LANGUAGES C Fortran)

# Handle user options.
option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(BUILD_4 "Build the 4-byte real version of the library, libw3emc_4.a" ON)
option(BUILD_D "Build the 8-byte real version of the library, libw3emc_d.a" ON)
option(BUILD_TESTING "Build tests of the library" ON)
option(BUILD_WITH_EXTRA_DEPS "Build w3emc with subprograms which call unknown dependencies" ON)
option(BUILD_WITH_BUFR "Build w3emc with subprograms which call NCEPLIBS-bufr" ON)

# If building shared, extra dependencies must be eliminated.
if(BUILD_SHARED_LIBS)
if(BUILD_WITH_EXTRA_DEPS)
message(FATAL_ERROR "Shared libraries cannot be built without setting -DBUILD_WITH_EXTRA_DEPS=OFF.")
endif()
endif()

# Figure whether user wants a _4, a _d, or both libraries.
if(BUILD_4 AND BUILD_D)
Expand All @@ -38,9 +48,14 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

# Bacio is required.
# NCEPLIBS-bacio is required.
find_package(bacio 2.4.0 REQUIRED)

# NCEPLIBS-bufr may be required.
if(BUILD_WITH_BUFR)
find_package(bufr REQUIRED)
endif()

# The name of the bacio library changed with NCEPLIBS-bacio-2.5.0.
if(bacio_VERSION GREATER_EQUAL 2.5.0)
set(bacio_name bacio)
Expand Down
4 changes: 4 additions & 0 deletions cmake/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ check_required_components("@PROJECT_NAME@")

find_dependency(bacio)

if(@BUILD_WITH_BUFR@)
find_dependency(bufr)
endif()

get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@_4 LOCATION)
message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"@PROJECT_VERSION@\")")
34 changes: 26 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,64 @@
# Kyle Gerheiser, Ed Hartnett

# This is the Fortran source code.
set(fortran_src args_mod.f getgbens.f isrchne.f iw3mat.f
set(fortran_src getgbens.f isrchne.f iw3mat.f
mersenne_twister.f mova2i.f orders.f putgbens.f w3ai40.f w3ai41.f
w3ctzdat.f w3fa01.f w3fa03.f w3fa03v.f w3fa04.f w3fa06.f w3fa09.f
w3fa11.f w3fa12.f w3fa13.f w3fb00.f w3fb01.f w3fb02.f w3fb03.f
w3fb04.f w3fb05.f w3fb06.f w3fb07.f w3fb08.f w3fb09.f w3fb10.f
w3fb11.f w3fb12.f w3fc02.f w3fc05.f w3fc06.f w3fc07.f w3fc08.f
w3fi02.f w3fi03.f w3fi18.f w3fi19.f w3fi20.f w3fi32.f w3fi47.f
w3fi48.f w3fi52.f w3fi61.f w3fi65.f w3fi66.f w3fi67.f w3fi70.f
w3fi48.f w3fi61.f w3fi65.f w3fi66.f w3fi67.f w3fi70.f
w3fi78.f w3fi85.f w3fm07.f w3fm08.f w3fp04.f w3fp05.f w3fp06.f
w3fp10.f w3fq07.f w3ft00.f w3ft01.f w3ft02.f w3ft03.f w3ft05.f
w3fp10.f w3ft00.f w3ft01.f w3ft02.f w3ft03.f w3ft05.f
w3ft05v.f w3ft06.f w3ft06v.f w3ft07.f w3ft08.f w3ft09.f w3ft10.f
w3ft11.f w3ft12.f w3ft16.f w3ft17.f w3ft201.f w3ft202.f w3ft203.f
w3ft204.f w3ft205.f w3ft206.f w3ft207.f w3ft208.f w3ft209.f w3ft210.f
w3ft211.f w3ft212.f w3ft213.f w3ft214.f w3ft21.f w3ft26.f w3ft33.f
w3ft38.f w3ft39.f w3ft40.f w3ft41.f w3ft43v.f w3log.f w3miscan.f
w3ft38.f w3ft39.f w3ft40.f w3ft41.f w3ft43v.f w3log.f
xdopen.f aea.f errexit.f errmsg.f fparsei.f fparser.f gbytec.f gbyte.f
gbytesc.f gbytes.f getbit.f getgb1.f getgb1re.f getgb1r.f getgb1s.f
getgbe.f getgbeh.f getgbem.f getgbemh.f getgbemn.f getgbemp.f
getgbep.f getgbex.f getgbexm.f getgb.f getgbh.f getgbm.f getgbmh.f
getgbmp.f getgbp.f getgi.f getgir.f gtbits.f idsdef.f instrument.f
iw3jdn.f iw3pds.f iw3unp29.f ixgb.f lengds.f makwmo.f mkfldsep.f
iw3jdn.f iw3pds.f ixgb.f lengds.f makwmo.f mkfldsep.f
pdsens.f pdseup.f putgbe.f putgben.f putgbex.f putgb.f putgbn.f
q9ie32.f r63w72.f sbytec.f sbyte.f sbytesc.f sbytes.f skgb.f w3ai00.f
w3ai01.f w3ai08.f w3ai15.f w3ai18.f w3ai19.f w3ai24.f w3ai38.f
w3ai39.f w3aq15.f w3as00.f w3difdat.f w3doxdat.f w3fi01.f w3fi04.f
w3ai39.f w3aq15.f w3difdat.f w3doxdat.f w3fi01.f w3fi04.f
w3fi58.f w3fi59.f w3fi62.f w3fi63.f w3fi64.f w3fi68.f w3fi69.f
w3fi71.f w3fi72.f w3fi73.f w3fi74.f w3fi75.f w3fi76.f w3fi82.f
w3fi83.f w3fi88.f w3fi92.f w3fp11.f w3fp12.f w3fp13.f w3fs13.f
w3fs15.f w3fs21.f w3fs26.f w3ft32.f w3kind.f w3locdat.f w3movdat.f
w3nogds.f w3pradat.f w3reddat.f w3trnarg.f w3unpk77.f w3utcdat.f
w3nogds.f w3pradat.f w3reddat.f w3trnarg.f w3utcdat.f
w3valdat.f w3ymdh4.f xmovex.f xstore.f w3tagb.f makgds.f90)

# These functions call NCEPLIBS-bufr.
if(BUILD_WITH_BUFR)
set(fortran_src ${fortran_src} w3miscan.f iw3unp29.f w3unpk77.f)
endif()

# These functions call external, mysterious dependencies.
if(BUILD_WITH_EXTRA_DEPS)
set(fortran_src ${fortran_src} args_mod.f w3as00.f w3fi52.f w3fq07.f)
endif()

# This is the C source code.
set(c_src summary.c)

add_library(c_obj_lib OBJECT ${c_src})

# For shared, add fPIC.
if(BUILD_SHARED_LIBS)
set_property(TARGET c_obj_lib PROPERTY POSITION_INDEPENDENT_CODE 1)
endif()

# We buld a _4 and a _d by default.
foreach(kind ${kinds})
set(lib_name ${PROJECT_NAME}_${kind})
set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include_${kind}")

add_library(${lib_name} STATIC ${fortran_src} $<TARGET_OBJECTS:c_obj_lib>)
add_library(${lib_name} ${fortran_src} $<TARGET_OBJECTS:c_obj_lib>)
add_library(${PROJECT_NAME}::${lib_name} ALIAS ${lib_name})

set_target_properties(${lib_name} PROPERTIES COMPILE_FLAGS
Expand All @@ -60,6 +75,9 @@ foreach(kind ${kinds})
list(APPEND LIB_TARGETS ${lib_name})

target_link_libraries(${lib_name} PUBLIC bacio::${bacio_name})
if(BUILD_WITH_BUFR)
target_link_libraries(${lib_name} PUBLIC bufr::bufr_4)
endif()

install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})
endforeach()
Expand Down

0 comments on commit f290fe3

Please sign in to comment.