Add Crtc::disable_mode() to pykmsbase.cpp.
[android/external-libkmsxx.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(kms++)
4 include(LTO.cmake)
6 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
7 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
8 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
10 include(CheckCXXCompilerFlag)
12 IF(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")
16 ENDIF()
18 string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
20 option(BUILD_SHARED_LIBS "Build shared libs" FALSE)
21 option(TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" FALSE)
23 set(KMSXX_ENABLE_PYTHON ON CACHE BOOL "Enable Python wrappers")
24 set(KMSXX_PYTHON_VERSION "python3;python2" CACHE STRING "Python pkgconfig package")
26 set(KMSXX_ENABLE_KMSCUBE OFF CACHE BOOL "Enable kmscube")
28 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall")
29 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wno-unused-parameter")
31 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
32 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-unused-parameter")
34 if (CMAKE_COMPILER_IS_GNUCC)
35     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
36         # GCC 4.x seems to warn too much
37         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
38     endif()
39 endif()
41 # HACK: cmake always adds "-rdynamic", this removes it
42 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
43 SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
45 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
47 if (TREAT_WARNINGS_AS_ERRORS)
48     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
49     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
50 endif()
52 # static link libc
53 # set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
55 check_lto()
57 if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
58     if (LTO_WORKS)
59         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
60         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
61         set(CMAKE_AR "${LTO_AR}")
62         set(CMAKE_RANLIB "${LTO_RANLIB}")
63     endif()
64 endif()
66 find_package(PkgConfig REQUIRED)
67 pkg_check_modules(LIBDRM libdrm>=2.4.64 REQUIRED)
69 pkg_check_modules(LIBDRM_OMAP libdrm_omap)
70 if(LIBDRM_OMAP_FOUND)
71     add_definitions(-DHAS_LIBDRM_OMAP)
72 endif()
74 enable_testing()
76 add_subdirectory(kms++)
77 add_subdirectory(kms++util)
78 add_subdirectory(utils)
80 if(KMSXX_ENABLE_KMSCUBE)
81         add_subdirectory(kmscube)
82 endif()
84 if(KMSXX_ENABLE_PYTHON)
85         add_subdirectory(py)
86 endif()
88 add_custom_target(docs SOURCES "README.md")