Add CMakeLists files to generate and compile the sample applications on Ubuntu 14.04

This commit is contained in:
Abdelrahman Mahmoud 2016-03-18 14:28:55 -04:00
parent aff6fc8c10
commit cdeb071732
4 changed files with 258 additions and 4 deletions

162
CMakeLists.txt Executable file
View File

@ -0,0 +1,162 @@
cmake_minimum_required(VERSION 2.6)
set(rootProject cpp-sdk-samples)
project(${rootProject})
# CMake includes
include(cmake_modules/Macros.cmake) # Some custom macros we have writtens
# -------------------
# CMAKE - ENVIRONMENT
# --------------------
set(CXX_COMPILER_WARNINGS "-Wreturn-type" CACHE STRING "Compiler warnings to use")
set(CMAKE_VERBOSE ON CACHE BOOL "Verbose mode")
# Setup "Profile" build type
set(CMAKE_CXX_FLAGS_PROFILE "-O3 -pg")
set(CMAKE_C_FLAGS_PROFILE "-O3 -pg")
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "-pg")
set(CMAKE_MODULE_LINKER_FLAGS_PROFILE "-pg")
# Setup additional compiler warnings
status("Setting up compiler warnings")
if( MSVC )
# Force to always compile with W4
if( CMAKE_CXX_FLAGS MATCHES "/W[0-4]" )
string( REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4" )
endif()
elseif( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
# Update if necessary
set( CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} ${CXX_COMPILER_WARNINGS}" )
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
status("Updating compiler to make use of C++14")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(bitness 64) # We have a 64-bit machine
else()
set(bitness 32) # We have a 32-bit machine
endif()
status("Bitness detected: ${bitness}")
# Setup install locations
if( NOT RUNTIME_INSTALL_DIRECTORY )
set( RUNTIME_INSTALL_DIRECTORY "bin" CACHE STRING "Install sub-directory of CMAKE_INSTALL_PREFIX for RUNTIME targets (binaries, and *.dll on windows)." )
endif( NOT RUNTIME_INSTALL_DIRECTORY )
# --------------------
# LOCATE DEPENDENCIES
# --------------------
# OpenCV
# ----------------------------------------------------------------------------
# find_package OpenCV to get OpenCV_FOUND, OpenCV_INCLUDE_DIRS, OpenCV_LIBS, OpenCV_LINK_LIBRARIES
# ----------------------------------------------------------------------------
set( OPENCV_COMPONENTS ml highgui core imgproc objdetect )
if( DEFINED OpenCV_DIR ) # Force the user to tell us which OpenCV they want (otherwise find_package can find the wrong one, cache it and changes to OpenCV_DIR are ignored)
find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR})
if( NOT OpenCV_FOUND)
message(SEND_ERROR "Failed to find OpenCV. Double check that \"OpenCV_DIR\" to the root build directory of OpenCV.")
endif(NOT OpenCV_FOUND)
else( DEFINED OpenCV_DIR )
set( OpenCV_DIR "" CACHE PATH "Root directory for opencv BUILD directory." )
message(FATAL_ERROR "\"OpenCV_DIR\" not set. Please explicitly provide the path to the root build directory of OpenCV.")
endif( DEFINED OpenCV_DIR )
# Boost package
# ----------------------------------------------------------------------------
# BOOST_ROOT is needed by BoostConfig.cmake configuration file to
# look for the Boost includes / libraries:
# Boost_FOUND, Boost_INCLUDE_DIRS, Boost_LIBRARY_DIRS, Boost_LIBRARIES,Boost_VERSION
set(Boost_USE_MULTITHREADED ON)
set( BOOST_COMPONENTS system filesystem date_time regex thread timer chrono serialization log log_setup program_options)
set( BOOST_MIN_VERSION "1.55.0" CACHE STRING "Minimum version of boost you would like to link against (e.g. C:/BOOST_1_55_0 is 1.55.0" )
status("")
if( ANDROID )
find_host_package( Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
else( ANDROID )
find_package( Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
endif()
if( NOT Boost_FOUND )
if( NOT DEFINED BOOST_ROOT )
set( BOOST_ROOT "" CACHE PATH "Root directory for Boost." )
endif( NOT DEFINED BOOST_ROOT )
message( FATAL_ERROR "Failed to find Boost (or missing components). Double check that \"BOOST_ROOT\" is properly set")
endif( NOT Boost_FOUND )
# Affdex package
# ----------------------------------------------------------------------------
set (AFFDEX_FOUND FALSE)
if( DEFINED AFFDEX_DIR )
find_path(AFFDEX_INCLUDE_DIR FrameDetector.h
HINTS "${AFFDEX_DIR}/include" )
find_library(AFFDEX_LIBRARY NAMES affdex-native
HINTS "${AFFDEX_DIR}/lib" )
set(AFFDEX_INCLUDE_DIRS "${AFFDEX_INCLUDE_DIR}")
set(AFFDEX_LIBRARIES "${AFFDEX_LIBRARY}")
if (AFFDEX_INCLUDE_DIR AND AFFDEX_LIBRARY)
set(AFFDEX_FOUND TRUE)
endif (AFFDEX_INCLUDE_DIR AND AFFDEX_LIBRARY)
set(AFFDEX_DATA_DIR "${AFFDEX_DIR}/data")
if (NOT AFFDEX_FOUND)
message(FATAL_ERROR "Unable to find the Affdex found")
endif (NOT AFFDEX_FOUND)
else (DEFINED AFFDEX_DIR)
message(FATAL_ERROR "Please define AFFDEX_DIR")
endif (DEFINED AFFDEX_DIR)
add_subdirectory(opencv-webcam-demo)
add_subdirectory(video-demo)
# --------------------
# SUMMARY
# --------------------
status("${CMAKE_INCLUDE_DIRECTORIES}")
status( "------- SUMMARY ------- " )
status( "Boost version found = ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} (${Boost_VERSION})" )
foreach( comp ${BOOST_COMPONENTS} )
string( TOUPPER ${comp} COMP )
status( " - ${comp}" 1 THEN "${Boost_${COMP}_LIBRARY}" )
endforeach( comp )
status("")
status("Affdex")
foreach( lib ${AFFDEX_LIBRARIES} )
status( "${lib}")
endforeach( lib )
status("")
status( "OpenCV version found = ${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.${OpenCV_VERSION_PATCH} (${OpenCV_VERSION})" )
status( "OpenCV_LIB_DIR = ${OpenCV_DIR}/lib" )
foreach( lib ${OpenCV_LIBRARIES} )
foreach( comp ${OPENCV_COMPONENTS} )
if( ${lib} MATCHES ${comp} )
status( " - ${comp}" 1 THEN "${lib}" )
endif( ${lib} MATCHES ${comp} )
endforeach( comp )
endforeach( lib )
status("")
status( "Apps identified for building:" )
foreach( app ${${rootProject}_APPS} )
status( " - ${app}" )
endforeach( app ${${rootProject}_APPS} )

View File

@ -1,6 +1,6 @@
#Sample Apps for Affdex SDK for Windows
#Sample Apps for Affdex C++ SDK for Windows / Linux
Welcome to our repository on GitHub! Here you will find example code to get you started with our Affdex SDK 3.0 for Windows and begin emotion-enabling you own app! Documentation for the Windows SDK is at <a href=http://developer.affectiva.com/windows/>Affectiva's Developer Portal</a>.
Welcome to our repository on GitHub! Here you will find example code to get you started with our Affdex SDK 3.0 and begin emotion-enabling you own app! Documentation for the SDKs is available on the <a href=http://developer.affectiva.com/>Affectiva's Developer Portal</a>.
[![Build status](https://ci.appveyor.com/api/projects/status/pn2y9h8a3nnkiw41?svg=true)]
(https://ci.appveyor.com/project/ahamino/win-sdk-samples)
@ -8,22 +8,46 @@ Welcome to our repository on GitHub! Here you will find example code to get you
Dependencies
------------
*Windows*
- Affdex SDK 3.0 (32 bit)
- Visual Studio 2013 or higher
*Linux*
- Ubuntu 14.04 or higher or CentOS 7 or higher
- Affdex SDK 3.0
- CMake 2.8 or higher
- GCC 4.8 or higher
*Additional dependencies for the C++ projects*
*Additional dependencies*
- OpenCV 3.1
- Boost 1.59
Installation
------------
- Download Affdex SDK for windows [from here](http://developer.affectiva.com/downloads)
- Download Affdex SDK [from here](http://developer.affectiva.com/downloads)
- Sign up for an evaluation license [by submitting this form](http://www.affectiva.com/45-day-free-trial/)
*Windows*
- Install the SDK using MSI installer.
- The additional dependencies get installed automatically by NuGet.
*Ubuntu*
```bashrc
sudo apt-get install build-essential libopencv-dev libboost-dev cmake
wget http://developer.affectiva.com/downloads/linux
mkdir affdex-sdk
tar -xzvf affdex-cpp-sdk-3.0-linux-64bit.tar.gz -C affdex-sdk
export AFFDEX_DATA_DIR=affdex-sdk/data
git clone https://github.com/Affectiva/win-sdk-samples.git
mkdir build
cd build
cmake -DOpenCV_DIR=/usr/local/ -DAFFDEX_DIR=../affdex-sdk ../win-sdk-samples
make
```
OpenCV-webcam-demo (c++)
------------------

View File

@ -0,0 +1,34 @@
# --------------
# CMake file opencv-webcam-demo
# --------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
set(subProject opencv-webcam-demo)
PROJECT(${subProject})
file(GLOB SRCS *.c*)
file(GLOB HDRS *.h*)
if( ${CMAKE_VERSION} VERSION_GREATER 2.8.11 )
get_filename_component(PARENT_DIR ${PROJECT_SOURCE_DIR} DIRECTORY) # PATH was updated to DIRECTORY in 2.8.12
else()
get_filename_component(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH)
endif()
set(COMMON_HDRS "${PARENT_DIR}/common/")
file(GLOB COMMON_HDRS_FILES ${COMMON_HDRS}/*.h*)
add_executable(${subProject} ${SRCS} ${HDRS} ${COMMON_HDRS_FILES})
target_include_directories(${subProject} PRIVATE ${Boost_INCLUDE_DIRS} ${AFFDEX_INCLUDE_DIR} ${COMMON_HDRS})
target_link_libraries( ${subProject} ${AFFDEX_LIBRARIES} ${OpenCV_LIBS} ${Boost_LIBRARIES} )
#Add to the apps list
list( APPEND ${rootProject}_APPS ${subProject} )
set( ${rootProject}_APPS ${${rootProject}_APPS} PARENT_SCOPE )
# Installation steps
install( TARGETS ${subProject}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIRECTORY} )

34
video-demo/CMakeLists.txt Executable file
View File

@ -0,0 +1,34 @@
# --------------
# CMake file video-demo
# --------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
set(subProject video-demo)
PROJECT(${subProject})
file(GLOB SRCS *.c*)
file(GLOB HDRS *.h*)
if( ${CMAKE_VERSION} VERSION_GREATER 2.8.11 )
get_filename_component(PARENT_DIR ${PROJECT_SOURCE_DIR} DIRECTORY) # PATH was updated to DIRECTORY in 2.8.12
else()
get_filename_component(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH)
endif()
set(COMMON_HDRS "${PARENT_DIR}/common/")
file(GLOB COMMON_HDRS_FILES ${COMMON_HDRS}/*.h*)
add_executable(${subProject} ${SRCS} ${HDRS} ${COMMON_HDRS_FILES})
target_include_directories(${subProject} PRIVATE ${Boost_INCLUDE_DIRS} ${AFFDEX_INCLUDE_DIR} ${COMMON_HDRS})
target_link_libraries( ${subProject} ${AFFDEX_LIBRARIES} ${OpenCV_LIBS} ${Boost_LIBRARIES} )
#Add to the apps list
list( APPEND ${rootProject}_APPS ${subProject} )
set( ${rootProject}_APPS ${${rootProject}_APPS} PARENT_SCOPE )
# Installation steps
install( TARGETS ${subProject}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIRECTORY} )