From 9cfd329f6f19da5f96364c36ef45f7bf14b0ab61 Mon Sep 17 00:00:00 2001 From: Vitalijus Dobrovolskis Date: Wed, 1 Jun 2022 02:16:43 +0200 Subject: [PATCH 1/3] build: fixed compile/missing include errors in apps --- apps/CMakeLists.txt | 4 +++- apps/DensifyPointCloud/CMakeLists.txt | 2 +- apps/InterfaceCOLMAP/CMakeLists.txt | 2 +- apps/InterfaceMetashape/CMakeLists.txt | 2 +- apps/InterfaceOpenMVG/CMakeLists.txt | 6 ++++-- apps/InterfaceOpenMVG/InterfaceOpenMVG.cpp | 14 ++++++++------ apps/InterfaceVisualSFM/CMakeLists.txt | 2 +- apps/ReconstructMesh/CMakeLists.txt | 2 +- apps/RefineMesh/CMakeLists.txt | 2 +- apps/TextureMesh/CMakeLists.txt | 2 +- apps/Viewer/CMakeLists.txt | 2 +- build/Utils.cmake | 1 - libs/Common/CMakeLists.txt | 1 + 13 files changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index b24044839..51a82810f 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -1,7 +1,9 @@ # Add applications +ADD_SUBDIRECTORY(DensifyPointCloud) ADD_SUBDIRECTORY(InterfaceCOLMAP) ADD_SUBDIRECTORY(InterfaceMetashape) -ADD_SUBDIRECTORY(DensifyPointCloud) +ADD_SUBDIRECTORY(InterfaceOpenMVG) +ADD_SUBDIRECTORY(InterfaceVisualSFM) ADD_SUBDIRECTORY(ReconstructMesh) ADD_SUBDIRECTORY(RefineMesh) ADD_SUBDIRECTORY(TextureMesh) diff --git a/apps/DensifyPointCloud/CMakeLists.txt b/apps/DensifyPointCloud/CMakeLists.txt index 38e27310b..1ac2211be 100644 --- a/apps/DensifyPointCloud/CMakeLists.txt +++ b/apps/DensifyPointCloud/CMakeLists.txt @@ -5,7 +5,7 @@ else() endif() FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl") -cxx_executable_with_flags(DensifyPointCloud "Apps" "${cxx_default}" "MVS;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) +cxx_executable_with_flags(DensifyPointCloud "Apps" "${cxx_default}" "MVS;Common;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) # Install INSTALL(TARGETS DensifyPointCloud diff --git a/apps/InterfaceCOLMAP/CMakeLists.txt b/apps/InterfaceCOLMAP/CMakeLists.txt index 5d48c79ec..9e0ef8a39 100644 --- a/apps/InterfaceCOLMAP/CMakeLists.txt +++ b/apps/InterfaceCOLMAP/CMakeLists.txt @@ -5,7 +5,7 @@ else() endif() FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl") -cxx_executable_with_flags(InterfaceCOLMAP "Apps" "${cxx_default}" "MVS;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) +cxx_executable_with_flags(InterfaceCOLMAP "Apps" "${cxx_default}" "MVS;IO;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) # Install INSTALL(TARGETS InterfaceCOLMAP diff --git a/apps/InterfaceMetashape/CMakeLists.txt b/apps/InterfaceMetashape/CMakeLists.txt index 100e829f5..9c9774641 100644 --- a/apps/InterfaceMetashape/CMakeLists.txt +++ b/apps/InterfaceMetashape/CMakeLists.txt @@ -5,7 +5,7 @@ else() endif() FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl") -cxx_executable_with_flags(InterfaceMetashape "Apps" "${cxx_default}" "MVS;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) +cxx_executable_with_flags(InterfaceMetashape "Apps" "${cxx_default}" "MVS;IO;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) # Install INSTALL(TARGETS InterfaceMetashape diff --git a/apps/InterfaceOpenMVG/CMakeLists.txt b/apps/InterfaceOpenMVG/CMakeLists.txt index 6377497ea..e3c86c2dd 100644 --- a/apps/InterfaceOpenMVG/CMakeLists.txt +++ b/apps/InterfaceOpenMVG/CMakeLists.txt @@ -1,10 +1,12 @@ FIND_PACKAGE(OpenMVG QUIET) IF (OPENMVG_FOUND) + find_package(Ceres REQUIRED) INCLUDE_DIRECTORIES(${OPENMVG_INCLUDE_DIRS}) + add_definitions(-D_USE_OPENMVG) - set(LIBS_DEPEND "MVS;${OPENMVG_LIBRARIES}") + set(LIBS_DEPEND "MVS;Common;OpenMVG::openMVG_sfm;OpenMVG::openMVG_camera;OpenMVG::openMVG_image") ELSE() - set(LIBS_DEPEND "MVS") + set(LIBS_DEPEND "MVS;Common") MESSAGE("OPENMVG_NOT FOUND : OpenMVG importer with JSON support will not be build") ENDIF() diff --git a/apps/InterfaceOpenMVG/InterfaceOpenMVG.cpp b/apps/InterfaceOpenMVG/InterfaceOpenMVG.cpp index edc7ccb81..79b30aa17 100644 --- a/apps/InterfaceOpenMVG/InterfaceOpenMVG.cpp +++ b/apps/InterfaceOpenMVG/InterfaceOpenMVG.cpp @@ -38,7 +38,9 @@ #undef R2D #include #include -#include +#include +#include + #endif @@ -415,7 +417,7 @@ bool Initialize(size_t argc, LPCTSTR* argv) Util::ensureValidPath(OPT::strInputFileName); Util::ensureUnifySlash(OPT::strInputFileName); Util::ensureUnifySlash(OPT::strOutputImageFolder); - Util::ensureDirectorySlash(OPT::strOutputImageFolder); + Util::ensureFolderSlash(OPT::strOutputImageFolder); const String strInputFileNameExt(Util::getFileExt(OPT::strInputFileName).ToLower()); OPT::bOpenMVS2OpenMVG = (strInputFileNameExt == MVS_EXT); #ifdef _USE_OPENMVG @@ -440,10 +442,10 @@ bool Initialize(size_t argc, LPCTSTR* argv) Util::ensureUnifySlash(OPT::strOutputFileName); if (OPT::bOpenMVS2OpenMVG) { if (OPT::strOutputFileName.IsEmpty()) - OPT::strOutputFileName = Util::getFullFileName(OPT::strInputFileName); + OPT::strOutputFileName = Util::getFileFullName(OPT::strInputFileName); } else { if (OPT::strOutputFileName.IsEmpty()) - OPT::strOutputFileName = Util::getFullFileName(OPT::strInputFileName) + MVS_EXT; + OPT::strOutputFileName = Util::getFileFullName(OPT::strInputFileName) + MVS_EXT; } // initialize global options @@ -602,10 +604,10 @@ int main(int argc, LPCTSTR* argv) image.name = view.second->s_Img_path; Util::ensureUnifySlash(image.name); Util::strTrim(image.name, PATH_SEPARATOR_STR); - String pathRoot(sfm_data.s_root_path); Util::ensureDirectorySlash(pathRoot); + String pathRoot(sfm_data.s_root_path); Util::ensureFolderSlash(pathRoot); const String srcImage(MAKE_PATH_FULL(WORKING_FOLDER_FULL, pathRoot+image.name)); image.name = MAKE_PATH_FULL(WORKING_FOLDER_FULL, OPT::strOutputImageFolder+image.name); - Util::ensureDirectory(image.name); + Util::ensureFolder(image.name); image.ID = static_cast(view.first); image.platformID = map_intrinsic.at(view.second->id_intrinsic); MVS::Platform& platform = scene.platforms[image.platformID]; diff --git a/apps/InterfaceVisualSFM/CMakeLists.txt b/apps/InterfaceVisualSFM/CMakeLists.txt index a1b16af7b..3641261b3 100644 --- a/apps/InterfaceVisualSFM/CMakeLists.txt +++ b/apps/InterfaceVisualSFM/CMakeLists.txt @@ -5,7 +5,7 @@ else() endif() FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl") -cxx_executable_with_flags(InterfaceVisualSFM "Apps" "${cxx_default}" "MVS;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) +cxx_executable_with_flags(InterfaceVisualSFM "Apps" "${cxx_default}" "MVS;Common;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) # Install INSTALL(TARGETS InterfaceVisualSFM diff --git a/apps/ReconstructMesh/CMakeLists.txt b/apps/ReconstructMesh/CMakeLists.txt index 4b6aac728..ce13223f0 100644 --- a/apps/ReconstructMesh/CMakeLists.txt +++ b/apps/ReconstructMesh/CMakeLists.txt @@ -5,7 +5,7 @@ else() endif() FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl") -cxx_executable_with_flags(ReconstructMesh "Apps" "${cxx_default}" "MVS;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) +cxx_executable_with_flags(ReconstructMesh "Apps" "${cxx_default}" "MVS;Common;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) # Install INSTALL(TARGETS ReconstructMesh diff --git a/apps/RefineMesh/CMakeLists.txt b/apps/RefineMesh/CMakeLists.txt index 26a6f84ed..ba95182e1 100644 --- a/apps/RefineMesh/CMakeLists.txt +++ b/apps/RefineMesh/CMakeLists.txt @@ -5,7 +5,7 @@ else() endif() FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl") -cxx_executable_with_flags(RefineMesh "Apps" "${cxx_default}" "MVS;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) +cxx_executable_with_flags(RefineMesh "Apps" "${cxx_default}" "MVS;Common;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) # Install INSTALL(TARGETS RefineMesh diff --git a/apps/TextureMesh/CMakeLists.txt b/apps/TextureMesh/CMakeLists.txt index bef488eeb..d3a407e57 100644 --- a/apps/TextureMesh/CMakeLists.txt +++ b/apps/TextureMesh/CMakeLists.txt @@ -5,7 +5,7 @@ else() endif() FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl") -cxx_executable_with_flags(TextureMesh "Apps" "${cxx_default}" "MVS;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) +cxx_executable_with_flags(TextureMesh "Apps" "${cxx_default}" "MVS;Common;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) # Install INSTALL(TARGETS TextureMesh diff --git a/apps/Viewer/CMakeLists.txt b/apps/Viewer/CMakeLists.txt index fe0920242..7ef14234b 100644 --- a/apps/Viewer/CMakeLists.txt +++ b/apps/Viewer/CMakeLists.txt @@ -34,7 +34,7 @@ else() endif() FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl") -cxx_executable_with_flags(${VIEWER_NAME} "Apps" "${cxx_default}" "MVS;${OPENGL_LIBRARIES};${GLEW_LIBRARY};${GLFW_STATIC_LIBRARIES};GLEW::GLEW;${glfw3_LIBRARY};${GLFW3_LIBRARY};glfw;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) +cxx_executable_with_flags(${VIEWER_NAME} "Apps" "${cxx_default}" "MVS;Common;${OPENGL_LIBRARIES};${GLEW_LIBRARY};${GLFW_STATIC_LIBRARIES};GLEW::GLEW;${glfw3_LIBRARY};${GLFW3_LIBRARY};glfw;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) # Manually set Common.h as the precompiled header IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16.0) diff --git a/build/Utils.cmake b/build/Utils.cmake index 2bfbc9822..0cb2d8e1a 100644 --- a/build/Utils.cmake +++ b/build/Utils.cmake @@ -451,7 +451,6 @@ macro(optimize_default_compiler_settings) add_extra_compiler_option(-Werror=sequence-point) add_extra_compiler_option(-Wformat) add_extra_compiler_option(-Werror=format-security -Wformat) - add_extra_compiler_option(-Wstrict-prototypes) add_extra_compiler_option(-Winit-self) add_extra_compiler_option(-Wsign-promo) add_extra_compiler_option(-Wreorder) diff --git a/libs/Common/CMakeLists.txt b/libs/Common/CMakeLists.txt index 18899afde..9c20ddd7e 100644 --- a/libs/Common/CMakeLists.txt +++ b/libs/Common/CMakeLists.txt @@ -13,6 +13,7 @@ endif() # Link its dependencies TARGET_LINK_LIBRARIES(Common ${Boost_LIBRARIES} ${OpenCV_LIBS}) +TARGET_COMPILE_OPTIONS(Common INTERFACE -fpermissive) # Install SET_TARGET_PROPERTIES(Common PROPERTIES From 290709b7e1fe8753cf832e6f2ddb501ce6f05069 Mon Sep 17 00:00:00 2001 From: Vitalijus Dobrovolskis Date: Sun, 5 Jun 2022 14:39:22 +0200 Subject: [PATCH 2/3] build: Fixed deprecated resolution of Eigen as dependency --- CMakeLists.txt | 11 ++-- build/Modules/FindEigen3.cmake | 107 --------------------------------- 2 files changed, 5 insertions(+), 113 deletions(-) delete mode 100644 build/Modules/FindEigen3.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d921e826..42eae09d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,14 +175,13 @@ if(Boost_FOUND) SET(_USE_BOOST TRUE) endif() -FIND_PACKAGE(Eigen3 REQUIRED) -if(EIGEN3_FOUND) - LIST(APPEND OpenMVS_EXTRA_INCLUDES ${EIGEN3_INCLUDE_DIR}) - INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIR}) +find_package(Eigen3 3.4 REQUIRED) +if(Eigen3_FOUND) LIST(APPEND OpenMVS_DEFINITIONS -D_USE_EIGEN) - ADD_DEFINITIONS(${EIGEN3_DEFINITIONS}) SET(_USE_EIGEN TRUE) - MESSAGE(STATUS "Eigen ${EIGEN3_VERSION} found (include: ${EIGEN3_INCLUDE_DIR})") + + message(STATUS "Found Eigen version ${Eigen3_VERSION}: ${Eigen3_DIR}") + link_libraries(Eigen3::Eigen) endif() FIND_PACKAGE(OpenCV REQUIRED) diff --git a/build/Modules/FindEigen3.cmake b/build/Modules/FindEigen3.cmake deleted file mode 100644 index 0b36805e7..000000000 --- a/build/Modules/FindEigen3.cmake +++ /dev/null @@ -1,107 +0,0 @@ -# - Try to find Eigen3 lib -# -# This module supports requiring a minimum version, e.g. you can do -# find_package(Eigen3 3.1.2) -# to require version 3.1.2 or newer of Eigen3. -# -# Once done this will define -# -# EIGEN3_FOUND - system has eigen lib with correct version -# EIGEN3_INCLUDE_DIR - the eigen include directory -# EIGEN3_VERSION - eigen version -# -# and the following imported target: -# -# Eigen3::Eigen - The header-only Eigen library -# -# This module reads hints about search locations from -# the following environment variables: -# -# EIGEN3_ROOT -# EIGEN3_ROOT_DIR - -# Copyright (c) 2006, 2007 Montel Laurent, -# Copyright (c) 2008, 2009 Gael Guennebaud, -# Copyright (c) 2009 Benoit Jacob -# Redistribution and use is allowed according to the terms of the 2-clause BSD license. - -if(NOT Eigen3_FIND_VERSION) - if(NOT Eigen3_FIND_VERSION_MAJOR) - set(Eigen3_FIND_VERSION_MAJOR 2) - endif() - if(NOT Eigen3_FIND_VERSION_MINOR) - set(Eigen3_FIND_VERSION_MINOR 91) - endif() - if(NOT Eigen3_FIND_VERSION_PATCH) - set(Eigen3_FIND_VERSION_PATCH 0) - endif() - - set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}") -endif() - -macro(_eigen3_check_version) - file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) - - string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") - set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") - set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") - set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") - - set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) - if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) - set(EIGEN3_VERSION_OK FALSE) - else() - set(EIGEN3_VERSION_OK TRUE) - endif() - - if(NOT EIGEN3_VERSION_OK) - - message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, " - "but at least version ${Eigen3_FIND_VERSION} is required") - endif() -endmacro() - -if (EIGEN3_INCLUDE_DIR) - - # in cache already - _eigen3_check_version() - set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) - set(Eigen3_FOUND ${EIGEN3_VERSION_OK}) - -else () - - # search first if an Eigen3Config.cmake is available in the system, - # if successful this would set EIGEN3_INCLUDE_DIR and the rest of - # the script will work as usual - find_package(Eigen3 ${Eigen3_FIND_VERSION} NO_MODULE QUIET) - - if(NOT EIGEN3_INCLUDE_DIR) - find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library - HINTS - ENV EIGEN3_ROOT - ENV EIGEN3_ROOT_DIR - PATHS - ${CMAKE_INSTALL_PREFIX}/include - ${KDE4_INCLUDE_DIR} - PATH_SUFFIXES eigen3 eigen - ) - endif() - - if(EIGEN3_INCLUDE_DIR) - _eigen3_check_version() - endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) - - mark_as_advanced(EIGEN3_INCLUDE_DIR) - -endif() - -if(EIGEN3_FOUND AND NOT TARGET Eigen3::Eigen) - add_library(Eigen3::Eigen INTERFACE IMPORTED) - set_target_properties(Eigen3::Eigen PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${EIGEN3_INCLUDE_DIR}") -endif() From cce15993f6b599836f04506ca63925d60e23d049 Mon Sep 17 00:00:00 2001 From: Vitalijus Dobrovolskis Date: Mon, 8 Aug 2022 00:42:26 +0200 Subject: [PATCH 3/3] build: Removed deprecated interfaces from CMake build configuration --- apps/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 51a82810f..47e06cf50 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -2,8 +2,8 @@ ADD_SUBDIRECTORY(DensifyPointCloud) ADD_SUBDIRECTORY(InterfaceCOLMAP) ADD_SUBDIRECTORY(InterfaceMetashape) -ADD_SUBDIRECTORY(InterfaceOpenMVG) -ADD_SUBDIRECTORY(InterfaceVisualSFM) +#ADD_SUBDIRECTORY(InterfaceOpenMVG) +#ADD_SUBDIRECTORY(InterfaceVisualSFM) ADD_SUBDIRECTORY(ReconstructMesh) ADD_SUBDIRECTORY(RefineMesh) ADD_SUBDIRECTORY(TextureMesh)