Skip to content

Commit

Permalink
From YACCLAB to YACCLAB 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prittt committed Dec 21, 2017
1 parent a60320b commit 699bbb9
Show file tree
Hide file tree
Showing 39 changed files with 160 additions and 10,251 deletions.
30 changes: 16 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/*.vcxproj
/*.filters
/*.sln
/*.opensdf
/*.suo
/*.sdf
/*.user
/CMakeCache.txt
/cmake_install.cmake
**/*.vcxproj
**/*.filters
**/*.sln
**/*.opensdf
**/*.suo
**/*.sdf
**/*.user

/Release
/Debug
build
bin
input
output
CMakeFiles
/[Bb]in*
/[Bb]uild*

/CMakeCache.txt
/cmake_install.cmake
/CMakeFiles

**/*.jpg
**/*.png
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ sudo: required

matrix:
include:
# mac
# mac (x86 build)
- os: osx
osx_image: xcode7.3
#addons:
# brew:
# packages:
env:
- BUILD_TARGET=mac
# linux
# linux (x64 build)
- os: linux
addons:
apt:
Expand Down
120 changes: 79 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Copyright(c) 2016 - 2017 Costantino Grana, Federico Bolelli, Lorenzo Baraldi and Roberto Vezzani
# Copyright(c) 2016 - 2017 Federico Bolelli, Costantino Grana, Michele Cancilla, Lorenzo Baraldi and Roberto Vezzani
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met :
#
#
# *Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and / or other materials provided with the distribution.
#
#
# * Neither the name of YACCLAB nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand All @@ -29,7 +29,6 @@
cmake_minimum_required(VERSION 3.0.0)

set (ProjectName "YACCLAB")

project (${ProjectName})

#Suppress creation of ZERO_CHECK
Expand All @@ -38,8 +37,12 @@ set(CMAKE_SUPPRESS_REGENERATION true)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Install prefix" FORCE)

#Set YACCLAB_dataset download variable
set(YACCLAB_DOWNLOAD_DATASET ON CACHE BOOL "If true the YACCLAB dataset will be downloaded automatically")
#Set YACCLAB variables
set(YACCLAB_DOWNLOAD_DATASET OFF CACHE BOOL "If flagged the YACCLAB dataset will be automatically downloaded")
set(YACCLAB_INPUT_DATASET_PATH "${CMAKE_INSTALL_PREFIX}/input" CACHE PATH "'input' dataset path")
set(YACCLAB_OUTPUT_RESULTS_PATH "${CMAKE_INSTALL_PREFIX}/output" CACHE PATH "'output' results path")
set(YACCLAB_OS "${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}" CACHE STRING "" FORCE)
set(YACCLAB_IS_TRAVIS_CI OFF CACHE BOOL "This variable is used to handle travis-ci parameters, do not change its value")

if(MSVC)
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
Expand All @@ -53,12 +56,27 @@ include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
if(DEFINED CMAKE_BUILD_TYPE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})
endif()

message(STATUS "Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang" OR CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
if(NOT CMAKE_CXX_FLAGS MATCHES "-m32" AND NOT CMAKE_CXX_FLAGS MATCHES "-m64")
set(CMAKE_CXX_FLAGS "-m32 ${CMAKE_CXX_FLAGS}" CACHE STRING "32-bit compiled" FORCE)
endif()
if(NOT CMAKE_C_FLAGS MATCHES "-m32" AND NOT CMAKE_C_FLAGS MATCHES "-m64")
set(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}" CACHE STRING "32-bit compiled" FORCE)
endif()
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
if(COMPILER_SUPPORTS_CXX11 AND NOT CMAKE_CXX_FLAGS MATCHES "-std=c\\+\\+11")
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}" CACHE STRING "Enable c++11" FORCE)
elseif(COMPILER_SUPPORTS_CXX0X AND NOT CMAKE_CXX_FLAGS MATCHES "-std=c\\+\\+11")
set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}" CACHE STRING "Enable c++11" FORCE)
elseif(NOT COMPILER_SUPPORTS_CXX11)
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no complete C++11 support. Please use a different C++ compiler.")
endif()
# Set compilation flag to avoid creation of debug info in release configuration under Linux
Expand All @@ -76,14 +94,16 @@ else()
message(STATUS "We are not able to check if ${CMAKE_CXX_COMPILER} compiler has complete C++11 support. YACCLAB may not work properly.")
endif()
endif()
message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS}")
message(STATUS "C flags: ${CMAKE_C_FLAGS}")


# ----------------------------------------------------------------------------
# Build & install layouts
# ----------------------------------------------------------------------------

# Save libs and executables in the same place
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}" CACHE PATH "Output directory for applications" )
set(YACCLAB_EXECUTABLE_OUTPUT_PATH "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Output directory for applications" )

# ----------------------------------------------------------------------------
# Solution folders
Expand All @@ -93,13 +113,12 @@ if(ENABLE_SOLUTION_FOLDERS)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
endif()

include_directories( "." )

# --------------------
# OpenCV
# --------------------

FIND_PACKAGE(OpenCV REQUIRED core imgcodecs imgproc)
set(OpenCV_REQUIRED_PACKAGES "core;imgcodecs;imgproc" CACHE STRING "OpenCV packages required by YACCLAB are already set")
FIND_PACKAGE(OpenCV REQUIRED ${OpenCV_REQUIRED_PACKAGES})
include_directories( ${OpenCV_INCLUDE_DIRS} )

if(MSVC)
Expand All @@ -117,39 +136,58 @@ endif()

include_directories("${CMAKE_SOURCE_DIR}/include")

file(GLOB SRCFILES ${SRCFILES} "src/*.cpp" "src/*.c")
file(GLOB SRCFILES ${SRCFILES} "src/*.cc" "src/*.cpp" "src/*.c")
file(GLOB HFILES ${HFILES} "include/*.h" "include/*.hpp")

set (addExe ${SRCFILES} ${HFILES})
file(GLOB INCFILES ${INCFILES} "include/*.inc")

add_definitions(-D_CRT_SECURE_NO_WARNINGS) #To suppress 'fopen' opencv warning/bug
# Set configuration file
if(YACCLAB_IS_TRAVIS_CI)
configure_file("${CMAKE_SOURCE_DIR}/doc/config_travis.yaml" "${CMAKE_INSTALL_PREFIX}/config.yaml")
else()
configure_file("${CMAKE_SOURCE_DIR}/doc/config_base.yaml" "${CMAKE_INSTALL_PREFIX}/config.yaml")
endif()
source_group("Include Files" FILES ${INCFILES})
source_group("Header Files" FILES ${HFILES})
source_group("Source Files" FILES ${SRCFILES})

set (addExe ${SRCFILES} ${HFILES} ${INCFILES} "${CMAKE_INSTALL_PREFIX}/config.yaml")
add_executable(${ProjectName} ${addExe})
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${ProjectName}) # Set YACCLAB as startup group instead of ALL_BUILD
target_link_libraries (${ProjectName} ${OpenCV_LIBS})
include_directories (${CMAKE_CURRENT_BINARY_DIR})

# Copy config file in the installation folder and rename it
file(COPY "${CMAKE_SOURCE_DIR}/doc/StandardConfigurationFileDoNotModifyItButTheOneInTheInstallationFolder.cfg" DESTINATION ${CMAKE_INSTALL_PREFIX})
file(RENAME "${CMAKE_INSTALL_PREFIX}/StandardConfigurationFileDoNotModifyItButTheOneInTheInstallationFolder.cfg" "${CMAKE_INSTALL_PREFIX}/config.cfg")

# Creation of output directory
if (NOT EXISTS "${YACCLAB_INPUT_DATASET_PATH}")
file(MAKE_DIRECTORY ${YACCLAB_OUTPUT_RESULTS_PATH})
endif()

# Download and unpack dataset if necessary
if(YACCLAB_DOWNLOAD_DATASET)
if (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/input")
if (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/dataset.zip")
message(STATUS "Downloading dataset...")
file(DOWNLOAD http://imagelab.ing.unimore.it/files/YACCLAB_dataset.zip "${CMAKE_INSTALL_PREFIX}/dataset.zip" STATUS status SHOW_PROGRESS)
list( GET status 0 error_code )
if( error_code )
message(ERROR " Cmake is not able to download the YACCLAB dataset. \nPlease, retry or download it manually and put the 'input' unzipped folder in the installation path:\n'" ${CMAKE_INSTALL_PREFIX} "'. \n(The dataset is available at http://imagelab.ing.unimore.it/files/YACCLAB_dataset.zip).")
if(EXISTS "${CMAKE_INSTALL_PREFIX}/dataset.zip")
file(REMOVE "${CMAKE_INSTALL_PREFIX}/dataset.zip")
endif()
else()
message(STATUS "Downloading done.")
# Creation of input directory
if (NOT EXISTS "${YACCLAB_INPUT_DATASET_PATH}")
file(MAKE_DIRECTORY ${YACCLAB_INPUT_DATASET_PATH})
endif()

if (EXISTS "${YACCLAB_INPUT_DATASET_PATH}/dataset.zip")
message(STATUS "${YACCLAB_INPUT_DATASET_PATH}/dataset.zip already exists, download skipped!")
else()
message(STATUS "Downloading dataset...")
file(DOWNLOAD http://imagelab.ing.unimore.it/files/YACCLAB_dataset_new.zip "${YACCLAB_INPUT_DATASET_PATH}/dataset.zip" STATUS status SHOW_PROGRESS)
list( GET status 0 error_code )
if( error_code )
message(ERROR " Cmake is not able to download the YACCLAB dataset. \nPlease, retry or download it manually and put all unzipped dataset directories in the 'input' path:\n'" ${YACCLAB_INPUT_DATASET_PATH} "'. \n(The dataset is available at http://imagelab.ing.unimore.it/files/YACCLAB_dataset_new.zip).")
if(EXISTS "${YACCLAB_INPUT_DATASET_PATH}/dataset.zip")
file(REMOVE "${YACCLAB_INPUT_DATASET_PATH}/dataset.zip")
endif()
else()
message(STATUS "Downloading done.")
endif()

if(EXISTS "${CMAKE_INSTALL_PREFIX}/dataset.zip")
if(EXISTS "${YACCLAB_INPUT_DATASET_PATH}/dataset.zip")
message(STATUS "Unpacking (it may take a while)...")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf "${CMAKE_INSTALL_PREFIX}/dataset.zip" WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" OUTPUT_QUIET)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf "${YACCLAB_INPUT_DATASET_PATH}/dataset.zip" WORKING_DIRECTORY "${YACCLAB_INPUT_DATASET_PATH}" OUTPUT_QUIET)
message(STATUS "Unpacking done.")
endif()
endif()

endif()
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Expand Down
84 changes: 0 additions & 84 deletions doc/ConfigurationFileForTravisCiTests.cfg

This file was deleted.

Loading

0 comments on commit 699bbb9

Please sign in to comment.