From cde75737ae9d367282950a1a340f780fb38de34d Mon Sep 17 00:00:00 2001 From: Samuel Felton Date: Tue, 17 Sep 2024 19:14:29 +0200 Subject: [PATCH] First attempt at including the cmake system include dirs functionality in ViSP modules, allowing to ignore 3rd party warnings --- cmake/FindMyPanda3D.cmake | 2 +- cmake/VISPModule.cmake | 7 +++++-- cmake/VISPUtils.cmake | 38 ++++++++++++++++++++++++++++++-------- modules/ar/CMakeLists.txt | 19 +++++-------------- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/cmake/FindMyPanda3D.cmake b/cmake/FindMyPanda3D.cmake index 22bbde66c8..fff1399d55 100644 --- a/cmake/FindMyPanda3D.cmake +++ b/cmake/FindMyPanda3D.cmake @@ -83,7 +83,7 @@ foreach(lib_name ${PANDA3D_LIBS}) endforeach() find_path(Panda3D_INCLUDE_DIRS panda.h PATHS ${PANDA3D_INCLUDE_SEARCH_PATHS}) -message(${Panda3D_INCLUDE_DIRS}) + include(FindPackageHandleStandardArgs) # Handle the QUIETLY and REQUIRED arguments and set the Panda3D_FOUND to TRUE # if all listed variables are TRUE diff --git a/cmake/VISPModule.cmake b/cmake/VISPModule.cmake index 0089104ad9..21d5365880 100644 --- a/cmake/VISPModule.cmake +++ b/cmake/VISPModule.cmake @@ -586,15 +586,18 @@ endfunction() # setup include paths for the list of passed modules macro(vp_target_include_modules target) + set(is_system "") foreach(d ${ARGN}) - if(d MATCHES "^visp_" AND HAVE_${d}) + if("${d}" STREQUAL "SYSTEM") + set(is_system "SYSTEM") + elseif(d MATCHES "^visp_" AND HAVE_${d}) if (EXISTS "${VISP_MODULE_${d}_LOCATION}/include") vp_target_include_directories(${target} "${VISP_MODULE_${d}_LOCATION}/include") endif() elseif(EXISTS "${d}") # FS keep external deps inc set(VISP_MODULE_${the_module}_INC_DEPS "${VISP_MODULE_${the_module}_INC_DEPS};${d}" CACHE INTERNAL "") - vp_target_include_directories(${target} "${d}") + vp_target_include_directories(${target} "${is_system}" "${d}") endif() endforeach() vp_list_unique(VISP_MODULE_${the_module}_INC_DEPS) diff --git a/cmake/VISPUtils.cmake b/cmake/VISPUtils.cmake index 6207c74f0f..b4cc098e8d 100644 --- a/cmake/VISPUtils.cmake +++ b/cmake/VISPUtils.cmake @@ -182,18 +182,26 @@ endfunction() # adds include directories in such way that directories from the ViSP source tree go first function(vp_target_include_directories target) set(__params "") + set(__system_params "") + set(__var_name __params) + foreach(dir ${ARGN}) - get_filename_component(__abs_dir "${dir}" ABSOLUTE) - string(REPLACE "+" "\\+" __VISP_BINARY_DIR_filtered ${VISP_BINARY_DIR}) -# if("${__abs_dir}" MATCHES "^${VISP_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${__VISP_BINARY_DIR_filtered}") # not compatible with cmake 2.8.12.2 - if("${__abs_dir}" MATCHES "^${VISP_SOURCE_DIR}") - list(APPEND __params "${__abs_dir}") - elseif("${__abs_dir}" MATCHES "^${__VISP_BINARY_DIR_filtered}") - list(APPEND __params "${__abs_dir}") + if("${dir}" STREQUAL "SYSTEM") + set(__var_name __system_params) else() - list(APPEND __params "${dir}") + get_filename_component(__abs_dir "${dir}" ABSOLUTE) + string(REPLACE "+" "\\+" __VISP_BINARY_DIR_filtered ${VISP_BINARY_DIR}) + # if("${__abs_dir}" MATCHES "^${VISP_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${__VISP_BINARY_DIR_filtered}") # not compatible with cmake 2.8.12.2 + if("${__abs_dir}" MATCHES "^${VISP_SOURCE_DIR}") + list(APPEND ${__var_name} "${__abs_dir}") + elseif("${__abs_dir}" MATCHES "^${__VISP_BINARY_DIR_filtered}") + list(APPEND ${__var_name} "${__abs_dir}") + else() + list(APPEND ${__var_name} "${dir}") + endif() endif() endforeach() + if(__params) if(TARGET ${target}) target_include_directories(${target} PRIVATE ${__params}) @@ -202,6 +210,16 @@ function(vp_target_include_directories target) set(VP_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "") endif() endif() + if(__system_params) + if(TARGET ${target}) + target_include_directories(${target} SYSTEM PRIVATE ${__system_params}) + else() + set(__new_inc ${VP_TARGET_INCLUDE_SYSTEM_DIRS_${target}}) + list(APPEND __new_inc ${__system_params}) + set(VP_TARGET_INCLUDE_SYSTEM_DIRS_${target} "${__new_inc}" CACHE INTERNAL "") + endif() + endif() + endfunction() # clears all passed variables @@ -780,6 +798,10 @@ function(_vp_append_target_includes target) target_include_directories(${target} PRIVATE ${VP_TARGET_INCLUDE_DIRS_${target}}) unset(VP_TARGET_INCLUDE_DIRS_${target} CACHE) endif() + if(DEFINED VP_TARGET_INCLUDE_SYSTEM_DIRS_${target}) + target_include_directories(${target} SYSTEM PRIVATE ${VP_TARGET_INCLUDE_SYSTEM_DIRS_${target}}) + unset(VP_TARGET_INCLUDE_SYSTEM_DIRS_${target} CACHE) + endif() endfunction() function(vp_add_executable target) diff --git a/modules/ar/CMakeLists.txt b/modules/ar/CMakeLists.txt index 4185627be7..cee2716121 100644 --- a/modules/ar/CMakeLists.txt +++ b/modules/ar/CMakeLists.txt @@ -35,6 +35,8 @@ # Add optional 3rd parties set(opt_incs "") +set(opt_system_incs "") + set(opt_libs "") if(USE_OGRE) @@ -175,7 +177,8 @@ endif() if(USE_PANDA3D) if(Panda3D_INCLUDE_DIRS) - list(APPEND opt_incs ${Panda3D_INCLUDE_DIRS}) + #vp_module_include_directories(SYSTEM ${Panda3D_INCLUDE_DIRS}) + list(APPEND opt_system_incs ${Panda3D_INCLUDE_DIRS}) endif() if(Panda3D_LIBRARIES) list(APPEND opt_libs ${Panda3D_LIBRARIES}) @@ -190,17 +193,5 @@ if(USE_OGRE) vp_set_source_file_compile_flag(src/ogre-simulator/vpAROgre.cpp -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-overloaded-virtual -Wno-float-equal -Wno-deprecated-copy -Wno-register) endif() -if(USE_PANDA3D) - set(PANDA3D_CXX_FLAGS -Wno-unused-parameter -Wno-unused-variable -Wno-extra -Wno-reorder-ctor) - set(PANDA3D_MODULE_SOURCES - vpPanda3DBaseRenderer.cpp vpPanda3DGeometryRenderer.cpp - vpPanda3DRGBRenderer.cpp vpPanda3DRenderParameters.cpp - vpPanda3DRendererSet.cpp vpPanda3DPostProcessFilter.cpp vpPanda3DCommonFilters.cpp - ) - foreach(panda_src_name ${PANDA3D_MODULE_SOURCES}) - vp_set_source_file_compile_flag(src/panda3d-simulator/${panda_src_name} ${PANDA3D_CXX_FLAGS}) - endforeach() -endif() - -vp_module_include_directories(${opt_incs}) +vp_module_include_directories(${opt_incs} SYSTEM ${opt_system_incs}) vp_create_module(${opt_libs})