vcpkg/ports/openmvg/fixcmake.patch
2020-02-11 17:23:12 -08:00

422 lines
16 KiB
Diff

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9cfd06c..a4dea06 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -14,6 +14,7 @@ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed.")
endif()
+if(0)
# ==============================================================================
# OpenMVG build options
# ==============================================================================
@@ -31,7 +32,7 @@ option(OpenMVG_USE_OPENMP "Enable OpenMP parallelization" ON)
# and openMVG simultaneously
# ==============================================================================
option(OpenMVG_USE_OPENCV "Build or not opencv+openMVG samples programs" OFF)
-
+endif()
# ==============================================================================
# Since OpenCV 3, SIFT is no longer in the default modules. See
# https://github.com/itseez/opencv_contrib for more informations.
@@ -85,6 +86,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
register_definitions(-DOPENMVG_STD_UNORDERED_MAP)
endif()
+if(0)
# ==============================================================================
# Check that submodule have been initialized and updated
# ==============================================================================
@@ -93,6 +95,7 @@ if (NOT EXISTS ${PROJECT_SOURCE_DIR}/dependencies/cereal/include)
"\n submodule(s) are missing, please update your repository:\n"
" > git submodule update -i\n")
endif()
+endif()
# ==============================================================================
# Additional cmake find modules
@@ -128,7 +131,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")
@@ -139,11 +141,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)
# ==============================================================================
@@ -182,6 +179,7 @@ if (OpenMVG_BUILD_OPENGL_EXAMPLES)
set_property(TARGET glfw PROPERTY FOLDER OpenMVG/3rdParty/glfw)
endif (OpenMVG_BUILD_OPENGL_EXAMPLES)
+if(0)
# Dependencies install rules
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/
@@ -189,7 +187,7 @@ install(
COMPONENT headers
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h"
)
-
+endif()
# ==============================================================================
# --END-- SUBMODULE CONFIGURATION
# ==============================================================================
@@ -225,6 +223,7 @@ ENDMACRO(UNIT_TEST)
# - external by default
# - internal if cereal not found
# ==============================================================================
+if(0)
find_package(cereal QUIET CONFIG)
if (NOT TARGET cereal)
add_library(cereal INTERFACE)
@@ -237,6 +236,10 @@ if (NOT TARGET cereal)
set(OpenMVG_USE_INTERNAL_CEREAL ON)
endif()
+endif()
+
+find_package(cereal REQUIRED CONFIG)
+get_target_property(CEREAL_INCLUDE_DIRS cereal INTERFACE_INCLUDE_DIRECTORIES)
# ==============================================================================
# Eigen
@@ -245,6 +248,7 @@ endif()
# - external if EIGEN_INCLUDE_DIR_HINTS is defined
# - internal if Eigen not found
# ==============================================================================
+if(0)
find_package(Eigen3 QUIET)
if (NOT Eigen3_FOUND)
set(EIGEN_INCLUDE_DIR_HINTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/eigen)
@@ -253,13 +257,17 @@ if (NOT Eigen3_FOUND)
else()
set(EIGEN_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
endif()
+endif()
+find_package(Eigen3 REQUIRED)
+set(EIGEN_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
# ==============================================================================
# Ceres
# ==============================================================================
# - external by default if CERES_DIR_HINTS or find_package found a valid Ceres
# - internal if ceres not found (ceres-solver+cxsparse+miniglog)
# ==============================================================================
+if(0)
find_package(Ceres QUIET HINTS ${CERES_DIR_HINTS})
if (NOT Ceres_FOUND)
set(OpenMVG_USE_INTERNAL_CERES ON)
@@ -271,13 +279,16 @@ if (NOT Ceres_FOUND)
STRING(REGEX REPLACE "version ([0-9.]+).*" "\\1" CERES_VERSION ${CERES_CONFIG})
set(CERES_LIBRARIES openMVG_ceres)
endif()
+endif()
+find_package(Ceres REQUIRED)
# ==============================================================================
# Flann
# ==============================================================================
# - internal by default (flann),
# - external if FLANN_INCLUDE_DIR_HINTS and a valid Flann setup is found
# ==============================================================================
+if(0)
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)
@@ -286,13 +297,16 @@ 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()
+endif()
+find_package(flann REQUIRED)
# ==============================================================================
# CoinUtils
# ==============================================================================
# - internal by default (CoinUtils),
# - external if COINUTILS_INCLUDE_DIR_HINTS and a valid CoinUtils setup is found
# ==============================================================================
+if(0)
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)
@@ -302,13 +316,16 @@ if (NOT DEFINED COINUTILS_INCLUDE_DIR_HINTS)
else()
find_package(CoinUtils QUIET)
endif()
+endif()
+find_package(CoinUtils REQUIRED)
## ==============================================================================
## Clp
## ==============================================================================
## - internal by default (Clp),
## - external if CLP_INCLUDE_DIR_HINTS and a valid Clp setup is found
## ==============================================================================
+if(0)
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)
@@ -320,6 +337,9 @@ if (NOT DEFINED CLP_INCLUDE_DIR_HINTS)
else()
find_package(Clp QUIET)
endif()
+endif()
+
+find_package(Clp REQUIRED)
# ==============================================================================
# Osi
@@ -327,6 +347,7 @@ endif()
# - internal by default (Osi),
# - external if OSI_INCLUDE_DIR_HINTS and a valid Osi setup is found
# ==============================================================================
+if(0)
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)
@@ -336,6 +357,9 @@ if (NOT DEFINED OSI_INCLUDE_DIR_HINTS)
else()
find_package(Osi QUIET)
endif()
+endif()
+
+find_package(Osi REQUIRED)
# ==============================================================================
# Internal CLP/OSI/COINUTILS libraries:
@@ -354,6 +378,7 @@ endif()
# - internal by default (Lemon),
# - external if LEMON_INCLUDE_DIR_HINTS and a valid Lemon setup is found
# ==============================================================================
+if(0)
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)
@@ -365,6 +390,9 @@ if (NOT LEMON_FOUND OR OpenMVG_USE_INTERNAL_LEMON)
${PROJECT_BINARY_DIR}/third_party/lemon)
set(LEMON_LIBRARY openMVG_lemon)
endif()
+endif()
+
+find_package(LEMON REQUIRED)
# ==============================================================================
# OpenCV
@@ -372,15 +400,13 @@ 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()
-
+# ==============================================================================
+# Suitesparse
+# ==============================================================================
+find_package(suitesparse REQUIRED)
# ==============================================================================
# Third-party libraries:
# ==============================================================================
@@ -472,67 +498,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 8a69c23..6a81580 100644
--- a/src/cmakeFindModules/FindClp.cmake
+++ b/src/cmakeFindModules/FindClp.cmake
@@ -51,9 +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)
SET(CLP_LIBRARIES ${CLP_LIBRARY} ${CLPSOLVER_LIBRARY} ${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 5fcd972..b21ea7b 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
@@ -39,10 +40,10 @@ target_link_libraries(openMVG_matching
Threads::Threads
cereal
)
-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)