cmake: fix order of headers
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Wed, 31 Mar 2021 23:14:45 +0000 (23:14 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Wed, 31 Mar 2021 23:16:46 +0000 (23:16 +0000)
- cmake uses filesystem's order which may vary
- unpredictable headers order may cause build failures (primary bindings)

cmake/OpenCVModule.cmake

index efb6ca8fa919084b09b7044682cdd6dee8330aa4..bcbca833f28ef57428f371311b726a3ae6960d70 100644 (file)
@@ -876,7 +876,9 @@ endmacro()
 macro(_ocv_create_module)
 
   ocv_compiler_optimization_process_sources(OPENCV_MODULE_${the_module}_SOURCES OPENCV_MODULE_${the_module}_DEPS_EXT ${the_module})
-  set(OPENCV_MODULE_${the_module}_HEADERS ${OPENCV_MODULE_${the_module}_HEADERS} CACHE INTERNAL "List of header files for ${the_module}")
+  set(__module_headers ${OPENCV_MODULE_${the_module}_HEADERS})
+  list(SORT __module_headers)  # fix headers order, useful for bindings
+  set(OPENCV_MODULE_${the_module}_HEADERS ${__module_headers} CACHE INTERNAL "List of header files for ${the_module}")
   set(OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES} CACHE INTERNAL "List of source files for ${the_module}")
 
   # The condition we ought to be testing here is whether ocv_add_precompiled_headers will