forked from strukturag/libheif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
107 lines (83 loc) · 2.97 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
cmake_minimum_required (VERSION 3.3.2)
project(libheif LANGUAGES C CXX VERSION 1.7.0.0)
# https://cmake.org/cmake/help/v3.1/policy/CMP0054.html
cmake_policy(SET CMP0054 NEW)
include(GNUInstallDirs)
# The version number.
set (PACKAGE_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
# Check for unistd.h
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
if (HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif()
# load paths from the user file if exists
if (EXISTS ${CMAKE_SOURCE_DIR}/CMakeUserPaths.cmake)
include(${CMAKE_SOURCE_DIR}/CMakeUserPaths.cmake)
endif()
if(NOT MSVC)
add_definitions(-Wall)
add_definitions(-Werror)
add_definitions(-Wsign-compare)
add_definitions(-Wconversion)
add_definitions(-Wno-sign-conversion)
add_definitions(-Wno-error=conversion)
add_definitions(-Wno-error=unused-parameter)
add_definitions(-Wno-error=deprecated-declarations)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Create the compile command database for clang by default
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-Wno-error=potentially-evaluated-expression has_potentially_evaluated_expression)
if (has_potentially_evaluated_expression)
add_definitions(-Wno-error=potentially-evaluated-expression)
endif()
if (UNIX)
find_package(PkgConfig)
pkg_check_modules(LIBDE265 libde265)
pkg_check_modules(X265 x265)
pkg_check_modules(AOM aom)
elseif(MSVC)
# nomacs patch for windows
find_package(libde265)
include_directories(
${LIBDE265_INCLUDE_DIR}
)
endif()
# Create libheif pkgconfig file
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
if (LIBDE265_FOUND)
set(have_libde265 yes)
else()
set(have_libde265 no)
endif()
if (X265_FOUND)
set(have_x265 yes)
else()
set(have_x265 no)
endif()
set(VERSION ${PROJECT_VERSION})
configure_file(libheif.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libheif.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libheif.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
add_subdirectory (examples)
add_subdirectory (libheif)
add_subdirectory (gdk-pixbuf)
# write nomacs config file (for Windows)
SET(libheif_LIBRARIES
optimized ${CMAKE_CURRENT_BINARY_DIR}/libheif/Release/heif.lib
debug ${CMAKE_CURRENT_BINARY_DIR}/libheif/Debug/heif.lib)
# include: provide binary dir for heif_version.h
SET(libheif_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libheif.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libheifConfig.cmake)
message(STATUS "libheif include dir: ${libheif_INCLUDE_DIR}")