Skip to content

Commit

Permalink
some cleanup to build file + debug libaec error
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA committed Feb 11, 2025
1 parent 5706c37 commit 7e59568
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
ccompiler: [gcc-12, gcc-14, clang]
jasper-version: [4.0.0]
openmp: [ ON, OFF ]
sharedlib: [ ON, OFF ]

steps:
- name: install-dependencies
Expand Down Expand Up @@ -55,6 +56,6 @@ jobs:
cd wgrib2
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip" .. -DUSE_AEC=ON -DUSE_PNG=ON -DUSE_JASPER=ON -DBUILD_SHARED_LIB=ON -DBUILD_LIB=ON -DMAKE_FTN_API=ON -DUSE_OPENMP=${{matrix.openmp}}
cmake -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip" .. -DUSE_AEC=ON -DUSE_PNG=ON -DUSE_JASPER=ON -DBUILD_SHARED_LIB=${{matrix.sharedlib}} -DBUILD_LIB=ON -DMAKE_FTN_API=ON -DUSE_OPENMP=${{matrix.openmp}}
make VERBOSE=1
ctest --verbose --output-on-failure --rerun-failed
17 changes: 11 additions & 6 deletions wgrib2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,20 @@ if(BUILD_LIB)
# target_compile_definitions(wgrib2_lib PRIVATE CALLABLE_WGRIB2)
endif()


add_executable(wgrib2_exe wgrib2_main.c)
set_target_properties(wgrib2_exe PROPERTIES OUTPUT_NAME wgrib2)

if(USE_NETCDF)
target_link_libraries(obj_lib PUBLIC NetCDF::NetCDF_C)
if(BUILD_SHARED_LIB)
if(BUILD_LIB)
target_link_libraries(wgrib2_lib PUBLIC NetCDF::NetCDF_C)
endif()
target_link_libraries(wgrib2_exe PUBLIC NetCDF::NetCDF_C)
endif()

if(USE_OPENMP)
target_link_libraries(obj_lib PUBLIC OpenMP::OpenMP_C)
if(BUILD_SHARED_LIB)
if(BUILD_LIB)
target_link_libraries(wgrib2_lib PUBLIC OpenMP::OpenMP_C)
endif()
endif()
Expand All @@ -118,6 +117,9 @@ if(USE_IPOLATES)
target_link_libraries(obj_lib PUBLIC ip::ip_d)
target_link_libraries(wgrib2_exe PUBLIC ip::ip_d)

if(BUILD_LIB)
target_link_libraries(wgrib2_lib PUBLIC ip::ip_d)
endif()
# Link to the Fortran runtime library for each compiler if using ip2.
# The wgrib2 exectuable is created using the C compiler and
# doesn't link the necessary Fortran library required for ip2.
Expand All @@ -129,22 +131,25 @@ if(USE_IPOLATES)

endif()

## target_link_libraries(obj_lib PUBLIC gctpc -lm)

# Link to gctpc directly because object libraries do not link transitively
target_link_libraries(wgrib2_exe PRIVATE gctpc -lm)

if(USE_AEC)
if(BUILD_LIB)
target_link_libraries(wgrib2_lib PUBLIC ${LIBAEC_LIBRARIES})
endif()
target_link_libraries(wgrib2_exe PRIVATE ${LIBAEC_LIBRARIES})
endif()

if(USE_JASPER OR USE_OPENJPEG OR USE_PNG)
target_link_libraries(obj_lib PUBLIC g2c::g2c)
if(BUILD_LIB)
target_link_libraries(wgrib2_lib PUBLIC g2c::g2c)
endif()
target_link_libraries(wgrib2_exe PRIVATE g2c::g2c)
endif()

target_link_libraries(wgrib2_exe PRIVATE obj_lib)
# target_link_libraries(wgrib2_exe PRIVATE wgrib2_lib)

if(BUILD_LIB)
set(headers wgrib2_api.h wgrib2.h ${CMAKE_BINARY_DIR}/wgrib2/wgrib2_meta.h)
Expand Down

0 comments on commit 7e59568

Please sign in to comment.