Skip to content

Commit

Permalink
First attempt at including the cmake system include dirs functionalit…
Browse files Browse the repository at this point in the history
…y in ViSP modules, allowing to ignore 3rd party warnings
  • Loading branch information
SamFlt committed Sep 17, 2024
1 parent b228a6d commit cde7573
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cmake/FindMyPanda3D.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions cmake/VISPModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 30 additions & 8 deletions cmake/VISPUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 5 additions & 14 deletions modules/ar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

# Add optional 3rd parties
set(opt_incs "")
set(opt_system_incs "")

set(opt_libs "")

if(USE_OGRE)
Expand Down Expand Up @@ -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})
Expand All @@ -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})

0 comments on commit cde7573

Please sign in to comment.