Commit 514cfefc2696d92dfca1273cda4394239c105dd5
1 parent
5aec6fb3
Added example thirdparty cmakelist file
Showing
1 changed file
with
108 additions
and
0 deletions
share/openbr/example/CMakeLists.txt
0 → 100644
| 1 | +set(BR_WITH_EXAMPLE OFF CACHE BOOL "Build Example application.") | |
| 2 | + | |
| 3 | +if(${BR_WITH_EXAMPLE}) | |
| 4 | + | |
| 5 | +set(CMAKE_INCLUDE_CURRENT_DIR ON) | |
| 6 | + | |
| 7 | +aux_source_directory(. SRC) | |
| 8 | + | |
| 9 | +# Build executable | |
| 10 | +if(APPLE) | |
| 11 | + set_source_files_properties(${NATIVE_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") | |
| 12 | + add_executable(Example MACOSX_BUNDLE ${NATIVE_ICON} ${SRC}) | |
| 13 | + set_target_properties(Example PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_INSTALL_PREFIX}/Info.plist") | |
| 14 | +else() | |
| 15 | + add_executable(Example WIN32 ${SRC}) | |
| 16 | +endif() | |
| 17 | + | |
| 18 | +qt5_use_modules(Example ${QT_DEPENDENCIES}) | |
| 19 | + | |
| 20 | +target_link_libraries(Example openbr ${Qt5Core_QTMAIN_LIBRARIES}) | |
| 21 | + | |
| 22 | +install(TARGETS Example RUNTIME DESTINATION bin BUNDLE DESTINATION .) | |
| 23 | + | |
| 24 | +file(GLOB HEADERS *.h) | |
| 25 | +install(FILES ${HEADERS} DESTINATION include/example) | |
| 26 | + | |
| 27 | +# Install openbr.bib so OpenBR can locate it's SDK (or so it thinks) | |
| 28 | +install(FILES ${CMAKE_SOURCE_DIR}/share/openbr/openbr.bib DESTINATION share/openbr/) | |
| 29 | + | |
| 30 | +# Make OSX bundle | |
| 31 | +if(APPLE) | |
| 32 | + set(BUNDLE_DIR "${CMAKE_INSTALL_PREFIX}/Example.app") | |
| 33 | + | |
| 34 | + install(FILES ${_qt5Core_install_prefix}/plugins/platforms/libqcocoa.dylib | |
| 35 | + DESTINATION ${BUNDLE_DIR}/Contents/MacOS/platforms) | |
| 36 | + | |
| 37 | + install(FILES ${CMAKE_INSTALL_PREFIX}/bin/br | |
| 38 | + DESTINATION ${BUNDLE_DIR}/Contents/MacOS | |
| 39 | + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE GROUP_WRITE WORLD_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) | |
| 40 | + | |
| 41 | + set(APPS "${BUNDLE_DIR}/Contents/MacOS/br") | |
| 42 | + set(LIBS "platforms/libqcocoa.dylib") | |
| 43 | + | |
| 44 | + # To simplify things, I'm assuming that OpenCV is installed in /usr/local/ | |
| 45 | + set(DIRS "/usr/local/" "${CMAKE_INSTALL_PREFIX}/lib" ${_qt5Core_install_prefix}) # directories to search for prerequisites | |
| 46 | + | |
| 47 | + install(CODE " | |
| 48 | + include(BundleUtilities) | |
| 49 | + fixup_bundle(\"${APPS}\" \"${LIBS}\" \"${DIRS}\") | |
| 50 | + " DESTINATION bin COMPONENT Runtime) | |
| 51 | + | |
| 52 | + # Just put the installed files into the bundle (there's a less clunky way to do this) | |
| 53 | + install(DIRECTORY ${CMAKE_INSTALL_PREFIX}/share | |
| 54 | + DESTINATION ${BUNDLE_DIR}/Contents/MacOS) | |
| 55 | +endif() | |
| 56 | + | |
| 57 | +if (BR_PACKAGE_THIRDPARTY) | |
| 58 | + | |
| 59 | +set(CPACK_PACKAGE_NAME "Example") | |
| 60 | +set(CPACK_PACKAGE_VENDOR “Company”) | |
| 61 | +set(CPACK_PACKAGE_DESCRIPTION "Example") | |
| 62 | +set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) | |
| 63 | +set(CPACK_PACKAGE_VERSION_MAJOR 1) | |
| 64 | +set(CPACK_PACKAGE_VERSION_MINOR 0) | |
| 65 | +set(CPACK_PACKAGE_VERSION_PATCH 0) | |
| 66 | +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") | |
| 67 | +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt") | |
| 68 | +set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") | |
| 69 | +set(SHARE_DIR “${OPENBR_DIR}/share/example”) | |
| 70 | + | |
| 71 | +# Define resources | |
| 72 | +if(WIN32) | |
| 73 | + set(NATIVE_ICON "${OPENBR_DIR}/icons/example.ico") | |
| 74 | +elseif(APPLE) | |
| 75 | + set(CPACK_PACKAGE_ICON "${OPENBR_DIR}/icons/example.png") | |
| 76 | + set(NATIVE_ICON "${OPENBR_DIR}/icons/example.icns") | |
| 77 | +else() | |
| 78 | + set(CPACK_PACKAGE_ICON "${OPENBR_DIR}/icons/example.png") | |
| 79 | + set(NATIVE_ICON "${OPENBR_DIR}/icons/example.png") | |
| 80 | +endif() | |
| 81 | + | |
| 82 | +set(CPACK_PACKAGE_EXECUTABLES “Example” "Example") | |
| 83 | +set(CPACK_CREATE_DESKTOP_LINKS "Example") | |
| 84 | +if(CMAKE_HOST_WIN32) | |
| 85 | + set(CPACK_NSIS_MUI_ICON ${NATIVE_ICON}) | |
| 86 | + set(CPACK_NSIS_MUI_UNIICON ${NATIVE_ICON}) | |
| 87 | + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") | |
| 88 | + set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") | |
| 89 | + endif() | |
| 90 | + set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\ Example.exe") | |
| 91 | + set(CPACK_NSIS_EXECUTABLES_DIRECTORY "bin\\\\") | |
| 92 | + set(CPACK_CREATE_DESKTOP_LINKS "Example") | |
| 93 | + set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "SetOutPath \\\"$INSTDIR\\\\bin\\\"\\nCreateShortCut \\\"$DESKTOP\\\\Example.lnk\\\" \\\"$INSTDIR\\\\bin\\\\ Example.exe\\\"\\nCreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Example.lnk\\\" \\\"$INSTDIR\\\\bin\\\\Example.exe\\\"") | |
| 94 | + set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "Delete \\\"$DESKTOP\\\\Example.lnk\\\"") | |
| 95 | +elseif(CMAKE_HOST_APPLE) | |
| 96 | + configure_file("${CMAKE_SOURCE_DIR}/README.md" "README.txt" COPYONLY) | |
| 97 | + set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_BINARY_DIR}/README.txt") | |
| 98 | + set(CPACK_BUNDLE_NAME ${CPACK_PACKAGE_NAME}) | |
| 99 | + set(CPACK_BUNDLE_ICON example) | |
| 100 | + set(MACOSX_BUNDLE_ICON_FILE example) | |
| 101 | + configure_file("${SHARE_DIR}/Info.plist.in" "${CMAKE_INSTALL_PREFIX}/Info.plist") | |
| 102 | +else() | |
| 103 | + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "scott.klum@gmail.com") | |
| 104 | +endif() | |
| 105 | +endif() | |
| 106 | +endif() | |
| 107 | + | |
| 108 | +include(CPack) | ... | ... |