@@ -866,7 +866,9 @@ macro(ocv_check_modules define)
866
866
foreach (flag ${${define} _LDFLAGS})
867
867
if (flag MATCHES "^-L(.*)" )
868
868
list (APPEND _libs_paths ${CMAKE_MATCH_1} )
869
- elseif (IS_ABSOLUTE "${flag} " )
869
+ elseif (IS_ABSOLUTE "${flag} "
870
+ OR flag STREQUAL "-lstdc++"
871
+ )
870
872
list (APPEND _libs "${flag} " )
871
873
elseif (flag MATCHES "^-l(.*)" )
872
874
set (_lib "${CMAKE_MATCH_1} " )
@@ -1578,24 +1580,41 @@ endfunction()
1578
1580
1579
1581
1580
1582
function (ocv_add_external_target name inc link def)
1581
- if (BUILD_SHARED_LIBS )
1583
+ if (BUILD_SHARED_LIBS AND link )
1582
1584
set (imp IMPORTED )
1583
1585
endif ()
1584
1586
add_library (ocv.3rdparty.${name} INTERFACE ${imp} )
1585
- set_target_properties (ocv.3rdparty.${name} PROPERTIES
1586
- INTERFACE_INCLUDE_DIRECTORIES "${inc} "
1587
- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${inc} "
1588
- INTERFACE_COMPILE_DEFINITIONS "${def} " )
1589
- # When cmake version is greater than or equal to 3.11, INTERFACE_LINK_LIBRARIES no longer applies to interface library
1590
- # See https://github.com/opencv/opencv/pull/18658
1591
- if (CMAKE_VERSION VERSION_LESS 3.11)
1592
- set_target_properties (ocv.3rdparty.${name} PROPERTIES
1593
- INTERFACE_LINK_LIBRARIES "${link} " )
1594
- else ()
1595
- target_link_libraries (ocv.3rdparty.${name} INTERFACE ${link} )
1587
+ if (def)
1588
+ if (NOT (CMAKE_VERSION VERSION_LESS "3.11.0" )) # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1264 : eliminates "Cannot specify compile definitions for imported target" error message
1589
+ target_compile_definitions (ocv.3rdparty.${name} INTERFACE "${def} " )
1590
+ else ()
1591
+ set_target_properties (ocv.3rdparty.${name} PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${def} " )
1592
+ endif ()
1593
+ endif ()
1594
+ if (inc)
1595
+ if (NOT (CMAKE_VERSION VERSION_LESS "3.11.0" )) # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1264 : eliminates "Cannot specify compile definitions for imported target" error message
1596
+ target_include_directories (ocv.3rdparty.${name} SYSTEM INTERFACE "$<BUILD_INTERFACE:${inc} >" )
1597
+ else ()
1598
+ set_target_properties (ocv.3rdparty.${name} PROPERTIES
1599
+ INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${inc} >"
1600
+ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${inc} >"
1601
+ )
1602
+ endif ()
1603
+ endif ()
1604
+ if (link)
1605
+ # When cmake version is greater than or equal to 3.11, INTERFACE_LINK_LIBRARIES no longer applies to interface library
1606
+ # See https://github.com/opencv/opencv/pull/18658
1607
+ if (CMAKE_VERSION VERSION_LESS 3.11)
1608
+ set_target_properties (ocv.3rdparty.${name} PROPERTIES
1609
+ INTERFACE_LINK_LIBRARIES "${link} " )
1610
+ else ()
1611
+ target_link_libraries (ocv.3rdparty.${name} INTERFACE ${link} )
1612
+ endif ()
1596
1613
endif ()
1597
- #
1598
- if (NOT BUILD_SHARED_LIBS )
1614
+ # to install used target only upgrade CMake
1615
+ if (NOT BUILD_SHARED_LIBS
1616
+ AND CMAKE_VERSION VERSION_LESS "3.13.0" # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/2152
1617
+ )
1599
1618
install (TARGETS ocv.3rdparty.${name} EXPORT OpenCVModules)
1600
1619
endif ()
1601
1620
endfunction ()
0 commit comments