Commit b315b067 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Kill cmake

parent 98708d41
project(medialibrary)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
option(BUILD_TESTS "Shall unit tests be built?" ON)
add_subdirectory( src )
if (${BUILD_TESTS})
add_subdirectory( test )
endif()
# CMake module to search for LIBVLC (VLC library)
# Author: Rohit Yadav <rohityadav89@gmail.com>
#
# If it's found it sets LIBVLC_FOUND to TRUE
# and following variables are set:
# LIBVLC_INCLUDE_DIR
# LIBVLC_LIBRARY
# FIND_PATH and FIND_LIBRARY normally search standard locations
# before the specified paths. To search non-standard paths first,
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
# and then again with no specified paths to search the default
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
# searching for the same item do nothing.
#Put here path to custom location
#example: /home/user/vlc/include etc..
FIND_PATH(LIBVLC_INCLUDE_DIR vlc/vlc.h
HINTS "$ENV{LIBVLC_INCLUDE_PATH}"
PATHS
#Mac OS and Contribs
"${CMAKE_CURRENT_SOURCE_DIR}/contribs/include"
"${CMAKE_CURRENT_SOURCE_DIR}/contribs/include/vlc"
# Env
"$ENV{LIB_DIR}/include"
"$ENV{LIB_DIR}/include/vlc"
#
"/usr/include"
"/usr/include/vlc"
"/usr/local/include"
"/usr/local/include/vlc"
#mingw
c:/msys/local/include
# MacOS install dir
/Applications/VLC.app/Contents/MacOS/include
)
FIND_PATH(LIBVLC_INCLUDE_DIR PATHS "${CMAKE_INCLUDE_PATH}/vlc" NAMES vlc.h)
#Put here path to custom location
#example: /home/user/vlc/lib etc..
FIND_LIBRARY(LIBVLC_LIBRARY NAMES vlc libvlc
HINTS "$ENV{LIBVLC_LIBRARY_PATH}"
PATHS
"$ENV{LIB_DIR}/lib"
#Mac OS
"${CMAKE_CURRENT_SOURCE_DIR}/contribs/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/contribs/plugins"
# MacOS install dir
/Applications/VLC.app/Contents/MacOS/lib
#mingw
c:/msys/local/lib
)
FIND_LIBRARY(LIBVLC_LIBRARY NAMES vlc libvlc)
IF (LIBVLC_INCLUDE_DIR AND LIBVLC_LIBRARY)
SET(LIBVLC_FOUND TRUE)
ENDIF (LIBVLC_INCLUDE_DIR AND LIBVLC_LIBRARY)
IF (LIBVLC_FOUND)
get_filename_component(LIBVLC_LIB_DIR ${LIBVLC_LIBRARY} PATH)
IF (NOT LIBVLC_FIND_QUIETLY)
MESSAGE(STATUS "Found LibVLC include-dir path: ${LIBVLC_INCLUDE_DIR}")
MESSAGE(STATUS "Found LibVLC library path:${LIBVLC_LIBRARY}")
ENDIF (NOT LIBVLC_FIND_QUIETLY)
ELSE (LIBVLC_FOUND)
IF (LIBVLC_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find LibVLC")
ENDIF (LIBVLC_FIND_REQUIRED)
ENDIF (LIBVLC_FOUND)
# - find Sqlite 3
# SQLITE3_INCLUDE_DIR - Where to find Sqlite 3 header files (directory)
# SQLITE3_LIBRARIES - Sqlite 3 libraries
# SQLITE3_LIBRARY_RELEASE - Where the release library is
# SQLITE3_LIBRARY_DEBUG - Where the debug library is
# SQLITE3_FOUND - Set to TRUE if we found everything (library, includes and executable)
# Copyright (c) 2010 Pau Garcia i Quiles, <pgquiles@elpauer.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# Generated by CModuler, a CMake Module Generator - http://gitorious.org/cmoduler
IF( SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG )
SET(SQLITE3_FIND_QUIETLY TRUE)
ENDIF( SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG )
FIND_PATH( SQLITE3_INCLUDE_DIR sqlite3.h )
FIND_LIBRARY(SQLITE3_LIBRARY_RELEASE NAMES sqlite3 )
FIND_LIBRARY(SQLITE3_LIBRARY_DEBUG NAMES sqlite3 sqlite3d HINTS /usr/lib/debug/usr/lib/ )
IF( SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR )
SET( SQLITE3_FOUND TRUE )
ENDIF( SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR )
IF( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE )
# if the generator supports configuration types then set
# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
IF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
SET( SQLITE3_LIBRARIES optimized ${SQLITE3_LIBRARY_RELEASE} debug ${SQLITE3_LIBRARY_DEBUG} )
ELSE( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
# if there are no configuration types and CMAKE_BUILD_TYPE has no value
# then just use the release libraries
SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE} )
ENDIF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
ELSEIF( SQLITE3_LIBRARY_RELEASE )
SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE} )
ELSE( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE )
SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_DEBUG} )
ENDIF( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE )
IF( SQLITE3_FOUND )
IF( NOT SQLITE3_FIND_QUIETLY )
MESSAGE( STATUS "Found Sqlite3 header file in ${SQLITE3_INCLUDE_DIR}")
MESSAGE( STATUS "Found Sqlite3 libraries: ${SQLITE3_LIBRARIES}")
ENDIF( NOT SQLITE3_FIND_QUIETLY )
ELSE(SQLITE3_FOUND)
IF( SQLITE3_FIND_REQUIRED)
MESSAGE( FATAL_ERROR "Could not find Sqlite3" )
ELSE( SQLITE3_FIND_REQUIRED)
MESSAGE( STATUS "Optional package Sqlite3 was not found" )
ENDIF( SQLITE3_FIND_REQUIRED)
ENDIF(SQLITE3_FOUND)
# Copyright (c) 2011 Milo Yip (miloyip@gmail.com)
# Copyright (c) 2013 Rafal Jeczalik (rjeczalik@gmail.com)
# Distributed under the MIT License (see license.txt file)
# -----------------------------------------------------------------------------------
#
# Finds the rapidjson library
#
# -----------------------------------------------------------------------------------
#
# Variables used by this module, they can change the default behaviour.
# Those variables need to be either set before calling find_package
# or exported as environment variables before running CMake:
#
# RAPIDJSON_INCLUDEDIR - Set custom include path, useful when rapidjson headers are
# outside system paths
# RAPIDJSON_USE_SSE2 - Configure rapidjson to take advantage of SSE2 capabilities
# RAPIDJSON_USE_SSE42 - Configure rapidjson to take advantage of SSE4.2 capabilities
#
# -----------------------------------------------------------------------------------
#
# Variables defined by this module:
#
# RAPIDJSON_FOUND - True if rapidjson was found
# RAPIDJSON_INCLUDE_DIRS - Path to rapidjson include directory
# RAPIDJSON_CXX_FLAGS - Extra C++ flags required for compilation with rapidjson
#
# -----------------------------------------------------------------------------------
#
# Example usage:
#
# set(RAPIDJSON_USE_SSE2 ON)
# set(RAPIDJSON_INCLUDEDIR "/opt/github.com/rjeczalik/rapidjson/include")
#
# find_package(rapidjson REQUIRED)
#
# include_directories("${RAPIDJSON_INCLUDE_DIRS}")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RAPIDJSON_CXX_FLAGS}")
# add_executable(foo foo.cc)
#
# -----------------------------------------------------------------------------------
foreach(opt RAPIDJSON_INCLUDEDIR RAPIDJSON_USE_SSE2 RAPIDJSON_USE_SSE42)
if(${opt} AND DEFINED ENV{${opt}} AND NOT ${opt} STREQUAL "$ENV{${opt}}")
message(WARNING "Conflicting ${opt} values: ignoring environment variable and using CMake cache entry.")
elseif(DEFINED ENV{${opt}} AND NOT ${opt})
set(${opt} "$ENV{${opt}}")
endif()
endforeach()
find_path(
RAPIDJSON_INCLUDE_DIRS
NAMES rapidjson/rapidjson.h
PATHS ${RAPIDJSON_INCLUDEDIR}
DOC "Include directory for the rapidjson library."
)
mark_as_advanced(RAPIDJSON_INCLUDE_DIRS)
if(RAPIDJSON_INCLUDE_DIRS)
set(RAPIDJSON_FOUND TRUE)
endif()
mark_as_advanced(RAPIDJSON_FOUND)
if(RAPIDJSON_USE_SSE42)
set(RAPIDJSON_CXX_FLAGS "-DRAPIDJSON_SSE42")
if(MSVC)
set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} /arch:SSE4.2")
else()
set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} -msse4.2")
endif()
else()
if(RAPIDJSON_USE_SSE2)
set(RAPIDJSON_CXX_FLAGS "-DRAPIDJSON_SSE2")
if(MSVC)
set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} /arch:SSE2")
else()
set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} -msse2")
endif()
endif()
endif()
mark_as_advanced(RAPIDJSON_CXX_FLAGS)
if(RAPIDJSON_FOUND)
if(NOT rapidjson_FIND_QUIETLY)
message(STATUS "Found rapidjson header files in ${RAPIDJSON_INCLUDE_DIRS}")
if(DEFINED RAPIDJSON_CXX_FLAGS)
message(STATUS "Found rapidjson C++ extra compilation flags: ${RAPIDJSON_CXX_FLAGS}")
endif()
endif()
elseif(rapidjson_FIND_REQUIRED)
message(FATAL_ERROR "Could not find rapidjson")
else()
message(STATUS "Optional package rapidjson was not found")
endif()
#Shamelessly taken from http://www.guyrutenberg.com/2014/01/05/enabling-c11-c0x-in-cmake/
macro(EnableCpp11)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
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()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
endmacro()
project(medialibrary)
include(cpp11)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
option(WITH_VLC "Include VLC metadata services" ON)
EnableCpp11()
include(FindPkgConfig)
pkg_check_modules(EVAS evas)
add_definitions("-Wall -Wextra -pedantic")
if(UNIX)
set(ARCH_FOLDER "unix")
elseif(WIN32)
set(ARCH_FOLDER "win32")
endif()
list(APPEND HEADERS_LIST
${CMAKE_SOURCE_DIR}/include/medialibrary/IShow.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IShowEpisode.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IAlbum.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IAlbumTrack.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IMedia.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IMediaLibrary.h
${CMAKE_SOURCE_DIR}/include/medialibrary/ILabel.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IAudioTrack.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IVideoTrack.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IMovie.h
${CMAKE_SOURCE_DIR}/include/medialibrary/ILogger.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IArtist.h
${CMAKE_SOURCE_DIR}/include/medialibrary/IPlaylist.h
${CMAKE_SOURCE_DIR}/include/discoverer/IDiscoverer.h
${CMAKE_SOURCE_DIR}/include/filesystem/IDirectory.h
${CMAKE_SOURCE_DIR}/include/filesystem/IFile.h
${CMAKE_SOURCE_DIR}/include/factory/IFileSystem.h
database/SqliteTools.h
filesystem/${ARCH_FOLDER}/Directory.h
filesystem/${ARCH_FOLDER}/File.h
discoverer/FsDiscoverer.h
factory/FileSystem.h
utils/Filename.h
)
include_directories("${CMAKE_SOURCE_DIR}/include")
include_directories("${CMAKE_SOURCE_DIR}/src")
list(APPEND SRC_LIST ${HEADERS_LIST}
MediaLibrary.cpp
Media.cpp
Folder.cpp
Album.cpp
Show.cpp
Label.cpp
AlbumTrack.cpp
ShowEpisode.cpp
Factory.cpp
Movie.cpp
VideoTrack.cpp
AudioTrack.cpp
Artist.cpp
Settings.cpp
Device.cpp
File.cpp
Playlist.cpp
History.cpp
Genre.cpp
parser/Parser.cpp
parser/ParserService.cpp
factory/FileSystem.cpp
filesystem/common/CommonFile.cpp
filesystem/${ARCH_FOLDER}/Directory.cpp
filesystem/${ARCH_FOLDER}/File.cpp
filesystem/${ARCH_FOLDER}/Device.cpp
discoverer/FsDiscoverer.cpp
discoverer/DiscovererWorker.cpp
utils/Filename.cpp
utils/VLCInstance.cpp
utils/ModificationsNotifier.cpp
database/SqliteConnection.cpp
database/SqliteTransaction.cpp
database/SqliteTools.cpp
logging/IostreamLogger.cpp
logging/Logger.cpp
)
if (${WITH_VLC})
list(APPEND SRC_LIST
metadata_services/vlc/VLCMetadataService.cpp
metadata_services/vlc/VLCThumbnailer.cpp
metadata_services/MetadataParser.cpp
)
endif()
find_package(Sqlite3 REQUIRED)
include_directories(${SQLITE3_INCLUDE_DIR})
add_library(${PROJECT_NAME} SHARED ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} ${SQLITE3_LIBRARIES})
if (${WITH_VLC})
find_package(LIBVLC REQUIRED)
# Since VLC include a thumbnailer, we need libjpeg to encode the result
find_package(JPEG)
target_link_libraries( ${PROJECT_NAME} ${LIBVLC_LIBRARY} )
include_directories(${LIBVLC_INCLUDE_DIR})
if (${EVAS_FOUND})
include_directories(${EVAS_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${EVAS_LIBRARIES})
add_definitions("-DWITH_EVAS")
elseif (${JPEG_FOUND})
include_directories(${JPEG_INCLUDE_DIR})
target_link_libraries( ${PROJECT_NAME} ${JPEG_LIBRARIES} )
add_definitions("-DWITH_JPEG")
endif()
set(LIBVLCPP_DIR "" CACHE PATH "Path to libvlcpp's directory")
include_directories(${LIBVLCPP_DIR})
endif()
# Work around for tizen platform
if (NOT "${EXTRA_LIBS}" STREQUAL "")
target_link_libraries( ${PROJECT_NAME} ${EXTRA_LIBS} )
endif()
project(medialibrary)
include(ExternalProject)
# Fetch gtest
ExternalProject_Add(
gtest-dependency
CMAKE_COMMAND cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
SVN_REPOSITORY http://googletest.googlecode.com/svn/trunk/
TIMEOUT 10
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
# Wrap download, configure and build steps in a script to log output
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
)
ExternalProject_Get_Property(gtest-dependency source_dir)
include_directories(${source_dir}/include)
# Also link with gtest:
# fetch the directory which contains the built libraries (gtest & gtest_main)
ExternalProject_Get_Property(gtest-dependency binary_dir)
link_directories(${binary_dir})
cmake_minimum_required(VERSION 2.8)
include(cpp11)
if (UNIX)
option(WITH_ASAN "Build with address sanitizer" OFF)
option(WITH_TSAN "Build with thread sanitizer" OFF)
option(WITH_UBSAN "Build with undefined behavior sanitizer" OFF)
endif()
EnableCpp11()
add_definitions("-Wall -Wextra -pedantic")
include_directories(${SQLITE3_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/test)
include_directories(${LIBVLC_INCLUDE_DIR})
include(unittest/unittest.cmake)
include(samples/samples.cmake)
include_directories(${LIBVLCPP_DIR})
# Also add pthread, as gtest requires it
if(UNIX)
target_link_libraries(unittest "pthread")
target_link_libraries(samples "pthread")
if(${WITH_ASAN})
if(${WITH_TSAN} OR ${WITH_UBSAN})
message(SEND_ERROR "Sanitizers are mutually exclusive")
endif()
add_definitions("-fsanitize=address -fno-omit-frame-pointer")
target_link_libraries(unittest "asan")
target_link_libraries(samples "asan")
endif()
if(${WITH_TSAN})
if(${WITH_ASAN} OR ${WITH_UBSAN})
message(SEND_ERROR "Sanitizers are mutually exclusive")
endif()
add_definitions("-fsanitize=thread -fno-omit-frame-pointer")
target_link_libraries(unittest "tsan")
target_link_libraries(samples "tsan")
endif()
if(${WITH_UBSAN})
if(${WITH_ASAN} OR ${WITH_TSAN})
message(SEND_ERROR "Sanitizers are mutually exclusive")
endif()
add_definitions("-fsanitize=undefined -fno-omit-frame-pointer")
target_link_libraries(unittest "ubsan")
target_link_libraries(samples "ubsan")
endif()
endif()
list(APPEND SAMPLE_TEST_SRCS
samples/main.cpp
samples/Tester.cpp
common/MediaLibraryTester.cpp
)
find_package(rapidjson REQUIRED)
add_executable(samples ${SAMPLE_TEST_SRCS})
add_dependencies(samples gtest-dependency)
target_link_libraries(samples medialibrary)
target_link_libraries(samples gtest gtest_main)
add_definitions("-DSRC_DIR=\"${CMAKE_SOURCE_DIR}\"")
list(APPEND TEST_SRCS
unittest/MediaTests.cpp
unittest/FolderTests.cpp
unittest/LabelTests.cpp
unittest/AlbumTests.cpp
unittest/Tests.cpp
unittest/ShowTests.cpp
unittest/MovieTests.cpp
unittest/VideoTrackTests.cpp
unittest/AudioTrackTests.cpp
unittest/FsUtilsTests.cpp
unittest/ArtistTests.cpp
unittest/AlbumTrackTests.cpp
unittest/DeviceTests.cpp
unittest/FileTests.cpp
unittest/PlaylistTests.cpp
unittest/HistoryTests.cpp
unittest/GenreTests.cpp
unittest/RemovalNotifierTests.cpp
mocks/FileSystem.h
mocks/FileSystem.cpp
mocks/DiscovererCbMock.h
mocks/filesystem/MockDevice.cpp
mocks/filesystem/MockFile.cpp
mocks/filesystem/MockDirectory.cpp
common/MediaLibraryTester.cpp
)
add_executable(unittest ${TEST_SRCS})
add_dependencies(unittest gtest-dependency)
target_link_libraries(unittest medialibrary)
target_link_libraries(unittest gtest gtest_main)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment