cmake: fix includes processing

This commit is contained in:
Alexander Alekhin 2018-02-02 21:52:54 +03:00
parent 403c3c3d03
commit 3d6659112f
3 changed files with 17 additions and 22 deletions

View File

@ -257,7 +257,7 @@ endmacro()
# Usage: _glob_locations(<output paths list> <output names list> <folder> [<folder> ...])
function(_glob_locations out_paths out_names)
foreach(path ${ARGN})
message(STATUS "Inspect: ${path}")
#message(STATUS "Inspect: ${path}")
list(LENGTH paths before)
get_filename_component(path "${path}" ABSOLUTE)
# Either module itself
@ -269,7 +269,7 @@ function(_glob_locations out_paths out_names)
# Either flat collection of modules
file(GLOB subdirs RELATIVE "${path}" "${path}/*")
foreach(subdir ${subdirs})
message(STATUS "Inspect: ${path}/${subdir}")
#message(STATUS "Inspect: ${path}/${subdir}")
if(EXISTS "${path}/${subdir}/CMakeLists.txt")
list(APPEND paths "${path}/${subdir}")
list(APPEND names "${subdir}")
@ -302,7 +302,7 @@ function(_add_modules_1 paths names)
foreach(i RANGE ${len})
list(GET ${paths} ${i} path)
list(GET ${names} ${i} name)
message(STATUS "First pass: ${name} => ${path}")
#message(STATUS "First pass: ${name} => ${path}")
include("${path}/cmake/init.cmake" OPTIONAL)
add_subdirectory("${path}" "${CMAKE_CURRENT_BINARY_DIR}/.firstpass/${name}")
endforeach()
@ -320,7 +320,7 @@ function(_add_modules_2)
message(WARNING "Incorrect module name: ${m}")
endif()
string(REGEX REPLACE "^opencv_" "" name "${m}")
message(STATUS "Second pass: ${name} => ${OPENCV_MODULE_${m}_LOCATION}")
#message(STATUS "Second pass: ${name} => ${OPENCV_MODULE_${m}_LOCATION}")
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${name}")
endif()
endforeach()
@ -427,7 +427,7 @@ function(__ocv_sort_modules_by_deps __lst)
break()
endif()
else()
message(FATAL_ERROR WARNING "Unresolved dependencies or loop in dependency graph (${length_after})\n"
message(FATAL_ERROR "FATAL: Unresolved dependencies or loop in dependency graph (${length_after})\n"
"Processed ${__lst}: ${${__lst}}\n"
"Good modules: ${result}\n"
"Bad modules: ${input}"
@ -652,12 +652,14 @@ endmacro()
# setup include paths for the list of passed modules
macro(ocv_target_include_modules target)
foreach(d ${ARGN})
if(d MATCHES "^opencv_" AND HAVE_${d})
if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
if(d MATCHES "^opencv_")
if(HAVE_${d} AND EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
ocv_target_include_directories(${target} "${OPENCV_MODULE_${d}_LOCATION}/include")
endif()
elseif(EXISTS "${d}")
ocv_target_include_directories(${target} "${d}")
else()
message(WARNING "Unexpected include: ${d} (module=${the_module})")
endif()
endforeach()
endmacro()
@ -686,14 +688,7 @@ macro(ocv_module_include_directories)
"${OPENCV_MODULE_${the_module}_LOCATION}/src"
"${CMAKE_CURRENT_BINARY_DIR}" # for precompiled headers
)
foreach(arg ${ARGN})
if(IS_ABSOLUTE "${arg}")
list(APPEND incs "${arg}")
else()
list(APPEND incs "${OPENCV_MODULE_${the_module}_LOCATION}/${arg}")
endif()
endforeach()
ocv_target_include_modules(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${incs})
ocv_target_include_modules(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${ARGN})
endmacro()

View File

@ -8,7 +8,7 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4189 /wd4505 -Wundef -Wmissing-declarati
ocv_add_module(cudev)
ocv_module_include_directories(opencv_core opencv_hal)
ocv_module_include_directories(opencv_core)
file(GLOB_RECURSE lib_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp")
file(GLOB lib_srcs "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp")

View File

@ -53,16 +53,16 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS
)
if(PROTOBUF_UPDATE_FILES)
file(GLOB proto_files "${CMAKE_CURRENT_SOURCE_DIR}/src/tensorflow/*.proto" "${CMAKE_CURRENT_SOURCE_DIR}/src/caffe/opencv-caffe.proto")
file(GLOB proto_files "${CMAKE_CURRENT_LIST_DIR}/src/tensorflow/*.proto" "${CMAKE_CURRENT_LIST_DIR}/src/caffe/opencv-caffe.proto")
set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) # required for tensorflow
protobuf_generate_cpp(fw_srcs fw_hdrs ${proto_files})
else()
file(GLOB fw_srcs "${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.cc" "${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/opencv-caffe.pb.cc")
file(GLOB fw_hdrs "${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/opencv-caffe.pb.h")
set(fw_inc "misc/caffe" "misc/tensorflow")
file(GLOB fw_srcs "${CMAKE_CURRENT_LIST_DIR}/misc/tensorflow/*.cc" "${CMAKE_CURRENT_LIST_DIR}/misc/caffe/opencv-caffe.pb.cc")
file(GLOB fw_hdrs "${CMAKE_CURRENT_LIST_DIR}/misc/tensorflow/*.h" "${CMAKE_CURRENT_LIST_DIR}/misc/caffe/opencv-caffe.pb.h")
set(fw_inc "${CMAKE_CURRENT_LIST_DIR}/misc/caffe" "${CMAKE_CURRENT_LIST_DIR}/misc/tensorflow")
endif()
ocv_module_include_directories(${fw_inc} src/ocl4dnn/include ${OPENCL_INCLUDE_DIRS})
ocv_module_include_directories(${fw_inc} ${CMAKE_CURRENT_LIST_DIR}/src/ocl4dnn/include ${OPENCL_INCLUDE_DIRS})
ocv_glob_module_sources(SOURCES ${fw_srcs})
ocv_create_module(libprotobuf ${LAPACK_LIBRARIES})
ocv_add_samples()