Skip to content

Commit

Permalink
Linux: statically linked libjpeg-turbo into openpnp-capture lib
Browse files Browse the repository at this point in the history
  • Loading branch information
trcwm committed Sep 28, 2017
1 parent b1d3458 commit 3f39179
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 43 deletions.
59 changes: 16 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,15 @@ ELSEIF(APPLE)

ELSEIF(UNIX)

# compile libjpeg-turbo for MJPEG decoding support
# right now, we need to disable SIMD because it
# causes a compile problem.. we need to fix this
# later...

set(ENABLE_SHARED OFF)
set(WITH_SIMD OFF)
add_subdirectory(linux/contrib/libjpeg-turbo-dev)

# Compile add libjpeg-turbo using Autotools
# as CMAKE is not supported on linux :-/
#
# Note that will do not install the project
# but statically link with it later..
#

#include(ExternalProject)
#ExternalProject_Add(turbojpeg
# SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/linux/contrib/libjpeg-turbo-1.5.2
# CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/linux/contrib/libjpeg-turbo-1.5.2/configure
# BUILD_COMMAND ${MAKE}
# INSTALL_COMMAND "")

# set the platform identification string
add_definitions(-D__PLATFORM__="Linux ${COMPILERBITS}")

Expand All @@ -133,39 +125,20 @@ ELSEIF(UNIX)
linux/mjpeghelper.cpp
linux/yuvconverters.cpp)

# need pthreads for std::thread
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# force include directories for libjpeg-turbo
include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/linux/contrib/libjpeg-turbo-dev")

# create our capture library
add_library(openpnp-capture SHARED ${SOURCE})
target_link_libraries(openpnp-capture Threads::Threads)
target_link_libraries(openpnp-capture turbojpeg-static)

# add pthreads library
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(openpnp-capture Threads::Threads)

# this will force using the static lib, which will will eventually want to
# do for all dependencies so we don't have to distribute them with our .so
# find_library(TURBOJPEG_LIB NAMES turbojpeg.a turbojpeg)

# but libturbojpeg is not compiled with -fPIC which means it can't be static
# linked into a shared lib. So instead we will eventually have to build it
# ourselves with -fPIC and then we can use this to specify the location:
# ADD_LIBRARY(turbojpeg STATIC IMPORTED)
# SET_TARGET_PROPERTIES(turbojpeg PROPERTIES IMPORTED_LOCATION ../libjpegturbo/whatever/libjpegturbo.a)
# add turbojpeg-static library
target_link_libraries(openpnp-capture turbojpeg-static)

# this lets us specify the full path of the turbojpeg library. this is required
# because of a bug in the library distribution that does not create the correct
# symlink. See https://github.com/OpenKinect/libfreenect2/issues/36
# Note: We should be able to specify this on the command line, as well, so we don't have
# to hardcode the path here.

#ADD_LIBRARY(turbojpeg SHARED IMPORTED)
#if(EXISTS "/usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.1.0")
# SET_TARGET_PROPERTIES(turbojpeg PROPERTIES IMPORTED_LOCATION /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.1.0)
#else()
# SET_TARGET_PROPERTIES(turbojpeg PROPERTIES IMPORTED_LOCATION /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.0.0)
#endif()

#target_link_libraries(openpnp-capture turbojpeg)

# add linux-specific test application
add_subdirectory(linux/tests)

Expand Down
2 changes: 2 additions & 0 deletions linux/contrib/libjpeg-turbo-dev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8.12)

project(libjpeg-turbo C)
set(VERSION 1.5.80)
set(VERBOSE 1)
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
Expand Down Expand Up @@ -482,6 +483,7 @@ endif()
# Include directories and compiler definitions
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})

message("Added DIRS: ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}")

###############################################################################
# TARGETS
Expand Down

0 comments on commit 3f39179

Please sign in to comment.