2018-05-02 21:15:30 -07:00
|
|
|
project(cscore)
|
|
|
|
|
|
2018-08-19 23:22:52 -07:00
|
|
|
include(SubDirList)
|
2019-06-23 12:44:28 -07:00
|
|
|
include(CompileWarnings)
|
|
|
|
|
include(AddTest)
|
2020-09-20 12:31:20 -04:00
|
|
|
include(LinkMacOSGUI)
|
2018-08-19 23:22:52 -07:00
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
file(GLOB cscore_native_src src/main/native/cpp/*.cpp)
|
2018-10-27 00:19:38 -07:00
|
|
|
file(GLOB cscore_linux_src src/main/native/linux/*.cpp)
|
|
|
|
|
file(GLOB cscore_osx_src src/main/native/osx/*.cpp)
|
2022-12-25 07:36:00 -08:00
|
|
|
file(GLOB cscore_osx_objc_src src/main/native/objcpp/*.mm)
|
2018-10-27 00:19:38 -07:00
|
|
|
file(GLOB cscore_windows_src src/main/native/windows/*.cpp)
|
|
|
|
|
|
|
|
|
|
add_library(cscore ${cscore_native_src})
|
|
|
|
|
set_target_properties(cscore PROPERTIES DEBUG_POSTFIX "d")
|
|
|
|
|
|
2024-07-11 18:01:05 -04:00
|
|
|
if(APPLE)
|
|
|
|
|
target_sources(cscore PRIVATE ${cscore_osx_src} ${cscore_osx_objc_src})
|
|
|
|
|
target_compile_options(cscore PRIVATE "-fobjc-arc")
|
|
|
|
|
set_target_properties(
|
|
|
|
|
cscore
|
|
|
|
|
PROPERTIES
|
|
|
|
|
LINK_FLAGS
|
2025-04-30 22:02:59 +08:00
|
|
|
"-framework CoreFoundation -framework AVFoundation -framework Foundation -framework CoreMedia -framework CoreVideo -framework IOKit"
|
2024-07-11 18:01:05 -04:00
|
|
|
)
|
|
|
|
|
elseif(MSVC)
|
2018-10-27 00:19:38 -07:00
|
|
|
target_sources(cscore PRIVATE ${cscore_windows_src})
|
2019-06-23 12:44:28 -07:00
|
|
|
target_compile_definitions(cscore PUBLIC -DNOMINMAX)
|
|
|
|
|
target_compile_definitions(cscore PRIVATE -D_CRT_SECURE_NO_WARNINGS)
|
2024-07-11 18:01:05 -04:00
|
|
|
else()
|
|
|
|
|
target_sources(cscore PRIVATE ${cscore_linux_src})
|
2018-10-27 00:19:38 -07:00
|
|
|
endif()
|
|
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
target_include_directories(
|
|
|
|
|
cscore
|
|
|
|
|
PUBLIC
|
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
|
|
|
|
$<INSTALL_INTERFACE:${include_dest}/cscore>
|
2024-08-11 02:39:17 -04:00
|
|
|
PRIVATE src/main/native/cpp
|
2023-11-30 19:52:21 -05:00
|
|
|
)
|
2019-06-23 12:44:28 -07:00
|
|
|
wpilib_target_warnings(cscore)
|
2022-05-07 10:54:14 -07:00
|
|
|
target_link_libraries(cscore PUBLIC wpinet wpiutil ${OpenCV_LIBS})
|
2018-10-27 00:19:38 -07:00
|
|
|
|
|
|
|
|
set_property(TARGET cscore PROPERTY FOLDER "libraries")
|
|
|
|
|
|
2023-09-18 01:17:32 +02:00
|
|
|
install(TARGETS cscore EXPORT cscore)
|
2024-04-10 22:04:22 -07:00
|
|
|
export(TARGETS cscore FILE cscore.cmake NAMESPACE cscore::)
|
2018-10-27 00:19:38 -07:00
|
|
|
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cscore")
|
|
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
configure_file(cscore-config.cmake.in ${WPILIB_BINARY_DIR}/cscore-config.cmake)
|
2023-11-21 14:48:32 -05:00
|
|
|
install(FILES ${WPILIB_BINARY_DIR}/cscore-config.cmake DESTINATION share/cscore)
|
|
|
|
|
install(EXPORT cscore DESTINATION share/cscore)
|
2018-10-27 00:19:38 -07:00
|
|
|
|
2023-08-30 21:17:09 -07:00
|
|
|
subdir_list(cscore_examples "${CMAKE_CURRENT_SOURCE_DIR}/examples")
|
2018-10-27 00:19:38 -07:00
|
|
|
foreach(example ${cscore_examples})
|
|
|
|
|
file(GLOB cscore_example_src examples/${example}/*.cpp)
|
2020-08-29 11:30:45 -07:00
|
|
|
unset(add_libs)
|
|
|
|
|
if(${example} STREQUAL "usbviewer")
|
|
|
|
|
if(TARGET wpigui)
|
|
|
|
|
set(add_libs wpigui)
|
|
|
|
|
else()
|
|
|
|
|
unset(cscore_example_src)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2018-10-27 00:19:38 -07:00
|
|
|
if(cscore_example_src)
|
|
|
|
|
add_executable(cscore_${example} ${cscore_example_src})
|
2019-06-23 12:44:28 -07:00
|
|
|
wpilib_target_warnings(cscore_${example})
|
2020-09-20 12:31:20 -04:00
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
if(${example} STREQUAL "usbviewer")
|
2020-09-20 12:31:20 -04:00
|
|
|
wpilib_link_macos_gui(cscore_${example})
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-08-29 11:30:45 -07:00
|
|
|
target_link_libraries(cscore_${example} cscore ${add_libs})
|
2019-06-10 20:04:34 -07:00
|
|
|
set_property(TARGET cscore_${example} PROPERTY FOLDER "examples")
|
2018-10-27 00:19:38 -07:00
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
if(WITH_TESTS)
|
2019-06-23 12:44:28 -07:00
|
|
|
wpilib_add_test(cscore src/test/native/cpp)
|
2024-07-19 00:10:26 -04:00
|
|
|
target_link_libraries(cscore_test cscore googletest)
|
2019-06-23 12:44:28 -07:00
|
|
|
endif()
|