summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 367bec8df03fe4c8f8f6fb0c93a25a93dc6dfec2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
cmake_minimum_required(VERSION 2.8)
project(kms++)

include(CheckCXXCompilerFlag)

IF(NOT CMAKE_BUILD_TYPE)
    message(STATUS "Setting build type to 'Release' as none was specified.")
    SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
ENDIF()

string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)

set(LIBKMS_ENABLE_PYTHON ON CACHE BOOL "Enable Python wrappers")
set(LIBKMS_ENABLE_KMSCUBE OFF CACHE BOOL "Enable kmscube")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-unused-parameter")

if (CMAKE_COMPILER_IS_GNUCC)
    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
        # GCC 4.x seems to warn too much
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
    endif()
endif()

set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

# static link libc
# set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
    CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG)

    if (HAS_LTO_FLAG)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
        set(CMAKE_AR gcc-ar)
        set(CMAKE_RANLIB gcc-ranlib)
    endif()
endif()

find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBDRM libdrm>=2.4.64 REQUIRED)

enable_testing()

add_subdirectory(libkms++)
add_subdirectory(libkms++util)
add_subdirectory(utils)

if(LIBKMS_ENABLE_KMSCUBE)
	add_subdirectory(kmscube)
endif()

if(LIBKMS_ENABLE_PYTHON)
        add_subdirectory(py)
endif()