NOAA-EMC / NCEPLIBS-g2c

This library contains C decoder/encoder routines for GRIB edition 2.
Other
17 stars 11 forks source link

AEC_INCLUDE_DIRS is undefined in src/CMakeLists.txt #492

Closed DusanJovic-NOAA closed 3 weeks ago

DusanJovic-NOAA commented 2 months ago

Include directories for libaec are specified by using variable AEC_INCLUDE_DIRS:

./src/CMakeLists.txt:147:  target_include_directories(${lib_name}_objlib PRIVATE "${AEC_INCLUDE_DIRS}")
./src/CMakeLists.txt:151:    target_include_directories(${lib_name}_shared PRIVATE "${AEC_INCLUDE_DIRS}")
./src/CMakeLists.txt:155:    target_include_directories(${lib_name}_static PRIVATE "${AEC_INCLUDE_DIRS}")

but AEC_INCLUDE_DIRS is undefined, probably a typo (AEC_INCLUDE_DIR is defined). Find module sets LIBAEC_INCLUDE_DIRS and LIBAEC_LIBRARIES and these two variables should be used. There is no need to introduce local variables with the same values, for example:

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3b3a831..dbae0c7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -135,24 +135,22 @@ endif()

 # Build with AEC.
 if(LIBAEC_FOUND)
-  set(AEC_LIBRARIES ${LIBAEC_LIBRARIES})
-  set(AEC_INCLUDE_DIR ${LIBAEC_INCLUDE_DIRS})
-  message(STATUS "AEC include directories ${AEC_INCLUDE_DIR}")
-  message(STATUS "AEC libraries ${AEC_LIBRARIES}")
+  message(STATUS "AEC include directories ${LIBAEC_INCLUDE_DIRS}")
+  message(STATUS "AEC libraries ${LIBAEC_LIBRARIES}")
   target_sources(${lib_name}_objlib PRIVATE decenc_aec.c
                                             aecpack.c
                                             aecunpack.c)
   target_compile_definitions(${lib_name}_objlib PRIVATE USE_AEC)
-  target_link_libraries(${lib_name}_objlib PRIVATE ${AEC_LIBRARIES})
-  target_include_directories(${lib_name}_objlib PRIVATE "${AEC_INCLUDE_DIRS}")
+  target_link_libraries(${lib_name}_objlib PRIVATE ${LIBAEC_LIBRARIES})
+  target_include_directories(${lib_name}_objlib PRIVATE "${LIBAEC_INCLUDE_DIRS}")
   set(G2_AEC_ENABLED ON)
   if(BUILD_SHARED_LIBS)
-    target_link_libraries(${lib_name}_shared PRIVATE ${AEC_LIBRARIES})
-    target_include_directories(${lib_name}_shared PRIVATE "${AEC_INCLUDE_DIRS}")
+    target_link_libraries(${lib_name}_shared PRIVATE ${LIBAEC_LIBRARIES})
+    target_include_directories(${lib_name}_shared PRIVATE "${LIBAEC_INCLUDE_DIRS}")
   endif()
   if(BUILD_STATIC_LIBS)
-    target_link_libraries(${lib_name}_static PRIVATE ${AEC_LIBRARIES})
-    target_include_directories(${lib_name}_static PRIVATE "${AEC_INCLUDE_DIRS}")
+    target_link_libraries(${lib_name}_static PRIVATE ${LIBAEC_LIBRARIES})
+    target_include_directories(${lib_name}_static PRIVATE "${LIBAEC_INCLUDE_DIRS}")
   endif()
 endif()
edwardhartnett commented 1 month ago

Is AEC working now? If so, this issue can be closed.