diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index c0281e09..c37fcec1 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -14,37 +14,36 @@ add_subdirectory(gctpc) # with -DCALLABLE_WGRIB2 add_library(obj_lib OBJECT ${lib_src}) target_compile_definitions(obj_lib PUBLIC ${definitions_list}) -target_link_libraries(obj_lib PRIVATE gctpc) # with -DCALLABLE_WGRIB2 for the lib add_library(wgrib2_lib $ ${callable_src}) +# library and executable have same name (wgrib2) but different target names set_target_properties(wgrib2_lib PROPERTIES OUTPUT_NAME wgrib2) + target_compile_definitions(wgrib2_lib PRIVATE CALLABLE_WGRIB2) -target_link_libraries(wgrib2_lib PUBLIC gctpc) # without -DCALLABLE_WGRIB2 for the executable add_executable(wgrib2_exe $ ${callable_src}) set_target_properties(wgrib2_exe PROPERTIES OUTPUT_NAME wgrib2) -target_link_libraries(wgrib2_exe PRIVATE gctpc) if(USE_NETCDF4) - target_link_libraries(wgrib2_lib PUBLIC NetCDF::NetCDF_C) - target_link_libraries(wgrib2_exe PUBLIC NetCDF::NetCDF_C) + target_link_libraries(obj_lib PUBLIC NetCDF::NetCDF_C) + target_link_libraries(wgrib2_exe PRIVATE NetCDF::NetCDF_C) endif() if(USE_JASPER) target_include_directories(obj_lib PUBLIC ${JASPER_INCLUDE_DIR}) + target_link_libraries(obj_lib PUBLIC ${JASPER_LIBRARIES}) target_link_libraries(wgrib2_exe PRIVATE ${JASPER_LIBRARIES}) - target_link_libraries(wgrib2_lib PUBLIC ${JASPER_LIBRARIES}) endif() if(USE_PNG) target_link_libraries(obj_lib PUBLIC PNG::PNG) target_link_libraries(wgrib2_exe PRIVATE PNG::PNG) - target_link_libraries(wgrib2_lib PUBLIC PNG::PNG) endif() if(OpenMP_FOUND) + target_link_libraries(obj_lib PUBLIC OpenMP::OpenMP_C) target_link_libraries(wgrib2_exe PRIVATE OpenMP::OpenMP_C) endif() @@ -56,10 +55,10 @@ endif() if(USE_IPOLATES EQUAL 3) target_link_libraries(obj_lib PUBLIC ip2::ip2_d) - target_link_libraries(wgrib2_exe PUBLIC ip2::ip2_d) - target_link_libraries(wgrib2_lib PUBLIC ip2::ip2_d) endif() +target_link_libraries(obj_lib PUBLIC gctpc) +target_link_libraries(wgrib2_exe PRIVATE gctpc) install( TARGETS wgrib2_lib wgrib2_exe