Debian Codegraph @

src/editor/libs/codemirror/mode/cmake/index.html

raw symbols SCIP
1 <!doctype html>
2
3 <title>CodeMirror: CMake mode</title>
4 <meta charset="utf-8"/>
5 <link rel=stylesheet href="../../doc/docs.css">
6
7 <link rel="stylesheet" href="../../lib/codemirror.css">
8 <script src="../../lib/codemirror.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
10 <script src="cmake.js"></script>
11 <style>
12 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
13 .cm-s-default span.cm-arrow { color: red; }
14 </style>
15 <div id=nav>
16 <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
17
18 <ul>
19 <li><a href="../../index.html">Home</a>
20 <li><a href="../../doc/manual.html">Manual</a>
21 <li><a href="https://github.com/codemirror/codemirror">Code</a>
22 </ul>
23 <ul>
24 <li><a href="../index.html">Language modes</a>
25 <li><a class=active href="#">CMake</a>
26 </ul>
27 </div>
28
29 <article>
30 <h2>CMake mode</h2>
31 <form><textarea id="code" name="code">
32 # vim: syntax=cmake
33 if(NOT CMAKE_BUILD_TYPE)
34 # default to Release build for GCC builds
35 set(CMAKE_BUILD_TYPE Release CACHE STRING
36 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
37 FORCE)
38 endif()
39 message(STATUS "cmake version ${CMAKE_VERSION}")
40 if(POLICY CMP0025)
41 cmake_policy(SET CMP0025 OLD) # report Apple's Clang as just Clang
42 endif()
43 if(POLICY CMP0042)
44 cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH
45 endif()
46
47 project (x265)
48 cmake_minimum_required (VERSION 2.8.8) # OBJECT libraries require 2.8.8
49 include(CheckIncludeFiles)
50 include(CheckFunctionExists)
51 include(CheckSymbolExists)
52 include(CheckCXXCompilerFlag)
53
54 # X265_BUILD must be incremented each time the public API is changed
55 set(X265_BUILD 48)
56 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
57 "${PROJECT_BINARY_DIR}/x265.def")
58 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
59 "${PROJECT_BINARY_DIR}/x265_config.h")
60
61 SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
62
63 # System architecture detection
64 string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSPROC)
65 set(X86_ALIASES x86 i386 i686 x86_64 amd64)
66 list(FIND X86_ALIASES "${SYSPROC}" X86MATCH)
67 if("${SYSPROC}" STREQUAL "" OR X86MATCH GREATER "-1")
68 message(STATUS "Detected x86 target processor")
69 set(X86 1)
70 add_definitions(-DX265_ARCH_X86=1)
71 if("${CMAKE_SIZEOF_VOID_P}" MATCHES 8)
72 set(X64 1)
73 add_definitions(-DX86_64=1)
74 endif()
75 elseif(${SYSPROC} STREQUAL "armv6l")
76 message(STATUS "Detected ARM target processor")
77 set(ARM 1)
78 add_definitions(-DX265_ARCH_ARM=1 -DHAVE_ARMV6=1)
79 else()
80 message(STATUS "CMAKE_SYSTEM_PROCESSOR value `${CMAKE_SYSTEM_PROCESSOR}` is unknown")
81 message(STATUS "Please add this value near ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}")
82 endif()
83
84 if(UNIX)
85 list(APPEND PLATFORM_LIBS pthread)
86 find_library(LIBRT rt)
87 if(LIBRT)
88 list(APPEND PLATFORM_LIBS rt)
89 endif()
90 find_package(Numa)
91 if(NUMA_FOUND)
92 list(APPEND CMAKE_REQUIRED_LIBRARIES ${NUMA_LIBRARY})
93 check_symbol_exists(numa_node_of_cpu numa.h NUMA_V2)
94 if(NUMA_V2)
95 add_definitions(-DHAVE_LIBNUMA)
96 message(STATUS "libnuma found, building with support for NUMA nodes")
97 list(APPEND PLATFORM_LIBS ${NUMA_LIBRARY})
98 link_directories(${NUMA_LIBRARY_DIR})
99 include_directories(${NUMA_INCLUDE_DIR})
100 endif()
101 endif()
102 mark_as_advanced(LIBRT NUMA_FOUND)
103 endif(UNIX)
104
105 if(X64 AND NOT WIN32)
106 option(ENABLE_PIC "Enable Position Independent Code" ON)
107 else()
108 option(ENABLE_PIC "Enable Position Independent Code" OFF)
109 endif(X64 AND NOT WIN32)
110
111 # Compiler detection
112 if(CMAKE_GENERATOR STREQUAL "Xcode")
113 set(XCODE 1)
114 endif()
115 if (APPLE)
116 add_definitions(-DMACOS)
117 endif()
118
119 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
120 set(CLANG 1)
121 endif()
122 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
123 set(INTEL_CXX 1)
124 endif()
125 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
126 set(GCC 1)
127 endif()
128
129 if(INTEL_CXX AND WIN32)
130 # treat icl roughly like MSVC
131 set(MSVC 1)
132 endif()
133 if(MSVC)
134 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
135 if (STATIC_LINK_CRT)
136 set(CompilerFlags CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE)
137 foreach(CompilerFlag ${CompilerFlags})
138 string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
139 endforeach()
140 endif (STATIC_LINK_CRT)
141 add_definitions(/W4) # Full warnings
142 add_definitions(/Ob2) # always inline
143 add_definitions(/MP) # multithreaded build
144
145 # disable Microsofts suggestions for proprietary secure APIs
146 add_definitions(/D_CRT_SECURE_NO_WARNINGS)
147
148 check_include_files(stdint.h HAVE_STDINT_H)
149 if(NOT HAVE_STDINT_H)
150 include_directories(compat/msvc)
151 endif()
152 endif(MSVC)
153
154 check_include_files(inttypes.h HAVE_INT_TYPES_H)
155 if(HAVE_INT_TYPES_H)
156 add_definitions(-DHAVE_INT_TYPES_H=1)
157 endif()
158
159 if(INTEL_CXX AND UNIX)
160 set(GCC 1) # treat icpc roughly like gcc
161 elseif(CLANG)
162 set(GCC 1) # treat clang roughly like gcc
163 elseif(CMAKE_COMPILER_IS_GNUCXX)
164 set(GCC 1)
165 endif()
166 if(GCC)
167 add_definitions(-Wall -Wextra -Wshadow)
168 add_definitions(-D__STDC_LIMIT_MACROS=1)
169 if(ENABLE_PIC)
170 add_definitions(-fPIC)
171 endif(ENABLE_PIC)
172 if(X86 AND NOT X64)
173 add_definitions(-march=i686)
174 endif()
175 if(ARM)
176 add_definitions(-march=armv6 -mfloat-abi=hard -mfpu=vfp)
177 endif()
178 check_cxx_compiler_flag(-Wno-narrowing CC_HAS_NO_NARROWING)
179 check_cxx_compiler_flag(-Wno-array-bounds CC_HAS_NO_ARRAY_BOUNDS)
180 if (CC_HAS_NO_ARRAY_BOUNDS)
181 add_definitions(-Wno-array-bounds) # these are unhelpful
182 endif()
183 check_cxx_compiler_flag(-ffast-math CC_HAS_FAST_MATH)
184 if (CC_HAS_FAST_MATH)
185 add_definitions(-ffast-math)
186 endif()
187 check_cxx_compiler_flag(-mstackrealign CC_HAS_STACK_REALIGN)
188 if (CC_HAS_STACK_REALIGN)
189 add_definitions(-mstackrealign)
190 endif()
191 # Disable exceptions. Reduce executable size, increase compability.
192 check_cxx_compiler_flag(-fno-exceptions CC_HAS_FNO_EXCEPTIONS_FLAG)
193 if(CC_HAS_FNO_EXCEPTIONS_FLAG)
194 add_definitions(-fno-exceptions)
195 endif()
196 set(FSANITIZE "" CACHE STRING "-fsanitize options for GCC/clang")
197 if(FSANITIZE)
198 add_definitions(-fsanitize=${FSANITIZE})
199 # clang and gcc need the sanitize options to be passed at link
200 # time so the appropriate ASAN/TSAN runtime libraries can be
201 # linked.
202 list(APPEND LINKER_OPTIONS "-fsanitize=${FSANITIZE}")
203 endif()
204 execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CC_VERSION)
205 endif(GCC)
206
207 find_package(Yasm)
208 if(YASM_FOUND AND X86)
209 if (YASM_VERSION_STRING VERSION_LESS "1.2.0")
210 message(STATUS "Yasm version ${YASM_VERSION_STRING} is too old. 1.2.0 or later required")
211 option(ENABLE_ASSEMBLY "Enable use of assembly coded primitives" OFF)
212 else()
213 message(STATUS "Found Yasm ${YASM_VERSION_STRING} to build assembly primitives")
214 option(ENABLE_ASSEMBLY "Enable use of assembly coded primitives" ON)
215 endif()
216 endif()
217
218 option(CHECKED_BUILD "Enable run-time sanity checks (debugging)" OFF)
219 if(CHECKED_BUILD)
220 add_definitions(-DCHECKED_BUILD=1)
221 if(GCC)
222 check_cxx_compiler_flag(-fsanitize=undefined-trap CC_HAS_CATCH_UNDEFINED) # clang
223 check_cxx_compiler_flag(-ftrapv CC_HAS_FTRAPV) # gcc
224 check_cxx_compiler_flag(-fstack-protector-all CC_HAS_STACK_PROTECT) # gcc
225 if(CC_HAS_FTRAPV)
226 add_definitions(-ftrapv)
227 endif()
228 if(CC_HAS_CATCH_UNDEFINED)
229 add_definitions(-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error)
230 endif()
231 if(CC_HAS_STACK_PROTECT)
232 add_definitions(-fstack-protector-all)
233 if(MINGW)
234 list(APPEND PLATFORM_LIBS ssp)
235 endif()
236 endif()
237 endif(GCC)
238 endif()
239
240 # Build options
241 set(LIB_INSTALL_DIR lib CACHE STRING "Install location of libraries")
242 set(BIN_INSTALL_DIR bin CACHE STRING "Install location of executables")
243
244 if(X64)
245 # NOTE: We only officially support 16bit-per-pixel compiles of x265
246 # on 64bit architectures. 16bpp plus large resolution plus slow
247 # preset plus 32bit address space usually means malloc failure. You
248 # can disable this if(X64) check if you desparately need a 32bit
249 # build with 10bit/12bit support, but this violates the "shrink wrap
250 # license" so to speak. If it breaks you get to keep both halves.
251 # You will likely need to compile without assembly
252 option(HIGH_BIT_DEPTH "Store pixels as 16bit values" OFF)
253 endif(X64)
254 if(HIGH_BIT_DEPTH)
255 add_definitions(-DHIGH_BIT_DEPTH=1)
256 else(HIGH_BIT_DEPTH)
257 add_definitions(-DHIGH_BIT_DEPTH=0)
258 endif(HIGH_BIT_DEPTH)
259
260 option(WARNINGS_AS_ERRORS "Stop compiles on first warning" OFF)
261 if(WARNINGS_AS_ERRORS)
262 if(GCC)
263 add_definitions(-Werror)
264 elseif(MSVC)
265 add_definitions(/WX)
266 endif()
267 endif(WARNINGS_AS_ERRORS)
268
269 if (WIN32)
270 # Visual leak detector
271 find_package(VLD QUIET)
272 if(VLD_FOUND)
273 add_definitions(-DHAVE_VLD)
274 include_directories(${VLD_INCLUDE_DIRS})
275 list(APPEND PLATFORM_LIBS ${VLD_LIBRARIES})
276 link_directories(${VLD_LIBRARY_DIRS})
277 endif()
278 option(WINXP_SUPPORT "Make binaries compatible with Windows XP" OFF)
279 if(WINXP_SUPPORT)
280 # force use of workarounds for CONDITION_VARIABLE and atomic
281 # intrinsics introduced after XP
282 add_definitions(-D_WIN32_WINNT=_WIN32_WINNT_WINXP)
283 endif()
284 endif()
285
286 include(version) # determine X265_VERSION and X265_LATEST_TAG
287 include_directories(. common encoder "${PROJECT_BINARY_DIR}")
288
289 option(ENABLE_PPA "Enable PPA profiling instrumentation" OFF)
290 if(ENABLE_PPA)
291 add_definitions(-DENABLE_PPA)
292 list(APPEND PLATFORM_LIBS PPA)
293 if(UNIX)
294 list(APPEND PLATFORM_LIBS dl)
295 endif(UNIX)
296 add_subdirectory(profile/PPA)
297 endif(ENABLE_PPA)
298
299 option(ENABLE_VTUNE "Enable Vtune profiling instrumentation" OFF)
300 if(ENABLE_VTUNE)
301 add_definitions(-DENABLE_VTUNE)
302 include_directories($ENV{VTUNE_AMPLIFIER_XE_2015_DIR}/include)
303 list(APPEND PLATFORM_LIBS vtune)
304 link_directories($ENV{VTUNE_AMPLIFIER_XE_2015_DIR}/lib64)
305 if(WIN32)
306 list(APPEND PLATFORM_LIBS libittnotify.lib)
307 else()
308 list(APPEND PLATFORM_LIBS libittnotify.a dl)
309 endif()
310 add_subdirectory(profile/vtune)
311 endif(ENABLE_VTUNE)
312
313 option(DETAILED_CU_STATS "Enable internal profiling of encoder work" OFF)
314 if(DETAILED_CU_STATS)
315 add_definitions(-DDETAILED_CU_STATS)
316 endif(DETAILED_CU_STATS)
317
318 add_subdirectory(encoder)
319 add_subdirectory(common)
320
321 if((MSVC_IDE OR XCODE) AND ENABLE_ASSEMBLY)
322 # this is required because of this cmake bug
323 # http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170
324 if(WIN32)
325 set(SUFFIX obj)
326 else()
327 set(SUFFIX o)
328 endif()
329 foreach(ASM ${MSVC_ASMS})
330 set(YASM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/common/x86/${ASM})
331 list(APPEND YASM_SRCS ${YASM_SRC})
332 list(APPEND YASM_OBJS ${ASM}.${SUFFIX})
333 add_custom_command(
334 OUTPUT ${ASM}.${SUFFIX}
335 COMMAND ${YASM_EXECUTABLE} ARGS ${YASM_FLAGS} ${YASM_SRC} -o ${ASM}.${SUFFIX}
336 DEPENDS ${YASM_SRC})
337 endforeach()
338 endif()
339
340 source_group(ASM FILES ${YASM_SRCS})
341 add_library(x265-static STATIC $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common> ${YASM_OBJS} ${YASM_SRCS})
342 if(NOT MSVC)
343 set_target_properties(x265-static PROPERTIES OUTPUT_NAME x265)
344 endif()
345 install(TARGETS x265-static
346 LIBRARY DESTINATION ${LIB_INSTALL_DIR}
347 ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
348 install(FILES x265.h "${PROJECT_BINARY_DIR}/x265_config.h" DESTINATION include)
349
350 if(CMAKE_RC_COMPILER)
351 # The resource compiler does not need CFLAGS or macro defines. It
352 # often breaks them
353 string(REPLACE "<FLAGS>" "" CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILE_OBJECT}")
354 string(REPLACE "<DEFINES>" "" CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILE_OBJECT}")
355
356 # convert X265_LATEST_TAG (ex: 0.7) and X265_TAG_DISTANCE (ex: 103) to
357 # @X265_VERSION_MAJOR@,@X265_VERSION_MINOR@,@X265_BRANCH_ID@,@X265_TAG_DISTANCE@
358 string(REPLACE "." ";" VERSION_LIST "${X265_LATEST_TAG}")
359 list(GET VERSION_LIST 0 X265_VERSION_MAJOR)
360 list(GET VERSION_LIST 1 X265_VERSION_MINOR)
361 set(X265_BRANCH_ID 0) # TODO: 0 - stable, 1 - default or other
362 set(X265_RC_FILE "${CMAKE_CURRENT_BINARY_DIR}/x265.rc")
363 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/x265.rc.in" "${X265_RC_FILE}" @ONLY)
364 endif()
365
366 if(NOT (MSVC_IDE OR XCODE))
367 add_custom_target(clean-generated COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/clean-generated.cmake)
368 endif()
369
370 option(ENABLE_SHARED "Build shared library" ON)
371 if(ENABLE_SHARED)
372 add_library(x265-shared SHARED "${PROJECT_BINARY_DIR}/x265.def" ${YASM_OBJS}
373 ${X265_RC_FILE} $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common>)
374 target_link_libraries(x265-shared ${PLATFORM_LIBS})
375 if(MSVC)
376 set_target_properties(x265-shared PROPERTIES OUTPUT_NAME libx265)
377 else()
378 set_target_properties(x265-shared PROPERTIES OUTPUT_NAME x265)
379 endif()
380 if(UNIX)
381 set_target_properties(x265-shared PROPERTIES VERSION ${X265_BUILD})
382 if(APPLE)
383 set_target_properties(x265-shared PROPERTIES MACOSX_RPATH 1)
384 else()
385 set_target_properties(x265-shared PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,-znoexecstack")
386 endif()
387 endif()
388 set_target_properties(x265-shared PROPERTIES SOVERSION ${X265_BUILD})
389 if(X265_LATEST_TAG)
390 if(WINDOWS)
391 set_target_properties(x265-shared PROPERTIES VERSION ${X265_LATEST_TAG})
392 endif()
393 # shared library is not installed if a tag is not found
394 install(TARGETS x265-shared
395 LIBRARY DESTINATION ${LIB_INSTALL_DIR}
396 ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
397 RUNTIME DESTINATION ${BIN_INSTALL_DIR})
398 endif()
399 if(LINKER_OPTIONS)
400 set_target_properties(x265-shared PROPERTIES LINK_FLAGS ${LINKER_OPTIONS})
401 endif()
402 endif()
403
404 if(X265_LATEST_TAG)
405 # convert lists of link libraries into -lstdc++ -lm etc..
406 foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES} ${PLATFORM_LIBS})
407 if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB})
408 list(APPEND PLIBLIST "${LIB}")
409 else()
410 list(APPEND PLIBLIST "-l${LIB}")
411 endif()
412 endforeach()
413 if(PLIBLIST)
414 # blacklist of libraries that should not be in Libs.private
415 list(REMOVE_ITEM PLIBLIST "-lc" "-lpthread")
416 string(REPLACE ";" " " PRIVATE_LIBS "${PLIBLIST}")
417 else()
418 set(PRIVATE_LIBS "")
419 endif(PLIBLIST)
420
421 # Produce a pkg-config file
422 configure_file("x265.pc.in" "x265.pc" @ONLY)
423 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/x265.pc"
424 DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
425 endif()
426
427 if(NOT WIN32)
428 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
429 "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
430 IMMEDIATE @ONLY)
431 add_custom_target(uninstall
432 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
433 endif()
434
435 # Main CLI application
436 option(ENABLE_CLI "Build standalone CLI application" ON)
437 if(ENABLE_CLI)
438 file(GLOB InputFiles input/*.cpp input/*.h)
439 file(GLOB OutputFiles output/*.cpp output/*.h)
440 file(GLOB FilterFiles filters/*.cpp filters/*.h)
441 source_group(input FILES ${InputFiles})
442 source_group(output FILES ${OutputFiles})
443 source_group(filters FILES ${FilterFiles})
444
445 check_include_files(getopt.h HAVE_GETOPT_H)
446 if(NOT HAVE_GETOPT_H)
447 if(MSVC)
448 set_source_files_properties(compat/getopt/getopt.c PROPERTIES COMPILE_FLAGS "/wd4100 /wd4131 -DHAVE_STRING_H=1")
449 endif(MSVC)
450 include_directories(compat/getopt)
451 set(GETOPT compat/getopt/getopt.c compat/getopt/getopt.h)
452 endif(NOT HAVE_GETOPT_H)
453
454 if(XCODE)
455 # Xcode seems unable to link the CLI with libs, so link as one targget
456 add_executable(cli ../COPYING ${InputFiles} ${OutputFiles} ${FilterFiles} ${GETOPT} x265.cpp x265.h x265cli.h
457 $<TARGET_OBJECTS:encoder> $<TARGET_OBJECTS:common> ${YASM_OBJS} ${YASM_SRCS})
458 else()
459 add_executable(cli ../COPYING ${InputFiles} ${OutputFiles} ${FilterFiles} ${GETOPT} ${X265_RC_FILE} x265.cpp x265.h x265cli.h)
460 if(WIN32 OR NOT ENABLE_SHARED OR INTEL_CXX)
461 # The CLI cannot link to the shared library on Windows, it
462 # requires internal APIs not exported from the DLL
463 target_link_libraries(cli x265-static ${PLATFORM_LIBS})
464 else()
465 target_link_libraries(cli x265-shared ${PLATFORM_LIBS})
466 endif()
467 endif()
468 set_target_properties(cli PROPERTIES OUTPUT_NAME x265)
469 if(LINKER_OPTIONS)
470 set_target_properties(cli PROPERTIES LINK_FLAGS ${LINKER_OPTIONS})
471 endif()
472
473 install(TARGETS cli DESTINATION ${BIN_INSTALL_DIR})
474 endif(ENABLE_CLI)
475
476 if(ENABLE_ASSEMBLY AND NOT XCODE)
477 option(ENABLE_TESTS "Enable Unit Tests" OFF)
478 if(ENABLE_TESTS)
479 add_subdirectory(test)
480 endif()
481 endif()
482 </textarea></form>
483 <script>
484 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
485 mode: "text/x-cmake",
486 matchBrackets: true,
487 indentUnit: 4
488 });
489 </script>
490
491 <p><strong>MIME types defined:</strong> <code>text/x-cmake</code>.</p>
492
493 </article>