vcpkg/ports/openmvg/fixcmake.patch
Stefano Sinigardi 69e86fd201 [lz4, flann] port patches from #5169 (#6294)
* [lz4, flann] port patches from #5169

* [lz4] use vcpkg_fixup_cmake_targets

* [flann] improve target handling

* [lz4] remove unnecessary debug message

* [openmvg] many many fixes to build it on windows

* [pcl] use official FLANN cmake config file instead of custom module

* [pcl] fix patch for flann targets

* [pcl] Bump CONTROL version
2019-05-18 22:58:03 -07:00

422 lines
16 KiB
Diff

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 654bebd..5264bfc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -17,27 +17,16 @@ endif()
# ==============================================================================
# OpenMVG build options
# ==============================================================================
-option(OpenMVG_BUILD_SHARED "Build OpenMVG shared libs" OFF)
-option(OpenMVG_BUILD_TESTS "Build OpenMVG tests" OFF)
-option(OpenMVG_BUILD_DOC "Build OpenMVG documentation" ON)
-option(OpenMVG_BUILD_EXAMPLES "Build OpenMVG samples applications." ON)
-option(OpenMVG_BUILD_OPENGL_EXAMPLES "Build OpenMVG openGL examples" OFF)
-option(OpenMVG_BUILD_SOFTWARES "Build OpenMVG softwares" ON)
-option(OpenMVG_BUILD_GUI_SOFTWARES "Build OpenMVG GUI softwares (QT5)" ON)
-option(OpenMVG_BUILD_COVERAGE "Enable code coverage generation (gcc only)" OFF)
-option(OpenMVG_USE_OPENMP "Enable OpenMP parallelization" ON)
# ==============================================================================
# Opencv is not used by openMVG but some samples show how to use openCV
# and openMVG simultaneously
# ==============================================================================
-option(OpenMVG_USE_OPENCV "Build or not opencv+openMVG samples programs" OFF)
# ==============================================================================
# Since OpenCV 3, SIFT is no longer in the default modules. See
# https://github.com/itseez/opencv_contrib for more informations.
# Enable this to be able to use OpenCV SIFT in main_ComputeFeatures_OpenCV.
# ==============================================================================
-option(OpenMVG_USE_OCVSIFT "Add or not OpenCV SIFT in available features" OFF)
# ==============================================================================
# OpenMVG version
@@ -85,15 +74,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
register_definitions(-DOPENMVG_STD_UNORDERED_MAP)
endif()
-# ==============================================================================
-# Check that submodule have been initialized and updated
-# ==============================================================================
-if (NOT EXISTS ${PROJECT_SOURCE_DIR}/dependencies/cereal/include)
- message(FATAL_ERROR
- "\n submodule(s) are missing, please update your repository:\n"
- " > git submodule update -i\n")
-endif()
-
# ==============================================================================
# Additional cmake find modules
# ==============================================================================
@@ -129,7 +109,6 @@ if (OpenMVG_USE_OPENMP)
find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
- option(OpenMVG_USE_OPENMP "Use OpenMP for parallelization" ON)
register_definitions(-DOPENMVG_USE_OPENMP)
if (NOT MSVC)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
@@ -140,11 +119,6 @@ if (OpenMVG_USE_OPENMP)
endif()
endif (NOT MSVC)
endif (OPENMP_FOUND)
-else (OpenMVG_USE_OPENMP)
- option(OpenMVG_USE_OPENMP "Use OpenMP for parallelization" OFF)
- include(UpdateCacheVariable)
- UPDATE_CACHE_VARIABLE(OpenMVG_USE_OPENMP OFF)
- remove_definitions(-DOPENMVG_USE_OPENMP)
endif (OpenMVG_USE_OPENMP)
# ==============================================================================
@@ -183,14 +157,6 @@ if (OpenMVG_BUILD_OPENGL_EXAMPLES)
set_property(TARGET glfw PROPERTY FOLDER OpenMVG/3rdParty/glfw)
endif (OpenMVG_BUILD_OPENGL_EXAMPLES)
-# Dependencies install rules
-install(
- DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/
- DESTINATION include/openMVG_dependencies
- COMPONENT headers
- FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h"
-)
-
# ==============================================================================
# --END-- SUBMODULE CONFIGURATION
# ==============================================================================
@@ -226,14 +192,8 @@ ENDMACRO(UNIT_TEST)
# - external by default
# - internal if cereal not found
# ==============================================================================
-find_package(cereal QUIET CONFIG)
-if (NOT cereal_FOUND)
- set(CEREAL_INCLUDE_DIRS
- ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/cereal/include)
- set(OpenMVG_USE_INTERNAL_CEREAL ON)
-else()
- get_target_property(CEREAL_INCLUDE_DIRS cereal INTERFACE_INCLUDE_DIRECTORIES)
-endif()
+find_package(cereal REQUIRED CONFIG)
+get_target_property(CEREAL_INCLUDE_DIRS cereal INTERFACE_INCLUDE_DIRECTORIES)
# ==============================================================================
# Eigen
@@ -242,14 +202,8 @@ endif()
# - external if EIGEN_INCLUDE_DIR_HINTS is defined
# - internal if Eigen not found
# ==============================================================================
-find_package(eigen3 QUIET)
-if (NOT eigen3_FOUND)
- set(EIGEN_INCLUDE_DIR_HINTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/eigen)
- set(OpenMVG_USE_INTERNAL_EIGEN ON)
- find_package(Eigen QUIET)
-else()
- set(EIGEN_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
-endif()
+find_package(eigen3 REQUIRED)
+set(EIGEN_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
# ==============================================================================
# Ceres
@@ -257,17 +211,7 @@ endif()
# - external by default if CERES_DIR_HINTS or find_package found a valid Ceres
# - internal if ceres not found (ceres-solver+cxsparse+miniglog)
# ==============================================================================
-find_package(Ceres QUIET HINTS ${CERES_DIR_HINTS})
-if (NOT Ceres_FOUND)
- set(OpenMVG_USE_INTERNAL_CERES ON)
- set(CERES_INCLUDE_DIRS
- ${CMAKE_CURRENT_SOURCE_DIR}/third_party/ceres-solver/include
- ${CMAKE_CURRENT_SOURCE_DIR}/third_party/ceres-solver/internal/ceres/miniglog
- ${PROJECT_BINARY_DIR}/third_party/ceres-solver/config)
- FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/third_party/ceres-solver/VERSION" CERES_CONFIG)
- STRING(REGEX REPLACE "version ([0-9.]+).*" "\\1" CERES_VERSION ${CERES_CONFIG})
- set(CERES_LIBRARIES openMVG_ceres)
-endif()
+find_package(Ceres REQUIRED)
# ==============================================================================
# Flann
@@ -275,14 +219,7 @@ endif()
# - internal by default (flann),
# - external if FLANN_INCLUDE_DIR_HINTS and a valid Flann setup is found
# ==============================================================================
-if (NOT DEFINED FLANN_INCLUDE_DIR_HINTS)
- set(FLANN_INCLUDE_DIR_HINTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/flann/src/cpp)
- set(OpenMVG_USE_INTERNAL_FLANN ON)
-endif()
-find_package(Flann QUIET)
-if (NOT FLANN_FOUND OR OpenMVG_USE_INTERNAL_FLANN)
- set(FLANN_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/flann/src/cpp)
-endif()
+find_package(flann REQUIRED)
# ==============================================================================
# CoinUtils
@@ -290,15 +227,7 @@ endif()
# - internal by default (CoinUtils),
# - external if COINUTILS_INCLUDE_DIR_HINTS and a valid CoinUtils setup is found
# ==============================================================================
-if (NOT DEFINED COINUTILS_INCLUDE_DIR_HINTS)
- set(COINUTILS_INCLUDE_DIR_HINTS ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/osi_clp/CoinUtils/src/)
- set(OpenMVG_USE_INTERNAL_COINUTILS ON)
-endif()
-find_package(CoinUtils QUIET)
-if (NOT COINUTILS_FOUND OR OpenMVG_USE_INTERNAL_COINUTILS)
- set(COINUTILS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/osi_clp/CoinUtils/src/)
- set(COINUTILS_LIBRARY lib_CoinUtils)
-endif()
+find_package(CoinUtils REQUIRED)
## ==============================================================================
## Clp
@@ -306,17 +235,7 @@ endif()
## - internal by default (Clp),
## - external if CLP_INCLUDE_DIR_HINTS and a valid Clp setup is found
## ==============================================================================
-if (NOT DEFINED CLP_INCLUDE_DIR_HINTS)
- set(CLP_INCLUDE_DIR_HINTS ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/osi_clp/Clp/src/)
- set(OpenMVG_USE_INTERNAL_CLP ON)
-endif()
-find_package(Clp QUIET)
-if (NOT CLP_FOUND OR OpenMVG_USE_INTERNAL_CLP)
- set(CLP_INCLUDE_DIRS
- ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/osi_clp/Clp/src/
- ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/osi_clp/Clp/src/OsiClp/)
- set(CLP_LIBRARIES lib_clp lib_OsiClpSolver)
-endif()
+find_package(Clp REQUIRED)
# ==============================================================================
# Osi
@@ -324,15 +243,7 @@ endif()
# - internal by default (Osi),
# - external if OSI_INCLUDE_DIR_HINTS and a valid Osi setup is found
# ==============================================================================
-if (NOT DEFINED OSI_INCLUDE_DIR_HINTS)
- set(OSI_INCLUDE_DIR_HINTS ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/osi_clp/Osi/src/)
- set(OpenMVG_USE_INTERNAL_OSI ON)
-endif()
-find_package(Osi QUIET)
-if (NOT OSI_FOUND OR OpenMVG_USE_INTERNAL_OSI)
- set(OSI_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/osi_clp/Osi/src/Osi/)
- set(OSI_LIBRARY lib_Osi)
-endif()
+find_package(Osi REQUIRED)
# ==============================================================================
# Internal CLP/OSI/COINUTILS libraries:
@@ -351,17 +262,7 @@ endif()
# - internal by default (Lemon),
# - external if LEMON_INCLUDE_DIR_HINTS and a valid Lemon setup is found
# ==============================================================================
-if (NOT DEFINED LEMON_INCLUDE_DIR_HINTS)
- set(LEMON_INCLUDE_DIR_HINTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/lemon)
- set(OpenMVG_USE_INTERNAL_LEMON ON)
-endif()
-find_package(Lemon QUIET)
-if (NOT LEMON_FOUND OR OpenMVG_USE_INTERNAL_LEMON)
- set(LEMON_INCLUDE_DIRS
- ${CMAKE_CURRENT_SOURCE_DIR}/third_party/lemon
- ${PROJECT_BINARY_DIR}/third_party/lemon)
- set(LEMON_LIBRARY openMVG_lemon)
-endif()
+find_package(Lemon REQUIRED)
# ==============================================================================
# OpenCV
@@ -369,12 +270,7 @@ endif()
# - only external and enabled only if OpenMVG_USE_OPENCV is set to ON
# ==============================================================================
if (OpenMVG_USE_OPENCV)
- find_package( OpenCV QUIET )
- if (NOT OpenCV_FOUND OR OpenCV_VERSION VERSION_LESS "3.0.0")
- message(STATUS "OpenCV was not found (note that OpenCV version >= 3.0.0 is required). -> Disabling OpenCV support.")
- UPDATE_CACHE_VARIABLE(OpenMVG_USE_OPENCV OFF)
- UPDATE_CACHE_VARIABLE(OpenMVG_USE_OCVSIFT OFF)
- endif()
+ find_package( OpenCV REQUIRED )
endif()
@@ -469,67 +365,67 @@ message("** Use OpenCV SIFT features: " ${OpenMVG_USE_OCVSIFT})
message("\n")
-if (DEFINED OpenMVG_USE_INTERNAL_CEREAL)
+if (OpenMVG_USE_INTERNAL_CEREAL)
message(STATUS "CEREAL: (internal)")
else()
message(STATUS "CEREAL: (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_EIGEN)
+if (OpenMVG_USE_INTERNAL_EIGEN)
message(STATUS "EIGEN: " ${EIGEN_VERSION} " (internal)")
else()
message(STATUS "EIGEN: " ${EIGEN_VERSION} " (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_CERES)
+if (OpenMVG_USE_INTERNAL_CERES)
message(STATUS "CERES: " ${CERES_VERSION} " (internal)")
else()
message(STATUS "CERES: " ${CERES_VERSION} " (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_FLANN)
+if (OpenMVG_USE_INTERNAL_FLANN)
message(STATUS "FLANN: " ${FLANN_VERSION} " (internal)")
else()
message(STATUS "FLANN: " ${FLANN_VERSION} " (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_TIFF)
+if (OpenMVG_USE_INTERNAL_TIFF)
message(STATUS "LIBTIFF: " ${TIFF_VERSION_STRING} " (internal)")
else()
message(STATUS "LIBTIFF: " ${TIFF_VERSION_STRING} " (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_PNG)
+if (OpenMVG_USE_INTERNAL_PNG)
message(STATUS "LIBPNG: " ${PNG_VERSION_STRING} " (internal)")
else()
message(STATUS "LIBPNG: " ${PNG_VERSION_STRING} " (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_JPEG)
+if (OpenMVG_USE_INTERNAL_JPEG)
message(STATUS "LIBJPEG (internal)")
else()
message(STATUS "LIBJPEG (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_CLP)
+if (OpenMVG_USE_INTERNAL_CLP)
message(STATUS "CLP: " ${CLP_VERSION} " (internal)")
else()
message(STATUS "CLP: " ${CLP_VERSION} " (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_COINUTILS)
+if (OpenMVG_USE_INTERNAL_COINUTILS)
message(STATUS "COINUTILS: " ${COINUTILS_VERSION} " (internal)")
else()
message(STATUS "COINUTILS: " ${COINUTILS_VERSION} " (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_OSI)
+if (OpenMVG_USE_INTERNAL_OSI)
message(STATUS "OSI: " ${OSI_VERSION} " (internal)")
else()
message(STATUS "OSI: " ${OSI_VERSION} " (external)")
endif()
-if (DEFINED OpenMVG_USE_INTERNAL_LEMON)
+if (OpenMVG_USE_INTERNAL_LEMON)
message(STATUS "LEMON: " ${LEMON_VERSION} " (internal)")
else()
message(STATUS "LEMON: " ${LEMON_VERSION} " (external)")
diff --git a/src/cmakeFindModules/FindClp.cmake b/src/cmakeFindModules/FindClp.cmake
index c997b87..74c3aae 100644
--- a/src/cmakeFindModules/FindClp.cmake
+++ b/src/cmakeFindModules/FindClp.cmake
@@ -51,8 +51,8 @@ IF(EXISTS "${CLP_DIR}" AND NOT "${CLP_DIR}" STREQUAL "")
SET(CLP_INCLUDE_DIR ${CLP_DIR})
FIND_LIBRARY(CLP_LIBRARY NAMES Clp)
- FIND_LIBRARY(CLPSOLVER_LIBRARY NAMES ClpSolver)
- FIND_LIBRARY(OSICLP_LIBRARY NAMES OsiClp)
+ FIND_LIBRARY(CLPSOLVER_LIBRARY NAMES ClpSolver Clp)
+ FIND_LIBRARY(OSICLP_LIBRARY NAMES OsiClp Clp)
# locate Clp libraries
IF(DEFINED CLP_LIBRARY AND DEFINED CLPSOLVER_LIBRARY AND DEFINED OSICLP_LIBRARY)
diff --git a/src/openMVG/linearProgramming/CMakeLists.txt b/src/openMVG/linearProgramming/CMakeLists.txt
index cc5212f..acc57dd 100644
--- a/src/openMVG/linearProgramming/CMakeLists.txt
+++ b/src/openMVG/linearProgramming/CMakeLists.txt
@@ -15,16 +15,12 @@ target_link_libraries(openMVG_linearProgramming
PUBLIC
openMVG_numeric
PRIVATE
- ${CLP_LIBRARIES} # clp + solver wrapper
- ${COINUTILS_LIBRARY} # container tools
- ${OSI_LIBRARY} # generic LP
+ Coin::Clp # clp + solver wrapper
+ Coin::CoinUtils # container tools
+ Coin::Osi # generic LP
)
target_include_directories(openMVG_linearProgramming
- PRIVATE
- ${CLP_INCLUDE_DIRS}
- ${COINUTILS_INCLUDE_DIRS}
- ${OSI_INCLUDE_DIRS}
PUBLIC
$<INSTALL_INTERFACE:include>
)
diff --git a/src/openMVG/matching/CMakeLists.txt b/src/openMVG/matching/CMakeLists.txt
index 80b1fe6..a091b47 100644
--- a/src/openMVG/matching/CMakeLists.txt
+++ b/src/openMVG/matching/CMakeLists.txt
@@ -18,6 +18,7 @@ list(REMOVE_ITEM matching_files_cpp ${REMOVEFILESUNITTEST})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
+find_package(flann REQUIRED)
set_source_files_properties(${matching_files_cpp} PROPERTIES LANGUAGE CXX)
add_library(openMVG_matching
@@ -38,10 +39,10 @@ target_link_libraries(openMVG_matching
openMVG_features
Threads::Threads
)
-if (NOT DEFINED OpenMVG_USE_INTERNAL_FLANN)
+if (NOT OpenMVG_USE_INTERNAL_FLANN)
target_link_libraries(openMVG_matching
PUBLIC
- ${FLANN_LIBRARIES}
+ flann::flann
)
endif()
set_target_properties(openMVG_matching PROPERTIES SOVERSION ${OPENMVG_VERSION_MAJOR} VERSION "${OPENMVG_VERSION_MAJOR}.${OPENMVG_VERSION_MINOR}")
diff --git a/src/third_party/CMakeLists.txt b/src/third_party/CMakeLists.txt
index 816a941..f0b7145 100644
--- a/src/third_party/CMakeLists.txt
+++ b/src/third_party/CMakeLists.txt
@@ -18,7 +18,7 @@ add_subdirectory(stlplus3)
set(STLPLUS_LIBRARY openMVG_stlplus PARENT_SCOPE)
# Add graph library
-if(DEFINED OpenMVG_USE_INTERNAL_LEMON)
+if(OpenMVG_USE_INTERNAL_LEMON)
add_subdirectory(lemon)
set_property(TARGET openMVG_lemon PROPERTY FOLDER OpenMVG/3rdParty/lemon)
set_property(TARGET check PROPERTY FOLDER OpenMVG/3rdParty/lemon)
@@ -68,7 +68,7 @@ endif (NOT TIFF_FOUND)
add_subdirectory(vectorGraphics)
# Add ceres-solver (A Nonlinear Least Squares Minimizer)
-if (DEFINED OpenMVG_USE_INTERNAL_CERES)
+if (OpenMVG_USE_INTERNAL_CERES)
add_subdirectory(cxsparse)
add_subdirectory(ceres-solver)
set_property(TARGET openMVG_cxsparse PROPERTY FOLDER OpenMVG/3rdParty/ceres)
@@ -76,7 +76,7 @@ if (DEFINED OpenMVG_USE_INTERNAL_CERES)
endif()
# Add an Approximate Nearest Neighbor library
-if (DEFINED OpenMVG_USE_INTERNAL_FLANN)
+if (OpenMVG_USE_INTERNAL_FLANN)
set(FLANN_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/openMVG/third_party/flann/src/cpp)
add_subdirectory(flann)
endif()
@@ -90,7 +90,7 @@ add_subdirectory(fast)
##
# Install Header only libraries if necessary
##
-if (DEFINED OpenMVG_USE_INTERNAL_EIGEN)
+if (OpenMVG_USE_INTERNAL_EIGEN)
#Configure Eigen install
set(EIGEN_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/openMVG/third_party/eigen)
add_subdirectory(eigen)