-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
141 lines (101 loc) · 4.15 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
cmake_minimum_required(VERSION 3.15)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
project(Cadeau C CXX)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
option(WITH_SIMD "Use SIMD optimization" ON)
option(WITH_HALIDE "Use Halide optimization" ON)
option(WITH_XMF "Build Media Foundation library (XMF)" ON)
option(USE_CONAN "Use conan package manager" ${WITH_XMF})
option(CADEAU_INSTALL "Generate cmake installation script" ON)
include(ConanHelper)
include(CMakePackageConfigHelpers)
if(WIN32)
include(WindowsRC)
endif()
file(STRINGS "${CMAKE_SOURCE_DIR}/VERSION" VERSION_STRINGS)
list(GET VERSION_STRINGS 0 VERSION_STRING)
string(REGEX REPLACE "([0-9]+).[0-9]+.[0-9]+.[0-9]+" "\\1" CADEAU_VERSION_MAJOR ${VERSION_STRING})
string(REGEX REPLACE "[0-9]+.([0-9]+).[0-9]+.[0-9]+" "\\1" CADEAU_VERSION_MINOR ${VERSION_STRING})
string(REGEX REPLACE "[0-9]+.[0-9]+.([0-9]+).[0-9]+" "\\1" CADEAU_VERSION_PATCH ${VERSION_STRING})
string(REGEX REPLACE "[0-9]+.[0-9]+.[0-9]+.([0-9]+)" "\\1" CADEAU_VERSION_BUILD ${VERSION_STRING})
set(CADEAU_VERSION "${CADEAU_VERSION_MAJOR}.${CADEAU_VERSION_MINOR}.${CADEAU_VERSION_PATCH}.${CADEAU_VERSION_BUILD}")
set(CADEAU_VENDOR "Devolutions Inc.")
set(CADEAU_COPYRIGHT "Copyright 2022, ${CADEAU_VENDOR}")
if(NOT DEFINED MSVC_RUNTIME)
set(MSVC_RUNTIME "static")
endif()
if(MSVC AND (MSVC_RUNTIME STREQUAL "static"))
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if(WIN32)
set(C_FLAGS "")
set(C_FLAGS "${C_FLAGS} -D_UNICODE")
set(C_FLAGS "${C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
set(C_FLAGS "${C_FLAGS} -DWIN32_LEAN_AND_MEAN")
set(C_FLAGS "${C_FLAGS} -D_WINSOCK_DEPRECATED_NO_WARNINGS")
set(C_FLAGS "${C_FLAGS} -DWINVER=0x0601 -D_WIN32_WINNT=0x0601")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_FLAGS}")
endif()
if(CMAKE_GENERATOR MATCHES "Ninja")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
endif()
set(CMAKE_EXPORT_DIR "lib/cmake/xpp")
# Halide
if(WITH_HALIDE)
find_path(HALIDE_ROOT_DIR
NAMES "include/Halide.h"
HINTS
${HALIDE_ROOT_DIR}
ENV HALIDE_ROOT_DIR)
if(NOT HALIDE_ROOT_DIR)
message(FATAL_ERROR "Halide could not be found! - set HALIDE_ROOT_DIR")
endif()
message(STATUS "HALIDE_ROOT_DIR: ${HALIDE_ROOT_DIR}")
set(HALIDE_ROOT_DIR "${HALIDE_ROOT_DIR}" CACHE PATH "Halide root directory")
set(HALIDE_INCLUDE_DIR "${HALIDE_ROOT_DIR}/include" CACHE PATH "Halide include directory")
set(HALIDE_LIBRARY_DIR "${HALIDE_ROOT_DIR}/lib" CACHE PATH "Halide library directory")
include_directories("${HALIDE_INCLUDE_DIR}")
endif()
# XPP: eXtreme Performance Primitives
add_definitions(-DXPP_EXPORTS)
include_directories(include)
add_subdirectory(libxpp)
# XMF: eXtreme Media Foundation
if(WITH_XMF)
add_definitions(-DXMF_EXPORTS)
include_directories(include)
add_definitions(-DWITH_LIBVPX)
add_definitions(-DWITH_LIBWEBM)
add_subdirectory(libwebm)
include_directories(libwebm)
add_subdirectory(libxmf)
endif()
# installation
if(CADEAU_INSTALL)
export(PACKAGE xpp)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cadeau-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cadeau-config.cmake"
INSTALL_DESTINATION "${CMAKE_EXPORT_DIR}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cadeau-config-version.cmake"
VERSION ${CADEAU_VERSION}
COMPATIBILITY SameMajorVersion)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/xpp"
DESTINATION include
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/xmf"
DESTINATION include
FILES_MATCHING PATTERN "*.h")
install(FILES
${PROJECT_BINARY_DIR}/cadeau-config.cmake
${PROJECT_BINARY_DIR}/cadeau-config-version.cmake
DESTINATION "${CMAKE_EXPORT_DIR}")
endif()