Add CMakeLists.txt
For using cmake to generate a makefile instead of building through scons. Implements issue #3: Investigate CMake Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
17150b1791
commit
0e171012ce
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -13,3 +13,8 @@ bin/
|
|||
*.gcno
|
||||
core.*
|
||||
.debug
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
|
|
67
CMakeLists.txt
Normal file
67
CMakeLists.txt
Normal file
|
@ -0,0 +1,67 @@
|
|||
cmake_minimum_required(VERSION 3.4)
|
||||
project(Ocarina)
|
||||
|
||||
# Various options for users
|
||||
option(CONFIG_DEBUG "Compile with debugging symbols" OFF)
|
||||
|
||||
# Configure settings
|
||||
set(CONFIG_MAJOR 6)
|
||||
set(CONFIG_MINOR 5)
|
||||
set(CONFIG_MICRO 0)
|
||||
set(CONFIG_RC OFF)
|
||||
|
||||
set(CONFIG_VERSION "${CONFIG_MAJOR}.${CONFIG_MINOR}.${CONFIG_MICRO}")
|
||||
|
||||
if (CONFIG_RC)
|
||||
set(CONFIG_VERSION "${CONFIG_VERSION}-rc")
|
||||
endif()
|
||||
|
||||
if (CONFIG_DEBUG)
|
||||
add_definitions(-Wall -Werror -g -DCONFIG_DEBUG)
|
||||
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}\")
|
||||
|
||||
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)
|
Loading…
Reference in New Issue
Block a user