I have worked out how to make my cmake compile, but now deploying with libraries is confusing me greatly.
As you can see below “target_link_libraries(my_project ${libavcodec_LIBRARIES})” allows me to use this code, but how do I package that library with “cpack” so that I don’t need a user to install it? I have been looking everywhere to understand this…
Thank you so much! Any tutorial or something? How do I even find the necessary files if I just want to manually add them to the bundle?
cmake_minimum_required(VERSION 2.8.12)
project(my_project)
# if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_STANDARD 17)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "-I /usr/local/include -L /usr/local/lib -l tensorflow -Wall -Os -g ${CMAKE_CXX_FLAGS}")
# -I /usr/local/include -L /usr/local/lib -l tensorflow -std=c++17
message("CMAKE_COMPILER_IS_GNUCXX is True")
message("option is: ${CMAKE_CXX_FLAGS}")
endif() #(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# endif (CMAKE_COMPILER_IS_GNUCXX)
find_package(PkgConfig)
pkg_check_modules(libavcodec REQUIRED libavcodec)
pkg_check_modules(libavformat REQUIRED libavformat)
pkg_check_modules(libavdevice REQUIRED libavdevice)
pkg_check_modules(libavutil REQUIRED libavutil)
pkg_check_modules(libswscale REQUIRED libswscale)
pkg_check_modules(sdl REQUIRED sdl)
add_compile_definitions(${libavcodec_CFLAGS_OTHER})
add_compile_definitions(${libavformat_CFLAGS_OTHER})
add_compile_definitions(${libavdevice_CFLAGS_OTHER})
add_compile_definitions(${libavutil_CFLAGS_OTHER})
find_package( OpenCV REQUIRED )
add_compile_definitions(${OpenCV_CFLAGS_OTHER})
add_compile_definitions(${libswscale_CFLAGS_OTHER})
add_executable(my_project my_project.cpp)
target_link_libraries(my_project "-framework Cocoa")
target_link_libraries(my_project "-framework IOKit")
target_link_libraries(my_project ${libavcodec_LIBRARIES})
target_link_libraries(my_project ${libavformat_LIBRARIES})
target_link_libraries(my_project ${libavdevice_LIBRARIES})
target_link_libraries(my_project ${libavutil_LIBRARIES})
target_link_libraries(my_project ${OpenCV_LIBRARIES})
target_link_libraries(my_project ${libswscale_LIBRARIES})
# target_link_libraries(my_project ${sdl_LIBRARIES})
SET(dlib_ROOT "~/Documents/Code/my_project/build/dlib-19.24/")
target_link_libraries(my_project dlib)
install(
TARGETS my_project
COMPONENT Application
)
set(CPACK_COMPONENTS_ALL Application Libraries)
set(CPACK_COMPONENT_APPLICATION_DISPLAY_NAME "Analysis")
set(CPACK_COMPONENT_APPLICATION_LIBRARY_NAME "Video Libaries")
set(CPACK_GENERATOR "TGZ")
if (WIN32)
list(APPEND CPACK_GENERATOR "NSIS")
elseif (APPLE)
list(APPEND CPACK_GENERATOR "Bundle")
endif(WIN32)
set(CPACK_SOURCE_GENERATOR "ZIP;TGZ")
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
set(CPACK_PACKAGE_VERSION_MAJOR "${my_project_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${my_project_VERSION_MINOR}")
include(CPack)