kmscube: fix X11 fullscreen
[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_ENABLE_KMSCUBE OFF CACHE BOOL "Enable kmscube")
26 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall")
27 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wno-unused-parameter")
29 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
30 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-unused-parameter")
32 if (CMAKE_COMPILER_IS_GNUCC)
33     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
34         # GCC 4.x seems to warn too much
35         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
36     endif()
37 endif()
39 # HACK: cmake always adds "-rdynamic", this removes it
40 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
41 SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
43 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
45 if (TREAT_WARNINGS_AS_ERRORS)
46     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
47     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
48 endif()
50 # static link libc
51 # set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
53 check_lto()
55 if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
56     if (LTO_WORKS)
57         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
58         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
59         set(CMAKE_AR "${LTO_AR}")
60         set(CMAKE_RANLIB "${LTO_RANLIB}")
61     endif()
62 endif()
64 find_package(PkgConfig REQUIRED)
65 pkg_check_modules(LIBDRM libdrm>=2.4.64 REQUIRED)
67 pkg_check_modules(LIBDRM_OMAP libdrm_omap)
68 if(LIBDRM_OMAP_FOUND)
69     add_definitions(-DHAS_LIBDRM_OMAP)
70 endif()
72 enable_testing()
74 add_subdirectory(kms++)
75 add_subdirectory(kms++util)
76 add_subdirectory(utils)
78 if(KMSXX_ENABLE_KMSCUBE)
79         add_subdirectory(kmscube)
80 endif()
82 if(KMSXX_ENABLE_PYTHON)
83         add_subdirectory(py)
84 endif()