2016-02-28 11:49:38 -05:00
|
|
|
cmake_minimum_required(VERSION 3.4)
|
|
|
|
project(Ocarina)
|
|
|
|
|
|
|
|
# Various options for users
|
|
|
|
option(CONFIG_DEBUG "Compile with debugging symbols" OFF)
|
2016-03-03 08:17:12 -05:00
|
|
|
option(CONFIG_TESTING_VERBOSE "Enable verbose output when running tests" OFF)
|
2016-09-26 08:26:45 -04:00
|
|
|
option(CONFIG_TESTING_GUI "Enable running GUI tests (requires an X server)" ON)
|
2016-09-28 10:08:12 -04:00
|
|
|
option(CONFIG_TESTING_ARTWORK "Enable album artwork fetching tests" ON)
|
2016-02-28 11:49:38 -05:00
|
|
|
|
|
|
|
# Configure settings
|
|
|
|
set(CONFIG_MAJOR 6)
|
|
|
|
set(CONFIG_MINOR 5)
|
2016-09-26 08:12:12 -04:00
|
|
|
set(CONFIG_RC ON)
|
2016-02-28 11:49:38 -05:00
|
|
|
|
2016-08-17 13:30:43 -04:00
|
|
|
set(CONFIG_VERSION "${CONFIG_MAJOR}.${CONFIG_MINOR}")
|
2016-02-28 11:49:38 -05:00
|
|
|
|
|
|
|
if (CONFIG_RC)
|
|
|
|
set(CONFIG_VERSION "${CONFIG_VERSION}-rc")
|
|
|
|
endif()
|
|
|
|
|
2016-03-03 08:17:12 -05:00
|
|
|
set(DEBUG_OPTIONS -Wall -Werror -g -DCONFIG_DEBUG)
|
2016-02-28 11:49:38 -05:00
|
|
|
if (CONFIG_DEBUG)
|
2016-03-03 08:17:12 -05:00
|
|
|
add_definitions(${DEBUG_OPTIONS})
|
2016-02-28 11:49:38 -05:00
|
|
|
set(CONFIG_VERSION "${CONFIG_VERSION}-debug")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(Git)
|
|
|
|
if (GIT_FOUND AND IS_DIRECTORY .git/)
|
|
|
|
configure_file(.git/HEAD .git/HEAD COPYONLY)
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0
|
|
|
|
COMMAND xargs ${GIT_EXECUTABLE} diff --quiet
|
|
|
|
RESULT_VARIABLE HAS_CHANGED)
|
|
|
|
if (HAS_CHANGED)
|
|
|
|
set(CONFIG_VERSION "${CONFIG_VERSION}+")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(-DCONFIG_VERSION=\"${CONFIG_VERSION}\")
|
2016-08-17 13:30:43 -04:00
|
|
|
add_definitions(-DCONFIG_MAJOR=${CONFIG_MAJOR})
|
|
|
|
add_definitions(-DCONFIG_MINOR=${CONFIG_MINOR})
|
2016-02-28 11:49:38 -05:00
|
|
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
function(use_module name module)
|
|
|
|
pkg_check_modules(${name} REQUIRED ${module})
|
|
|
|
include_directories(${${name}_INCLUDE_DIRS})
|
|
|
|
add_definitions(${${name}_CFLAGS} ${${name}_CFLAGS_OTHERS})
|
|
|
|
link_libraries(${${name}_LIBRARIES} ${${name}_LDFLAGS})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
use_module(GTK gtk+-3.0)
|
|
|
|
use_module(GMODULE gmodule-export-2.0)
|
|
|
|
use_module(GST gstreamer-1.0)
|
|
|
|
use_module(TAGLIB taglib_c)
|
|
|
|
use_module(CAA libcoverart)
|
|
|
|
use_module(MB5 libmusicbrainz5)
|
|
|
|
|
|
|
|
# Tell compiler where to find header and source files
|
|
|
|
include_directories(include)
|
|
|
|
file(GLOB_RECURSE core "core/*.c")
|
|
|
|
file(GLOB_RECURSE gui "gui/*.c")
|
|
|
|
|
|
|
|
# Configure executable
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin/)
|
|
|
|
add_executable(ocarina ${core} ${gui})
|
|
|
|
|
|
|
|
# Configure install targets
|
|
|
|
install(TARGETS ocarina DESTINATION /usr/bin/)
|
|
|
|
install(DIRECTORY share/ DESTINATION /usr/share/)
|
|
|
|
|
|
|
|
# Configure release target
|
|
|
|
set(CONFIG_RELEASE ocarina-${CONFIG_VERSION})
|
|
|
|
add_custom_target(release COMMAND git archive -v --prefix=${CONFIG_RELEASE}/ -o ${CONFIG_RELEASE}.tar.gz HEAD)
|
2016-03-03 08:17:12 -05:00
|
|
|
|
|
|
|
# Set up unit tests
|
|
|
|
set(CMAKE_TEST_COMMAND ctest --output-on-failure)
|
|
|
|
if (CONFIG_TESTING_VERBOSE)
|
|
|
|
set(CMAKE_TEST_COMMAND ctest -V)
|
|
|
|
endif()
|
|
|
|
if (IS_DIRECTORY tests/)
|
|
|
|
enable_testing()
|
|
|
|
add_custom_target(tests COMMAND ${CMAKE_TEST_COMMAND})
|
|
|
|
add_subdirectory(tests/)
|
|
|
|
endif()
|