40cc19f36270180bae5609dc40561045560da190
[android/external-libkmsxx.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(kms++)
4 include(CheckCXXCompilerFlag)
6 IF(NOT CMAKE_BUILD_TYPE)
7     message(STATUS "Setting build type to 'Release' as none was specified.")
8     SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
9     set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
10 ENDIF()
12 string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
14 option(BUILD_SHARED_LIBS "Build shared libs" FALSE)
16 set(LIBKMS_ENABLE_PYTHON ON CACHE BOOL "Enable Python wrappers")
17 set(LIBKMS_ENABLE_KMSCUBE OFF CACHE BOOL "Enable kmscube")
19 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
20 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-unused-parameter")
22 if (CMAKE_COMPILER_IS_GNUCC)
23     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
24         # GCC 4.x seems to warn too much
25         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
26     endif()
27 endif()
29 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
31 # static link libc
32 # set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
34 if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
35     CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG)
37     if (HAS_LTO_FLAG)
38         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
39         set(CMAKE_AR gcc-ar)
40         set(CMAKE_RANLIB gcc-ranlib)
41     endif()
42 endif()
44 find_package(PkgConfig REQUIRED)
45 pkg_check_modules(LIBDRM libdrm>=2.4.64 REQUIRED)
47 enable_testing()
49 add_subdirectory(kms++)
50 add_subdirectory(kms++util)
51 add_subdirectory(utils)
53 if(LIBKMS_ENABLE_KMSCUBE)
54         add_subdirectory(kmscube)
55 endif()
57 if(LIBKMS_ENABLE_PYTHON)
58         add_subdirectory(py)
59 endif()