From e44bcb061f93ff95ec8c0f7db84dc2783c7d5b5d Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:44:43 -0800 Subject: [PATCH] cmake changes --- CMakeLists.txt | 5 +++++ extra/CMakeLists.txt | 16 +++++++++++++++- wgrib2/CMakeLists.txt | 8 ++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fb4f979..8bce8025 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index 0fc798ab..f03b20c1 100644 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -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() \ No newline at end of file +endif() + +target_include_directories(wgrib2_extra PUBLIC + $ + $) + +install( + TARGETS wgrib2_extra + EXPORT wgrib2_exports + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) \ No newline at end of file diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index b190dbe9..8df49c82 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -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)