2012-05-12 21:54:26 +08:00
|
|
|
set(the_description "All the selected OpenCV modules in a single binary")
|
2012-05-13 17:34:33 +08:00
|
|
|
set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE)
|
|
|
|
set(BUILD_opencv_world_INIT OFF)
|
2012-06-10 00:18:39 +08:00
|
|
|
|
2012-06-15 15:52:20 +08:00
|
|
|
if(IOS OR NOT BUILD_SHARED_LIBS)
|
|
|
|
set(OPENCV_MODULE_TYPE STATIC)
|
|
|
|
set(OPENCV_WORLD_FLAGS_PROPERTY STATIC_LIBRARY_FLAGS)
|
|
|
|
else()
|
|
|
|
set(OPENCV_WORLD_FLAGS_PROPERTY LINK_FLAGS)
|
2012-06-10 00:18:39 +08:00
|
|
|
endif()
|
2012-05-12 21:54:26 +08:00
|
|
|
|
2012-05-13 17:34:33 +08:00
|
|
|
ocv_add_module(world opencv_core)
|
2012-05-12 21:54:26 +08:00
|
|
|
|
|
|
|
if(MSVC)
|
2012-05-13 17:34:33 +08:00
|
|
|
foreach(_var CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_MODULE_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
|
|
|
CMAKE_EXE_LINKER_FLAGS_DEBUG CMAKE_MODULE_LINKER_FLAGS_DEBUG CMAKE_SHARED_LINKER_FLAGS_DEBUG)
|
|
|
|
string(REPLACE "/INCREMENTAL:NO" "/INCREMENTAL:YES" ${_var} "${${_var}}")
|
|
|
|
endforeach()
|
2012-05-12 21:54:26 +08:00
|
|
|
endif()
|
|
|
|
|
2012-05-13 17:34:33 +08:00
|
|
|
ocv_glob_module_sources()
|
|
|
|
ocv_module_include_directories()
|
|
|
|
ocv_create_module(SKIP_LINK)
|
2012-05-12 21:54:26 +08:00
|
|
|
|
2012-05-13 17:34:33 +08:00
|
|
|
#TODO: try to use try_compile to find real object file extension/location
|
2012-05-12 21:54:26 +08:00
|
|
|
if(CMAKE_GENERATOR MATCHES "^Visual.*$")
|
2012-05-13 17:34:33 +08:00
|
|
|
set(have_cfg 1)
|
|
|
|
set(objpath0 "<MODULE_NAME>.dir/<CONFIGURATION>/<SRC_NAME_WE>.obj")
|
2012-05-12 21:54:26 +08:00
|
|
|
elseif (CMAKE_GENERATOR MATCHES Xcode)
|
2012-05-13 17:34:33 +08:00
|
|
|
set(have_cfg 1)
|
|
|
|
set(objpath0 "OpenCV.build/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/<MODULE_NAME>.build/Objects-normal/$(CURRENT_ARCH)/<SRC_NAME_WE>.o")
|
2012-05-12 21:54:26 +08:00
|
|
|
else()
|
2012-05-13 17:34:33 +08:00
|
|
|
set(have_cfg 0)
|
|
|
|
set(objpath0 "CMakeFiles/<MODULE_NAME>.dir/<RELATIVE_SRC_NAME>.o")
|
|
|
|
if(MINGW OR MSVC)
|
|
|
|
set(objpath0 "${objpath0}bj")
|
|
|
|
endif()
|
2012-05-12 21:54:26 +08:00
|
|
|
endif()
|
|
|
|
|
2012-05-13 17:34:33 +08:00
|
|
|
set(objlist "")
|
|
|
|
foreach(m ${OPENCV_MODULE_${the_module}_DEPS})
|
|
|
|
# build order dependencies
|
|
|
|
add_dependencies(${the_module} ${m})
|
|
|
|
# link dependencies
|
|
|
|
string(REGEX REPLACE "(general|debug|optimized);opencv_[^;]*(;|$)" "" _link_deps "${${m}_LIB_DEPENDS}")
|
|
|
|
if(_link_deps)
|
|
|
|
target_link_libraries(${the_module} ${_link_deps})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(REGEX REPLACE "<MODULE_NAME>" "${m}" objpath1 "${${m}_BINARY_DIR}/${objpath0}")
|
2012-05-22 04:15:17 +08:00
|
|
|
foreach(srcname ${OPENCV_MODULE_${m}_SOURCES})
|
|
|
|
if(srcname MATCHES "\\.(cpp|mm|c|cxx|cc|o|obj)$")
|
|
|
|
if(srcname MATCHES "\\.(o|obj)$")
|
|
|
|
if(IS_ABSOLUTE "${srcname}")
|
|
|
|
set(objpath3 "${srcname}")
|
|
|
|
else()
|
|
|
|
set(objpath3 "${${m}_SOURCE_DIR}/${srcname}")
|
|
|
|
endif()
|
2012-05-21 22:56:07 +08:00
|
|
|
else()
|
2012-05-22 04:15:17 +08:00
|
|
|
if(IS_ABSOLUTE "${srcname}")
|
2012-06-06 21:24:41 +08:00
|
|
|
if(srcname MATCHES "/(qrc|moc)_[^/]*\\.cxx$")
|
|
|
|
# QT generated sources
|
|
|
|
file(RELATIVE_PATH srcname "${${m}_BINARY_DIR}" "${srcname}")
|
|
|
|
else()
|
|
|
|
file(RELATIVE_PATH srcname "${OPENCV_MODULE_${m}_LOCATION}" "${srcname}")
|
|
|
|
endif()
|
2012-05-22 04:15:17 +08:00
|
|
|
endif()
|
|
|
|
string(REPLACE ".." "__" srcname "${srcname}")
|
2013-11-08 16:39:34 +08:00
|
|
|
#NAME_WE intentionally not used since it interprets first period as start of extension (http://cmake.org/Bug/view.php?id=12282)
|
|
|
|
get_filename_component(srcname_we "${srcname}" NAME)
|
|
|
|
string(REGEX REPLACE "\\.[^.]+$" "" srcname_we "${srcname_we}")
|
2012-05-22 04:15:17 +08:00
|
|
|
string(REGEX REPLACE <SRC_NAME_WE> "${srcname_we}" objpath2 "${objpath1}")
|
|
|
|
string(REGEX REPLACE <RELATIVE_SRC_NAME> "${srcname}" objpath3 "${objpath2}")
|
|
|
|
endif()
|
|
|
|
if(CMAKE_GENERATOR MATCHES Makefiles)
|
2012-05-21 22:56:07 +08:00
|
|
|
file(RELATIVE_PATH objpath4 "${CMAKE_CURRENT_BINARY_DIR}" "${objpath3}")
|
2012-05-22 04:15:17 +08:00
|
|
|
else()
|
|
|
|
set(objpath4 ${objpath3})
|
2012-05-21 22:56:07 +08:00
|
|
|
endif()
|
2012-05-13 17:34:33 +08:00
|
|
|
list(APPEND objlist "\"${objpath4}\"")
|
2012-05-12 21:54:26 +08:00
|
|
|
endif()
|
2012-05-13 17:34:33 +08:00
|
|
|
endforeach()
|
2012-05-12 21:54:26 +08:00
|
|
|
endforeach()
|
|
|
|
|
2013-03-25 00:07:55 +08:00
|
|
|
|
|
|
|
macro(ios_include_3party_libs)
|
|
|
|
foreach(l ${ARGN})
|
|
|
|
add_dependencies(${the_module} ${l})
|
|
|
|
string(REGEX REPLACE "<MODULE_NAME>" "${l}" objpath1 "${CMAKE_BINARY_DIR}/3rdparty/${l}/${objpath0}")
|
|
|
|
file(GLOB sources ${CMAKE_SOURCE_DIR}/3rdparty/${l}/*.c)
|
|
|
|
foreach(srcname ${sources})
|
|
|
|
if(IS_ABSOLUTE "${srcname}")
|
|
|
|
file(RELATIVE_PATH srcname "${CMAKE_SOURCE_DIR}/3rdparty/${l}" "${srcname}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(REPLACE ".." "__" srcname "${srcname}")
|
2013-11-08 16:39:34 +08:00
|
|
|
#NAME_WE intentionally not used since it interprets first period as start of extension (http://cmake.org/Bug/view.php?id=12282)
|
|
|
|
get_filename_component(srcname_we "${srcname}" NAME)
|
|
|
|
string(REGEX REPLACE "\\.[^.]+$" "" srcname_we "${srcname_we}")
|
2013-03-25 00:07:55 +08:00
|
|
|
string(REGEX REPLACE <SRC_NAME_WE> "${srcname_we}" objpath2 "${objpath1}")
|
|
|
|
string(REGEX REPLACE <RELATIVE_SRC_NAME> "${srcname}" objpath3 "${objpath2}")
|
2013-08-21 20:44:09 +08:00
|
|
|
|
2013-03-25 00:07:55 +08:00
|
|
|
list(APPEND objlist "\"${objpath3}\"")
|
|
|
|
endforeach() # (srcname ${sources})
|
2013-08-21 20:44:09 +08:00
|
|
|
endforeach()
|
2014-04-18 19:42:47 +08:00
|
|
|
ocv_list_filterout(objlist jmemansi) # <<= dirty fix
|
2013-03-25 00:07:55 +08:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
if(IOS AND WITH_PNG)
|
|
|
|
ios_include_3party_libs(zlib libpng)
|
2013-08-21 20:44:09 +08:00
|
|
|
endif()
|
2013-03-25 00:07:55 +08:00
|
|
|
|
|
|
|
if(IOS AND WITH_JPEG)
|
|
|
|
ios_include_3party_libs(libjpeg)
|
2013-08-21 20:44:09 +08:00
|
|
|
endif()
|
2013-03-25 00:07:55 +08:00
|
|
|
|
2012-05-13 17:34:33 +08:00
|
|
|
string(REPLACE ";" " " objlist "${objlist}")
|
|
|
|
|
2012-05-12 21:54:26 +08:00
|
|
|
if(have_cfg)
|
2012-05-13 17:34:33 +08:00
|
|
|
string(REGEX REPLACE "<CONFIGURATION>" "Debug" objlist_dbg "${objlist}")
|
|
|
|
string(REGEX REPLACE "<CONFIGURATION>" "Release" objlist_rls "${objlist}")
|
2012-06-15 15:52:20 +08:00
|
|
|
set_target_properties(${the_module} PROPERTIES
|
|
|
|
${OPENCV_WORLD_FLAGS_PROPERTY}_DEBUG ${objlist_dbg}
|
|
|
|
${OPENCV_WORLD_FLAGS_PROPERTY}_RELEASE ${objlist_rls})
|
2012-05-12 21:54:26 +08:00
|
|
|
else()
|
2012-05-13 17:34:33 +08:00
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/world_objects.list" "${objlist}")
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/world_objects.list" "${CMAKE_CURRENT_BINARY_DIR}/world_objects.rsp" OUTPUT_QUIET)
|
2012-06-15 15:52:20 +08:00
|
|
|
set_target_properties(${the_module} PROPERTIES
|
|
|
|
${OPENCV_WORLD_FLAGS_PROPERTY} "@${CMAKE_CURRENT_BINARY_DIR}/world_objects.rsp")
|
2012-05-12 21:54:26 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
ocv_add_precompiled_headers(${the_module})
|