1cmake_minimum_required(VERSION 2.8)
2project(kms++)
3
4include(LTO.cmake)
5
6set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
7set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
8set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
9
10include(CheckCXXCompilerFlag)
11
12IF(NOT CMAKE_BUILD_TYPE)
13    message(STATUS "Setting build type to 'Release' as none was specified.")
14    SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
15    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
16ENDIF()
17
18string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
19
20option(BUILD_SHARED_LIBS "Build shared libs" FALSE)
21option(TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" FALSE)
22
23set(KMSXX_ENABLE_PYTHON ON CACHE BOOL "Enable Python wrappers")
24set(KMSXX_PYTHON_VERSION "python3;python2" CACHE STRING "Python pkgconfig package")
25
26set(KMSXX_ENABLE_KMSCUBE OFF CACHE BOOL "Enable kmscube")
27
28set(KMSXX_ENABLE_THREADING ON CACHE BOOL "Enable threading for parallelized drawing")
29
30set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall")
31set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wno-unused-parameter")
32
33set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
34set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-unused-parameter")
35
36if (CMAKE_COMPILER_IS_GNUCC)
37    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
38        # GCC 4.x seems to warn too much
39        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
40    endif()
41endif()
42
43# HACK: cmake always adds "-rdynamic", this removes it
44SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
45SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
46
47set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
48
49if (TREAT_WARNINGS_AS_ERRORS)
50    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
51    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
52endif()
53
54# static link libc
55# set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
56
57check_lto()
58
59if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
60    if (LTO_WORKS)
61        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
62        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
63        set(CMAKE_AR "${LTO_AR}")
64        set(CMAKE_RANLIB "${LTO_RANLIB}")
65    endif()
66endif()
67
68find_package(PkgConfig REQUIRED)
69pkg_check_modules(LIBDRM libdrm>=2.4.64 REQUIRED)
70
71pkg_check_modules(LIBDRM_OMAP libdrm_omap)
72if(LIBDRM_OMAP_FOUND)
73    add_definitions(-DHAS_LIBDRM_OMAP)
74endif()
75
76enable_testing()
77
78add_subdirectory(kms++)
79add_subdirectory(kms++util)
80add_subdirectory(utils)
81
82if(KMSXX_ENABLE_KMSCUBE)
83	add_subdirectory(kmscube)
84endif()
85
86if(KMSXX_ENABLE_PYTHON)
87        add_subdirectory(py)
88endif()
89
90add_custom_target(docs SOURCES "README.md")
91