Problems building on Linux using cinderMakeApp.cmake with external dependencies

Hi, I’m trying to compile an application using Cinder on Ubuntu 16.04. I’m using CLion and CMake. The project has several other external dependencies and I’m having issues linking them. At first I tried to create the cmakelists file from scratch, but got a lot of Cinder-related linker errors. I decided to look at the Cinder samples for inspiration.

Now I’m trying to use the cinderMakeApp.cmake file instead of linking Cinder by hand which works great for Cinder itself, but not for the other external libs. Here’s what the file looks like–it seems like this should work:

`cmake_minimum_required(VERSION 3.5)
project(AIBackend)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fpermissive")

set(AI_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../include")
set(AI_SRC_DIR "${PROJECT_SOURCE_DIR}/../src")

include("$ENV{LIBCINDER0_9}/proj/cmake/modules/cinderMakeApp.cmake")

ci_make_app(
        SOURCES ${AI_SRC_DIR}/AIBackend.cpp ${AI_SRC_DIR}/aiLoader.cpp ${AI_SRC_DIR}/aiPicker.cpp ${AI_SRC_DIR}/aiSensorIO.cpp
        CINDER_PATH "$ENV{LIBCINDER0_9}"
        INCLUDES "${PROJECT_SOURCE_DIR}/../include" "$ENV{LIBCINDER0_9}/include" "$ENV{LIBPCL}" "$ENV{EIGEN}" "$ENV{DEPTHSENSESDK64}/include"
        LIBRARIES /opt/softkinetic/DepthSenseSDK/libDepthSense.so /opt/softkinetic/DepthSenseSDK/lib/libDepthSensePlugins.so /opt/softkinetic/DepthSenseSDK/lib/libusb-1.0.so
)`

I’m using the absolute path to the so files as a sanity check–I would much prefer to use an environment variable for their parent directory. I’ve tried variations on that theme with no luck. I also tried adding link_directories() in cinderMakeApp.cmake just to see if that might work, also no dice. I’m seeing tons of “undefined reference…” errors in the console related to the libs listed above. As I said, this is one of many external libs I need to link.

Any tips? They are much appreciated as cmake is not my forte. (obviously :slight_smile: )

Hey, you could try pass the DepthSenseSDK path to link_directories and then use just the library name for passing to LIBRARIES

i.e LIBRARIES DepthSense DepthSensePlugins usb-1.0

HTH,
Petros

I’ve been using cmake for a few years, and am just starting to look at cinder, starting with ubuntu 16.04.
I am very interested in your use case, as I expect to be running into the very same problem soon.
But I have no useful suggestions yet. Good luck!

Hi, I know it’s been a long time, but I returned to this process when setting up an automated build for this project. I’ll include the whole CMakeLists file below for those that are running into similar build issues (src/header files omitted):

cmake_minimum_required(VERSION 3.5)
project(AIBackend)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(AI_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../include")
set(AI_SRC_DIR "${PROJECT_SOURCE_DIR}/../src")

find_package(PkgConfig REQUIRED)

find_library( DEPTH_SENSE
    NAMES DepthSense DepthSensePlugins turbojpeg
    PATHS "$ENV{DEPTHSENSESDK64}/lib"
)

find_library( REAL_SENSE
    NAMES realsense
    PATHS "$ENV{LIBREALSENSE}/lib"
    NO_DEFAULT_PATH
)

find_library( LIBUSB_LIB
    NAMES usb-1.0
    PATHS "$ENV{LIBUSB}"
    NO_DEFAULT_PATH
)

pkg_search_module(UUID REQUIRED uuid)

find_package(Boost 1.48 COMPONENTS thread REQUIRED)
find_package(PCL 1.8 REQUIRED)

set(INCLUDE_FILES ...)
set(SOURCE_FILES ...)

get_filename_component( CINDER_PATH "$ENV{LIBCINDER0_9}" ABSOLUTE )
get_filename_component( SAMPLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE )

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

ci_make_app(
    SOURCES     ${SOURCE_FILES}
    INCLUDES    ${INCLUDE_FILES}
    CINDER_PATH ${CINDER_PATH}
    LIBRARIES   ${REAL_SENSE} ${DEPTH_SENSE} ${PCL} ${LIBUSB_LIB} ${UUID_LIBRARIES} 
)