Merge pull request #1930 from alalek:cmake_msvs_subfolders
This commit is contained in:
commit
f3ba1a361e
@ -485,6 +485,9 @@ macro(ocv_glob_module_sources)
|
||||
file(GLOB lib_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
|
||||
file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h")
|
||||
|
||||
ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs})
|
||||
ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail})
|
||||
|
||||
file(GLOB lib_cuda_srcs "src/cuda/*.cu")
|
||||
set(cuda_objs "")
|
||||
set(lib_cuda_hdrs "")
|
||||
@ -493,11 +496,9 @@ macro(ocv_glob_module_sources)
|
||||
file(GLOB lib_cuda_hdrs "src/cuda/*.hpp")
|
||||
|
||||
ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
endif()
|
||||
|
||||
source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs})
|
||||
|
||||
file(GLOB cl_kernels "src/opencl/*.cl")
|
||||
if(cl_kernels)
|
||||
ocv_include_directories(${OPENCL_INCLUDE_DIRS})
|
||||
@ -506,15 +507,13 @@ macro(ocv_glob_module_sources)
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp"
|
||||
COMMAND ${CMAKE_COMMAND} -DMODULE_NAME="${the_module_barename}" -DCL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake"
|
||||
DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake")
|
||||
source_group("OpenCL" FILES ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
|
||||
ocv_source_group("Src\\opencl\\kernels" FILES ${cl_kernels})
|
||||
ocv_source_group("Src\\opencl\\kernels\\autogenerated" FILES "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
|
||||
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
|
||||
endif()
|
||||
|
||||
ocv_set_module_sources(${ARGN} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
|
||||
SOURCES ${lib_srcs} ${lib_int_hdrs} ${cuda_objs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
|
||||
source_group("Include" FILES ${lib_hdrs})
|
||||
source_group("Include\\detail" FILES ${lib_hdrs_detail})
|
||||
endmacro()
|
||||
|
||||
# creates OpenCV module in current folder
|
||||
@ -692,8 +691,8 @@ function(ocv_add_perf_tests)
|
||||
if(NOT OPENCV_PERF_${the_module}_SOURCES)
|
||||
file(GLOB_RECURSE perf_srcs "${perf_path}/*.cpp")
|
||||
file(GLOB_RECURSE perf_hdrs "${perf_path}/*.hpp" "${perf_path}/*.h")
|
||||
source_group("Src" FILES ${perf_srcs})
|
||||
source_group("Include" FILES ${perf_hdrs})
|
||||
ocv_source_group("Src" DIRBASE "${perf_path}" FILES ${perf_srcs})
|
||||
ocv_source_group("Include" DIRBASE "${perf_path}" FILES ${perf_hdrs})
|
||||
set(OPENCV_PERF_${the_module}_SOURCES ${perf_srcs} ${perf_hdrs})
|
||||
endif()
|
||||
|
||||
@ -742,8 +741,8 @@ function(ocv_add_accuracy_tests)
|
||||
if(NOT OPENCV_TEST_${the_module}_SOURCES)
|
||||
file(GLOB_RECURSE test_srcs "${test_path}/*.cpp")
|
||||
file(GLOB_RECURSE test_hdrs "${test_path}/*.hpp" "${test_path}/*.h")
|
||||
source_group("Src" FILES ${test_srcs})
|
||||
source_group("Include" FILES ${test_hdrs})
|
||||
ocv_source_group("Src" DIRBASE "${test_path}" FILES ${test_srcs})
|
||||
ocv_source_group("Include" DIRBASE "${test_path}" FILES ${test_hdrs})
|
||||
set(OPENCV_TEST_${the_module}_SOURCES ${test_srcs} ${test_hdrs})
|
||||
endif()
|
||||
|
||||
|
@ -1,3 +1,22 @@
|
||||
# Debugging function
|
||||
function(ocv_cmake_dump_vars)
|
||||
cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN})
|
||||
set(regex "${DUMP_UNPARSED_ARGUMENTS}")
|
||||
get_cmake_property(_variableNames VARIABLES)
|
||||
set(VARS "")
|
||||
foreach(_variableName ${_variableNames})
|
||||
if(_variableName MATCHES "${regex}")
|
||||
set(VARS "${VARS}${_variableName}=${${_variableName}}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
if(DUMP_TOFILE)
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/${DUMP_TOFILE} "${VARS}")
|
||||
else()
|
||||
message(AUTHOR_WARNING "${VARS}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
# Search packages for host system instead of packages for target system
|
||||
# in case of cross compilation thess macro should be defined by toolchain file
|
||||
if(NOT COMMAND find_host_package)
|
||||
@ -601,7 +620,35 @@ endmacro()
|
||||
################################################################################################
|
||||
# short command to setup source group
|
||||
function(ocv_source_group group)
|
||||
cmake_parse_arguments(OCV_SOURCE_GROUP "" "" "GLOB" ${ARGN})
|
||||
file(GLOB srcs ${OCV_SOURCE_GROUP_GLOB})
|
||||
source_group(${group} FILES ${srcs})
|
||||
cmake_parse_arguments(SG "" "DIRBASE" "GLOB;GLOB_RECURSE;FILES" ${ARGN})
|
||||
set(files "")
|
||||
if(SG_FILES)
|
||||
list(APPEND files ${SG_FILES})
|
||||
endif()
|
||||
if(SG_GLOB)
|
||||
file(GLOB srcs ${SG_GLOB})
|
||||
list(APPEND files ${srcs})
|
||||
endif()
|
||||
if(SG_GLOB_RECURSE)
|
||||
file(GLOB_RECURSE srcs ${SG_GLOB_RECURSE})
|
||||
list(APPEND files ${srcs})
|
||||
endif()
|
||||
if(SG_DIRBASE)
|
||||
foreach(f ${files})
|
||||
file(RELATIVE_PATH fpart "${SG_DIRBASE}" "${f}")
|
||||
if(fpart MATCHES "^\\.\\.")
|
||||
message(AUTHOR_WARNING "Can't detect subpath for source_group command: Group=${group} FILE=${f} DIRBASE=${SG_DIRBASE}")
|
||||
set(fpart "")
|
||||
else()
|
||||
get_filename_component(fpart "${fpart}" PATH)
|
||||
if(fpart)
|
||||
set(fpart "/${fpart}") # add '/'
|
||||
string(REPLACE "/" "\\" fpart "${fpart}")
|
||||
endif()
|
||||
endif()
|
||||
source_group("${group}${fpart}" FILES ${f})
|
||||
endforeach()
|
||||
else()
|
||||
source_group(${group} FILES ${files})
|
||||
endif()
|
||||
endfunction()
|
||||
|
Loading…
Reference in New Issue
Block a user