From cb6dea41701c057982a03c69ab18df04169cdc59 Mon Sep 17 00:00:00 2001 From: Oliver Heidmann <oliver.heidmann@mpimet.mpg.de> Date: Thu, 6 Feb 2025 09:02:54 +0100 Subject: [PATCH] Main CMakeLists.txt cleanup - removed forced out of source build - removed global setting of HAVE_NETCDF - HAVE_NETCDF now added to list of cdo_compile_definitions - replaced bloated property printing by cmake inbuild features --- CMakeLists.txt | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df12a45f4..4be38d46f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,9 +38,12 @@ ELSE() ENDIF() ### -------------- proj --------------------------- -find_package(PROJ) -if(PROJ4::proj) - list(APPEND cdo_compile_defintions ${HAVE_PROJ}) +option(ENABLE_PROJ "Enable projection library, use -DPROJ_ROOT for specific path" OFF) +if(ENABLE_PROJ OR PROJ_ROOT) + find_package(PROJ) + if(PROJ4::proj) + list(APPEND cdo_compile_defintions HAVE_PROJ=${PROJ_FOUND}) + endif() endif() ### -------------- fftw3 --------------------------- @@ -63,16 +66,10 @@ endif() ### -------------- NETCDF --------------------------- message("Start check for netCDF4") find_package(netCDF 4.0 REQUIRED) -set(netcdf_flag HAVE_LIBNETCDF) if (TARGET netCDF::netcdf) message(DEBUG "Checking for netCDF_HAS_NC4 flag equal 'yes' : flag is: ${netCDF_HAS_NC4}") - if(NOT "${netCDF_HAS_NC4}" STREQUAL "yes") - message(WARNING "NetCDF4 installation does not support nc4") - endif() - - list(APPEND cdo_compile_defintions ${netcdf_flag}=${netCDF_FOUND}) - + list(APPEND cdo_compile_defintions HVAE_NETCDF=${netCDF_FOUND}) else() message(WARNING "Netcdf not found, compiling without netcdf") endif () @@ -101,27 +98,8 @@ add_subdirectory( libcdi) add_subdirectory( src ) add_subdirectory( test ) -#use this to print all variables set to true - -message("STATUS:") -get_property(target_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY IMPORTED_TARGETS) -foreach(_target ${target_names}) - message(STATUS "${_target}") - get_target_property(_imported_location ${_target} IMPORTED_LOCATION) - get_target_property(_imported_incl_dirs ${_target} INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(_interface_link_lib ${_target} INTERFACE_LINK_LIBRARIES) - message(STATUS " include paths: ${_imported_incl_dirs}") - if(_imported_location) - message(STATUS " linker target: ${_imported_location}") - endif() - if(_interface_link_lib) - message(STATUS " interf_li_lib: ${_interface_link_lib}") - endif() -endforeach() -if(FALSE) - get_cmake_property(_variableNames VARIABLES) - list (SORT _variableNames) - foreach (_variableName ${_variableNames}) - message(VERBOSE "${_variableName}=${${_variableName}}") - endforeach() +if(TRUE) + cmake_print_properties(TARGETS cdo cdolib operators PROPERTIES INTERFACE_LINK_LIBRARIES LINK_LIBRARIES) + get_property(target_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY IMPORTED_TARGETS) + cmake_print_properties(TARGETS ${target_names} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES) endif() -- GitLab