Skip to content

Commit

Permalink
cmake changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA committed Feb 28, 2025
1 parent 1aaaa0c commit e44bcb0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ configure_file("${PROJECT_SOURCE_DIR}/wgrib2/config.h.in" "${CMAKE_CURRENT_BINAR
include_directories(${CMAKE_CURRENT_BINARY_DIR})

message(STATUS "Adding wgrib2, aux_probs subdirectories...")

if (BUILD_EXTRA)
add_subdirectory(extra)
endif()

add_subdirectory(wgrib2)
add_subdirectory(aux_progs)

Expand Down
16 changes: 15 additions & 1 deletion extra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@

set(src Mysql.c Mysql_dump.c Mysql_speed.c)

include_directories(../wgrib2/)

add_library(wgrib2_extra OBJECT ${src})
target_compile_definitions(wgrib2_extra PUBLIC ${definitions_list})

if (BUILD_LIB)
set_property(TARGET wgrib2_extra PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
endif()

target_include_directories(wgrib2_extra PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}>)

install(
TARGETS wgrib2_extra
EXPORT wgrib2_exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
8 changes: 8 additions & 0 deletions wgrib2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ if(USE_PNG)
endif()
endif()

if (BUILD_EXTRA)
target_link_libraries(obj_lib PRIVATE wgrib2_extra)
target_link_libraries(wgrib2_exe PRIVATE wgrib2_extra)
if(BUILD_LIB)
target_link_libraries(wgrib2_lib PRIVATE wgrib2_extra)
endif()
endif()

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

0 comments on commit e44bcb0

Please sign in to comment.