CMakeLists.txt 3.68 KB
Newer Older
1 2
# ***** BEGIN GPL LICENSE BLOCK *****
#
3 4 5 6
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
7 8 9 10 11 12 13
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
#
16
# Copyright 2012-2014, Bart van der Velden <bart@muckingabout.eu>
17 18 19 20
# All rights reserved.
#
# ***** END GPL LICENSE BLOCK *****
#
21 22 23 24 25 26
# This CMakeLists.txt code is largely based on the following projects:
# * Blender (http://blender.org)
# * Amarok (http://amarok.kde.org)
# * CoR-Lab (https://code.cor-lab.org)
# 
# Thanks guys!
27

28
project(MusicCollection CXX)
29
cmake_minimum_required(VERSION 2.8.11)
30

31 32 33 34
#-----------------------------------------------------------------------------
# Set some options

# Set to On to have all CMakeLists files generate some extra output (-DCMAKE_DEGUG=On)
35
option(CMAKE_DEBUG "Generate extra CMake info" Off)
36

37 38 39
# When On build all tests. Turn off with -Dtest=off
option(test "Build all tests." On)

40 41 42
# We want to be able to run 'make test' to execute the unit tests
enable_testing()

43 44 45 46 47 48 49 50
#-----------------------------------------------------------------------------
# We don't allow in-source builds. This causes no end of troubles because
# all out-of-source builds will use the CMakeCache.txt file there and even
# build the libs and objects in it.

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
    message(FATAL_ERROR
        "CMake generation for is not allowed within the source directory!"
51
        "\n Remove the CMakeCache.txt file and try again from another directory, e.g.:"
52 53 54 55 56 57 58 59 60
        "\n "
        "\n rm CMakeCache.txt"
        "\n cd .."
        "\n mkdir build"
        "\n cd build"
        "\n cmake ../trunk"
    )
endif()

61
#-----------------------------------------------------------------------------
62
# Set some paths
63

64
# Set the path to the CMake modules
65
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
66 67 68 69 70 71
# Set output path
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# Set library path
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
# Set the path to the test data
set(TEST_DATA_PATH ${CMAKE_CURRENT_SOURCE_DIR}/data/testdata)
72 73 74

#-----------------------------------------------------------------------------
# Enable modules
75 76
include(EnableCoverageReport)     # Enable settings for coverage calculation
include(PedanticCompilerWarnings) # Global compiler flags
77

78 79 80 81
#-----------------------------------------------------------------------------
# Fix for compiling Google Mock and Test with Visual Studio 2012, see:
# stackoverflow.com/questions/8274588/c2977-stdtuple-too-many-template-arguments-msvc11
if (MSVC11)
82
    add_definitions(/D _VARIADIC_MAX=10)
83 84
endif(MSVC11)

85
#-----------------------------------------------------------------------------
86 87
# Third party libraries
add_subdirectory(3rdparty)
88

89 90 91
#-----------------------------------------------------------------------------
# Get version information
include(Version)
92 93 94 95

git_last_version(MUSICCOLLECTION_VERSION_GITSHA1)
git_last_revision_single_line(MUSICCOLLECTION_VERSION_GIT_LAST_REV_SINGLELINE)
git_last_revision_full_info(MUSICCOLLECTION_VERSION_GIT_LAST_REV_FULLINFO)
96

97 98
#-----------------------------------------------------------------------------
# Add the actual source code
99
add_subdirectory(src)
100 101

if(CMAKE_DEBUG)
102
    include(CMakeVariableLogging)
103
endif(CMAKE_DEBUG)