Skip to content

Commit

Permalink
[build] Add transitive cxx11 compilation rules openMVG#1282
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoulon committed Jun 10, 2018
1 parent 27afb33 commit 1791bea
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 29 deletions.
5 changes: 0 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,6 @@ install(EXPORT openMVG-targets
DESTINATION share/openMVG/cmake
)

#Adapt build include paths to install path
set(OpenMVG_INCLUDE_DIRS
"${OpenMVG_INCLUDE_DIRS}"
"${CMAKE_INSTALL_PREFIX}/include;${CMAKE_INSTALL_PREFIX}/include/openMVG_dependencies")


# Build OpenMVG_CFLAGS variable for export
set(OpenMVG_CFLAGS "")
Expand Down
32 changes: 17 additions & 15 deletions src/cmakeFindModules/CXX11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ macro(check_for_cxx11_compiler _VAR)
endif()
endmacro()

# Sets the appropriate flag to enable C++11 support
macro(enable_cxx11)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(--std=c++11 SUPPORTS_STD_CXX11)
check_cxx_compiler_flag(--std=c++0x SUPPORTS_STD_CXX01)
if(SUPPORTS_STD_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11")
elseif(SUPPORTS_STD_CXX01)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++0x")
else()
message(ERROR "Compiler does not support --std=c++11 or --std=c++0x.")
endif()
endif()
endmacro()
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.8.0"))
# For CMake 3.8 and above, we can use meta features directly provided by CMake itself
set(CXX11_FEATURES cxx_std_11)
set(CXX14_FEATURES cxx_std_14)
set(CXX17_FEATURES cxx_std_17)
return()
endif()

set(CXX11_FEATURES
cxx_auto_type
cxx_constexpr
cxx_lambdas
cxx_nullptr
cxx_override
cxx_range_for
cxx_strong_enums
)
8 changes: 0 additions & 8 deletions src/cmakeFindModules/OpenMVGConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
#
# OPENMVG_VERSION: Version of OpenMVG found.
#
# OPENMVG_INCLUDE_DIRS: Include directories for OpenMVG and the
# dependencies which appear in the OpenMVG public
# API and are thus required to use OpenMVG.
#
# OPENMVG_LIBRARIES: Libraries for OpenMVG and all
# dependencies against which OpenMVG was
# compiled.

# Called if we failed to find OpenMVG or any of it's required dependencies,
# unsets all public (designed to be used externally) variables and reports
Expand Down Expand Up @@ -90,7 +83,6 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

# Import exported OpenMVG targets
set(OPENMVG_LIBRARIES @OpenMVG_LIBRARIES@)
include(${CURRENT_CONFIG_INSTALL_DIR}/OpenMVGTargets.cmake)

# As we use OPENMVG_REPORT_NOT_FOUND() to abort, if we reach this point we have
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/cameras/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

add_library(openMVG_camera INTERFACE)
target_compile_features(openMVG_camera INTERFACE ${CXX11_FEATURES})
target_link_libraries(openMVG_camera INTERFACE openMVG_numeric openMVG_geometry)
install(TARGETS openMVG_camera DESTINATION lib EXPORT openMVG-targets)

Expand Down
1 change: 1 addition & 0 deletions src/openMVG/exif/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

add_library(openMVG_exif exif_IO_EasyExif.cpp)
target_compile_features(openMVG_exif INTERFACE ${CXX11_FEATURES})
target_link_libraries(openMVG_exif LINK_PRIVATE openMVG_easyexif)
target_include_directories(openMVG_exif PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/third_party/include/easyexif)
set_property(TARGET openMVG_exif PROPERTY FOLDER OpenMVG/OpenMVG)
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/features/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ list(REMOVE_ITEM features_files_sources ${REMOVEFILESUNITTEST})

set_source_files_properties(${features_files_sources} PROPERTIES LANGUAGE CXX)
add_library(openMVG_features ${features_files_sources} ${features_files_headers})
target_compile_features(openMVG_features INTERFACE ${CXX11_FEATURES})
target_include_directories(openMVG_features
PUBLIC
$<BUILD_INTERFACE:${EIGEN_INCLUDE_DIRS}>
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/geodesy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

add_library(openMVG_geodesy INTERFACE)
target_compile_features(openMVG_geodesy INTERFACE ${CXX11_FEATURES})
target_link_libraries(openMVG_geodesy
INTERFACE
openMVG_numeric
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ file(GLOB_RECURSE REMOVEFILESUNITTEST *_test.cpp)
list(REMOVE_ITEM geometry_files_cpp ${REMOVEFILESUNITTEST})

add_library(openMVG_geometry ${geometry_files_header} ${geometry_files_cpp})
target_compile_features(openMVG_geometry INTERFACE ${CXX11_FEATURES})
set_target_properties(openMVG_geometry PROPERTIES SOVERSION ${OPENMVG_VERSION_MAJOR} VERSION "${OPENMVG_VERSION_MAJOR}.${OPENMVG_VERSION_MINOR}")
set_property(TARGET openMVG_geometry PROPERTY FOLDER OpenMVG/OpenMVG)

Expand Down
1 change: 1 addition & 0 deletions src/openMVG/graph/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

add_library(openMVG_graph INTERFACE)
target_compile_features(openMVG_graph INTERFACE ${CXX11_FEATURES})
target_link_libraries(openMVG_graph INTERFACE ${LEMON_LIBRARY})
install(TARGETS openMVG_graph DESTINATION lib EXPORT openMVG-targets)

Expand Down
1 change: 1 addition & 0 deletions src/openMVG/image/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ file(GLOB_RECURSE REMOVEFILESUNITTEST *_test.cpp)
list(REMOVE_ITEM image_files_cpp ${REMOVEFILESUNITTEST})

add_library(openMVG_image ${image_files_header} ${image_files_cpp})
target_compile_features(openMVG_image INTERFACE ${CXX11_FEATURES})
target_link_libraries(openMVG_image
PUBLIC
openMVG_numeric
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/linearProgramming/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ add_library(openMVG_linearProgramming
linearProgrammingOSI_X.cpp
linearProgrammingOSI_X.hpp
linearProgramming.hpp)
target_compile_features(openMVG_linearProgramming INTERFACE ${CXX11_FEATURES})

set_property(TARGET openMVG_linearProgramming PROPERTY FOLDER OpenMVG/OpenMVG)
install(TARGETS openMVG_linearProgramming DESTINATION lib EXPORT openMVG-targets)
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/linearProgramming/lInfinityCV/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ file(GLOB_RECURSE REMOVEFILESUNITTEST *_test.cpp)
list(REMOVE_ITEM lInftycomputervision_cpp ${REMOVEFILESUNITTEST})

add_library(openMVG_lInftyComputerVision ${lInftycomputervision_headers} ${lInftycomputervision_cpp})
target_compile_features(openMVG_lInftyComputerVision INTERFACE ${CXX11_FEATURES})
target_link_libraries(openMVG_lInftyComputerVision PUBLIC openMVG_linearProgramming openMVG_multiview)
set_target_properties(openMVG_lInftyComputerVision PROPERTIES SOVERSION ${OPENMVG_VERSION_MAJOR} VERSION "${OPENMVG_VERSION_MAJOR}.${OPENMVG_VERSION_MINOR}")
set_property(TARGET openMVG_lInftyComputerVision PROPERTY FOLDER OpenMVG/OpenMVG)
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/matching/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set_source_files_properties(${matching_files_cpp} PROPERTIES LANGUAGE CXX)
add_library(openMVG_matching
${matching_files_header}
${matching_files_cpp})
target_compile_features(openMVG_matching INTERFACE ${CXX11_FEATURES})
target_include_directories(openMVG_matching
PUBLIC
$<BUILD_INTERFACE:${FLANN_INCLUDE_DIRS}>
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/matching/kvld/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

add_library(openMVG_kvld kvld.cpp kvld.h algorithm.cpp algorithm.h)
target_compile_features(openMVG_kvld INTERFACE ${CXX11_FEATURES})
target_link_libraries(openMVG_kvld
PUBLIC openMVG_features openMVG_image)
set_target_properties(openMVG_kvld PROPERTIES SOVERSION ${OPENMVG_VERSION_MAJOR} VERSION "${OPENMVG_VERSION_MAJOR}.${OPENMVG_VERSION_MINOR}")
Expand Down
2 changes: 2 additions & 0 deletions src/openMVG/matching_image_collection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ list(REMOVE_ITEM matching_collection_images_files_cpp ${REMOVEFILESUNITTEST})
add_library(openMVG_matching_image_collection
${matching_collection_images_files_header}
${matching_collection_images_files_cpp})
target_compile_features(openMVG_matching_image_collection INTERFACE ${CXX11_FEATURES})

target_link_libraries(openMVG_matching_image_collection
PUBLIC
openMVG_matching
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/multiview/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ list(REMOVE_ITEM multiview_files_cpp ${MULTIVIEWTESTDATA})
add_library(openMVG_multiview
${multiview_files_header}
${multiview_files_cpp})
target_compile_features(openMVG_multiview INTERFACE ${CXX11_FEATURES})
set_property(TARGET openMVG_multiview PROPERTY FOLDER OpenMVG/OpenMVG)
install(TARGETS openMVG_multiview DESTINATION lib EXPORT openMVG-targets)
target_link_libraries(openMVG_multiview
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/numeric/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ list(REMOVE_ITEM numeric_files_cpp ${REMOVEFILESUNITTEST})
add_library(openMVG_numeric
${numeric_files_header}
${numeric_files_cpp})
target_compile_features(openMVG_numeric INTERFACE ${CXX11_FEATURES})
target_include_directories(openMVG_numeric
PUBLIC
$<BUILD_INTERFACE:${EIGEN_INCLUDE_DIRS}>
Expand Down
2 changes: 2 additions & 0 deletions src/openMVG/robust_estimation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ UNIT_TEST(openMVG robust_estimator_ACRansac "openMVG_testing")
add_library(openMVG_robust_estimation
gms_filter.hpp gms_filter.cpp
)
target_compile_features(openMVG_robust_estimation INTERFACE ${CXX11_FEATURES})
target_include_directories(openMVG_robust_estimation
PUBLIC
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:include/openMVG>
)
target_link_libraries(openMVG_robust_estimation
PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion src/openMVG/sfm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ file(GLOB_RECURSE REMOVEFILESUNITTEST *_test.hpp)
list(REMOVE_ITEM sfm_files_header ${REMOVEFILESUNITTEST})

add_library(openMVG_sfm ${sfm_files_header} ${sfm_files_cpp})

target_compile_features(openMVG_sfm INTERFACE ${CXX11_FEATURES})
target_link_libraries(openMVG_sfm
PUBLIC
openMVG_geometry
Expand Down
1 change: 1 addition & 0 deletions src/openMVG/system/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_library(openMVG_system
timer.hpp
timer.cpp)
target_include_directories(openMVG_system PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>)
target_compile_features(openMVG_system INTERFACE ${CXX11_FEATURES})
set_target_properties(openMVG_system PROPERTIES SOVERSION ${OPENMVG_VERSION_MAJOR} VERSION "${OPENMVG_VERSION_MAJOR}.${OPENMVG_VERSION_MINOR}")
set_property(TARGET openMVG_system PROPERTY FOLDER OpenMVG/OpenMVG)
install(TARGETS openMVG_system DESTINATION lib/ EXPORT openMVG-targets)
Expand Down

0 comments on commit 1791bea

Please sign in to comment.