8000 Replace CMake provided find_package scripts and modern CMake targets by ahojnnes · Pull Request #2016 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Replace CMake provided find_package scripts and modern CMake targets #2016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ option(ASAN_ENABLED "Whether to enable AddressSanitizer flags" OFF)
option(PROFILING_ENABLED "Whether to enable google-perftools linker flags" OFF)
option(CCACHE_ENABLED "Whether to enable compiler caching, if available" ON)
option(CGAL_ENABLED "Whether to enable the CGAL library" ON)
option(BOOST_STATIC "Whether to enable static boost library linker flags" ON)
option(BOOST_STATIC "Whether to enable static boost library linker flags" OFF)

if(TESTS_ENABLED)
enable_testing()
Expand Down Expand Up @@ -356,16 +356,12 @@ endif()
include(GenerateVersionDefinitions)

set(COLMAP_INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
${GLOG_INCLUDE_DIRS}
${FLANN_INCLUDE_DIRS}
${LZ4_INCLUDE_DIRS}
${FREEIMAGE_INCLUDE_DIRS}
${CERES_INCLUDE_DIRS}
${METIS_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
${SQLite3_INCLUDE_DIRS}
)

set(COLMAP_LINK_DIRS
Expand All @@ -374,17 +370,19 @@ set(COLMAP_LINK_DIRS

set(COLMAP_EXTERNAL_LIBRARIES
${CMAKE_DL_LIBS}
${Boost_FILESYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${GLOG_LIBRARIES}
${FLANN_LIBRARIES}
${LZ4_LIBRARIES}
${FREEIMAGE_LIBRARIES}
${METIS_LIBRARIES}
${CERES_LIBRARIES}
${OPENGL_LIBRARIES}
${SQLite3_LIBRARIES}
Boost::program_options
Boost::filesystem
Boost::graph
Boost::system
Eigen3::Eigen
glog::glog
SQLite::SQLite3
)

if(OPENMP_FOUND)
Expand Down
6 changes: 2 additions & 4 deletions cmake/CMakeHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ macro(COLMAP_ADD_TEST TEST_NAME)
if(CLANG_TIDY_EXE)
set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*")
endif()
target_link_libraries(${TARGET_NAME} colmap
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
target_link_libraries(${TARGET_NAME} colmap Boost::unit_test_framework)
add_test("${FOLDER_NAME}/${TARGET_NAME}" ${TARGET_NAME})
if(IS_MSVC)
install(TARGETS ${TARGET_NAME} DESTINATION bin/)
Expand All @@ -185,8 +184,7 @@ macro(COLMAP_ADD_CUDA_TEST TEST_NAME)
if(CLANG_TIDY_EXE)
set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*")
endif()
target_link_libraries(${TARGET_NAME} colmap
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
target_link_libraries(${TARGET_NAME} colmap Boost::unit_test_framework)
add_test("${FOLDER_NAME}/${TARGET_NAME}" ${TARGET_NAME})
if(IS_MSVC)
install(TARGETS ${TARGET_NAME} DESTINATION bin/)
Expand Down
126 changes: 0 additions & 126 deletions cmake/FindEigen3.cmake

This file was deleted.

113 changes: 62 additions & 51 deletions cmake/FindGlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
# The following variables are set by this module:
#
# GLOG_FOUND: TRUE if Glog is found.
# GLOG_INCLUDE_DIRS: Include directories for Glog.
# GLOG_LIBRARIES: Libraries required to link Glog.
# glog::glog: Imported target to ling against.
#
# The following variables control the behavior of this module:
#
Expand All @@ -51,58 +50,70 @@ unset(GLOG_FOUND)
unset(GLOG_INCLUDE_DIRS)
unset(GLOG_LIBRARIES)

include(FindPackageHandleStandardArgs)
find_package(glog CONFIG QUIET)
if(glog_FOUND)
set(GLOG_FOUND)
else()
# Older versions of glog don't come with a find_package config.
# Fall back to custom logic to find the library and remap to imported target.

list(APPEND GLOG_CHECK_INCLUDE_DIRS
/usr/local/include
/usr/local/homebrew/include
/opt/local/var/macports/software
/opt/local/include
/usr/include)
list(APPEND GLOG_CHECK_PATH_SUFFIXES
glog/include
glog/Include
Glog/include
Glog/Include
src/windows)
include(FindPackageHandleStandardArgs)

list(APPEND GLOG_CHECK_LIBRARY_DIRS
/usr/local/lib
/usr/local/homebrew/lib
/opt/local/lib
/usr/lib)
list(APPEND GLOG_CHECK_LIBRARY_SUFFIXES
glog/lib
glog/Lib
Glog/lib
Glog/Lib
x64/Release)
list(APPEND GLOG_CHECK_INCLUDE_DIRS
/usr/local/include
/usr/local/homebrew/include
/opt/local/var/macports/software
/opt/local/include
/usr/include)
list(APPEND GLOG_CHECK_PATH_SUFFIXES
glog/include
glog/Include
Glog/include
Glog/Include
src/windows)

find_path(GLOG_INCLUDE_DIRS
NAMES
glog/logging.h
PATHS
${GLOG_INCLUDE_DIR_HINTS}
${GLOG_CHECK_INCLUDE_DIRS}
PATH_SUFFIXES
${GLOG_CHECK_PATH_SUFFIXES})
find_library(GLOG_LIBRARIES
NAMES
glog
libglog
PATHS
${GLOG_LIBRARY_DIR_HINTS}
${GLOG_CHECK_LIBRARY_DIRS}
PATH_SUFFIXES
${GLOG_CHECK_LIBRARY_SUFFIXES})
list(APPEND GLOG_CHECK_LIBRARY_DIRS
/usr/local/lib
/usr/local/homebrew/lib
/opt/local/lib
/usr/lib)
list(APPEND GLOG_CHECK_LIBRARY_SUFFIXES
glog/lib
glog/Lib
Glog/lib
Glog/Lib
x64/Release)

if (GLOG_INCLUDE_DIRS AND GLOG_LIBRARIES)
set(GLOG_FOUND TRUE)
message(STATUS "Found Glog")
message(STATUS " Includes : ${GLOG_INCLUDE_DIRS}")
message(STATUS " Libraries : ${GLOG_LIBRARIES}")
else()
if(Glog_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Glog")
find_path(GLOG_INCLUDE_DIRS
NAMES
glog/logging.h
PATHS
${GLOG_INCLUDE_DIR_HINTS}
${GLOG_CHECK_INCLUDE_DIRS}
PATH_SUFFIXES
${GLOG_CHECK_PATH_SUFFIXES})
find_library(GLOG_LIBRARIES
NAMES
glog
libglog
PATHS
${GLOG_LIBRARY_DIR_HINTS}
${GLOG_CHECK_LIBRARY_DIRS}
PATH_SUFFIXES
${GLOG_CHECK_LIBRARY_SUFFIXES})

if (GLOG_INCLUDE_DIRS AND GLOG_LIBRARIES)
set(GLOG_FOUND TRUE)
message(STATUS "Found Glog")
message(STATUS " Includes : ${GLOG_INCLUDE_DIRS}")
message(STATUS " Libraries : ${GLOG_LIBRARIES}")
else()
if(Glog_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Glog")
endif()
endif()

add_library(glog::glog INTERFACE IMPORTED)
target_include_directories(glog::glog INTERFACE ${GLOG_INCLUDE_DIRS})
target_link_libraries(glog::glog INTERFACE ${GLOG_LIBRARIES})
endif()
Loading
0