Improve mode finding
[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)
22 set(KMSXX_ENABLE_PYTHON ON CACHE BOOL "Enable Python wrappers")
23 set(KMSXX_ENABLE_KMSCUBE OFF CACHE BOOL "Enable kmscube")
25 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
26 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-unused-parameter")
28 if (CMAKE_COMPILER_IS_GNUCC)
29     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
30         # GCC 4.x seems to warn too much
31         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
32     endif()
33 endif()
35 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
37 # static link libc
38 # set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
40 check_lto()
42 if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
43     if (LTO_WORKS)
44         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
45         set(CMAKE_AR "${LTO_AR}")
46         set(CMAKE_RANLIB "${LTO_RANLIB}")
47     endif()
48 endif()
50 find_package(PkgConfig REQUIRED)
51 pkg_check_modules(LIBDRM libdrm>=2.4.64 REQUIRED)
53 enable_testing()
55 add_subdirectory(kms++)
56 add_subdirectory(kms++util)
57 add_subdirectory(utils)
59 if(KMSXX_ENABLE_KMSCUBE)
60         add_subdirectory(kmscube)
61 endif()
63 if(KMSXX_ENABLE_PYTHON)
64         add_subdirectory(py)
65 endif()