Add OmapCard and OmapFramebuffer
[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_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
27 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-unused-parameter")
29 if (CMAKE_COMPILER_IS_GNUCC)
30     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
31         # GCC 4.x seems to warn too much
32         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
33     endif()
34 endif()
36 # HACK: cmake always adds "-rdynamic", this removes it
37 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
38 SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
40 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
42 if (TREAT_WARNINGS_AS_ERRORS)
43     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
44     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
45 endif()
47 # static link libc
48 # set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
50 check_lto()
52 if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
53     if (LTO_WORKS)
54         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
55         set(CMAKE_AR "${LTO_AR}")
56         set(CMAKE_RANLIB "${LTO_RANLIB}")
57     endif()
58 endif()
60 find_package(PkgConfig REQUIRED)
61 pkg_check_modules(LIBDRM libdrm>=2.4.64 REQUIRED)
62 pkg_check_modules(LIBDRM_OMAP libdrm_omap)
64 enable_testing()
66 add_subdirectory(kms++)
67 add_subdirectory(kms++util)
68 add_subdirectory(utils)
70 if(KMSXX_ENABLE_KMSCUBE)
71         add_subdirectory(kmscube)
72 endif()
74 if(KMSXX_ENABLE_PYTHON)
75         add_subdirectory(py)
76 endif()