[x265] [PATCH RFC] cmake: combine PrimitiveASM and PrimitiveVec into the common/ project
Steve Borho
steve at borho.org
Mon Oct 7 04:53:19 CEST 2013
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1381114372 18000
# Sun Oct 06 21:52:52 2013 -0500
# Node ID 646b9196a62811ed90bf91926f88efe3cc2537cb
# Parent c010342f7605c86867824f5b525a8f84c0d2de1c
cmake: combine PrimitiveASM and PrimitiveVec into the common/ project
This brings the encoder to just two static lib: encoder + common
It simplifies a number of things, at the expense of making common/CMakeLists.txt
somewhat convoluted.
diff -r c010342f7605 -r 646b9196a628 source/CMakeLists.txt
--- a/source/CMakeLists.txt Sun Oct 06 02:09:00 2013 -0500
+++ b/source/CMakeLists.txt Sun Oct 06 21:52:52 2013 -0500
@@ -149,21 +149,12 @@
add_subdirectory(common)
add_subdirectory(encoder)
-if(ENABLE_PRIMITIVES_VEC)
- set(LIBS ${LIBS} PrimitivesVec)
-endif(ENABLE_PRIMITIVES_VEC)
-
-if(ENABLE_PRIMITIVES_ASM)
- set(LIBS ${LIBS} PrimitivesASM)
-endif(ENABLE_PRIMITIVES_ASM)
-set(LIBS ${LIBS} encoder common)
-
if(ENABLE_SHARED)
add_library(x265 SHARED dllmain.cpp)
- target_link_libraries(x265 ${LIBS})
+ target_link_libraries(x265 encoder common)
elseif(NOT XCODE)
include(mergestaticlibs)
- merge_static_libs(x265 ${LIBS})
+ merge_static_libs(x265 encoder common)
endif()
# Test applications
@@ -191,7 +182,7 @@
x265.cpp x265opts.h x265.h
compat/msvc/getopt.c compat/msvc/getopt.h)
if(XCODE OR MSVC)
- target_link_libraries(cli ${LIBS})
+ target_link_libraries(cli encoder common)
else()
target_link_libraries(cli x265)
endif()
diff -r c010342f7605 -r 646b9196a628 source/common/CMakeLists.txt
--- a/source/common/CMakeLists.txt Sun Oct 06 02:09:00 2013 -0500
+++ b/source/common/CMakeLists.txt Sun Oct 06 21:52:52 2013 -0500
@@ -81,7 +81,139 @@
endif()
endif(MSVC)
+if(ENABLE_PRIMITIVES_VEC)
+ if (MSVC)
+ add_definitions(/wd4127) # conditional expression is constant
+ add_definitions(/wd4244) # 'argument' : conversion from 'int' to 'char', possible loss of data
+ if ("$ENV{CXX}" STREQUAL "icl")
+ add_definitions(/Qwd111) # statement is unreachable
+ add_definitions(/Qwd128) # loop is unreachable
+ add_definitions(/Qwd177) # declared function is unused
+ add_definitions(/Qwd185) # dynamic initialization in unreachable code
+ add_definitions(/Qwd280) # conditional expression is constant
+ add_definitions(/Qwd13200) # function using MMX does not call EMMS
+ endif()
+ set(PRIMITIVES vec/blockcopy-sse3.cpp
+ vec/pixel-sse3.cpp vec/pixel-ssse3.cpp vec/pixel-sse41.cpp
+ vec/dct-sse3.cpp vec/dct-ssse3.cpp vec/dct-sse41.cpp
+ vec/ipfilter-ssse3.cpp vec/ipfilter-sse41.cpp
+ vec/intra-sse3.cpp vec/intra-sse41.cpp)
+ if (NOT X64)
+ # x64 implies SSE4, so this flag would have no effect (and it issues a warning)
+ set_source_files_properties(vec/blockcopy-sse3.cpp
+ vec/pixel-sse3.cpp vec/pixel-ssse3.cpp vec/pixel-sse41.cpp
+ vec/dct-sse3.cpp vec/dct-ssse3.cpp vec/dct-sse41.cpp
+ vec/ipfilter-ssse3.cpp vec/ipfilter-sse41.cpp
+ vec/intra-sse3.cpp vec/intra-sse41.cpp
+ PROPERTIES COMPILE_FLAGS /arch:SSE2)
+ endif()
+ if (MSVC_VERSION EQUAL 1700 OR "$ENV{CXX}" STREQUAL "icl")
+ set(PRIMITIVES ${PRIMITIVES} vec/blockcopy-avx2.cpp vec/pixel-avx2.cpp)
+ set_source_files_properties(vec/blockcopy-avx2.cpp vec/pixel-avx2.cpp
+ PROPERTIES COMPILE_FLAGS /arch:AVX)
+ endif()
+ endif()
+ if(GCC)
+ if ("$ENV{CXX}" STREQUAL "icpc")
+ add_definitions(-wd13200) # function using MMX does not call EMMS
+ endif()
+ if("$ENV{CXX}" STREQUAL "icpc" OR NOT GCC_VERSION VERSION_LESS 4.3)
+ set(PRIMITIVES blockcopy-sse3.cpp
+ vec/pixel-sse3.cpp vec/pixel-ssse3.cpp vec/pixel-sse41.cpp
+ vec/ipfilter-ssse3.cpp vec/ipfilter-sse41.cpp
+ vec/dct-sse3.cpp vec/dct-ssse3.cpp vec/dct-sse41.cpp
+ vec/intra-sse3.cpp vec/intra-sse41.cpp)
+ set_source_files_properties(
+ vec/blockcopy-sse3.cpp vec/pixel-sse3.cpp vec/dct-sse3.cpp vec/intra-sse3.cpp
+ PROPERTIES COMPILE_FLAGS "-msse3")
+ set_source_files_properties(
+ vec/ipfilter-ssse3.cpp vec/pixel-ssse3.cpp vec/dct-ssse3.cpp
+ PROPERTIES COMPILE_FLAGS "-mssse3")
+ set_source_files_properties(
+ vec/pixel-sse41.cpp vec/ipfilter-sse41.cpp vec/dct-sse41.cpp vec/intra-sse41.cpp
+ PROPERTIES COMPILE_FLAGS "-msse4.1")
+ endif()
+ if("$ENV{CXX}" STREQUAL "icpc" OR NOT GCC_VERSION VERSION_LESS 4.7)
+ set(PRIMITIVES ${PRIMITIVES}
+ vec/blockcopy-avx2.cpp vec/pixel-avx2.cpp)
+ set_source_files_properties(
+ vec/blockcopy-avx2.cpp vec/pixel-avx2.cpp
+ PROPERTIES COMPILE_FLAGS "-march=core-avx2")
+ endif()
+ endif(GCC)
+
+ set(VEC_PRIMITIVES vec/vec-primitives.cpp ${PRIMITIVES}
+ vec/pixel.inc vec/pixel8.inc vec/pixel16.inc vec/sse.inc)
+ source_group(Intrinsics FILES ${VEC_PRIMITIVES})
+endif(ENABLE_PRIMITIVES_VEC)
+
+if(ENABLE_PRIMITIVES_ASM)
+ if (GCC)
+ add_definitions(-DHAVE_ALIGNED_STACK=1)
+ add_definitions(-Wno-error=unused-parameter)
+ else()
+ add_definitions(-DHAVE_ALIGNED_STACK=0)
+ endif()
+
+ set(ASMS pixel-a.asm const-a.asm cpu-a.asm sad-a.asm mc-a.asm mc-a2.asm ipfilter8.asm)
+ if (X64)
+ add_definitions(-DARCH_X86_64=1)
+ else()
+ add_definitions(-DARCH_X86_64=0)
+ set(ASMS ${ASMS} pixel-32.asm)
+ endif()
+ foreach(ASM ${ASMS})
+ set(FULLPATHASM ${FULLPATHASM} x86/${ASM})
+ endforeach()
+
+ if(XCODE)
+ if (X64)
+ set(FLAGS -f macho64 -m amd64 -DPREFIX -DPIC -DARCH_X86_64=1 -DHAVE_ALIGNED_STACK=1)
+ else()
+ set(FLAGS -f macho -DPREFIX -DPIC -DARCH_X86_64=0 -DHAVE_ALIGNED_STACK=1)
+ endif()
+ if (HIGH_BIT_DEPTH)
+ set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10)
+ else()
+ set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8)
+ endif()
+ foreach(ASM ${ASMS})
+ set(OBJS ${OBJS} ${ASM}.o)
+ add_custom_command(
+ OUTPUT ${ASM}.o
+ COMMAND ${YASM_EXECUTABLE} ARGS ${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/x86/${ASM} -o ${ASM}.o
+ DEPENDS ${ASM})
+ endforeach()
+ elseif(MSVC)
+ # this is horrible. ugly, and hacky, and it reproduces logic found
+ # in the yasm CMake modules, but this is required because of this cmake bug
+ # http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170
+ if (X64)
+ set(FLAGS -f win64 -m amd64 -DARCH_X86_64=1 -DHAVE_ALIGNED_STACK=0)
+ else()
+ set(FLAGS -f win32 -DARCH_X86_64=0 -DHAVE_ALIGNED_STACK=0 -DPREFIX)
+ endif()
+ if (HIGH_BIT_DEPTH)
+ set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10)
+ else()
+ set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8)
+ endif()
+ foreach(ASM ${ASMS})
+ set(OBJS ${OBJS} ${ASM}.obj)
+ add_custom_command(
+ OUTPUT ${ASM}.obj
+ COMMAND ${YASM_EXECUTABLE} ARGS ${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/x86/${ASM} -o ${ASM}.obj
+ DEPENDS ${ASM})
+ endforeach()
+ else()
+ enable_language(ASM_YASM)
+ endif()
+ set(ASM_PRIMITIVES x86/asm-primitives.cpp x86/pixel.h ${FULLPATHASM} ${OBJS})
+ source_group(Assembly FILES ${ASM_PRIMITIVES})
+endif(ENABLE_PRIMITIVES_ASM)
+
add_library(common STATIC ../../COPYING
+ ${ASM_PRIMITIVES} ${VEC_PRIMITIVES}
${LIBCOMMON_SRC} ${LIBCOMMON_HDR}
primitives.cpp primitives.h
pixel.cpp dct.cpp ipfilter.cpp intrapred.cpp
@@ -94,10 +226,3 @@
reference.cpp reference.h
common.cpp common.h
lowres.cpp lowres.h)
-
-if(ENABLE_PRIMITIVES_VEC)
- add_subdirectory(vec)
-endif(ENABLE_PRIMITIVES_VEC)
-if(ENABLE_PRIMITIVES_ASM)
- add_subdirectory(x86)
-endif(ENABLE_PRIMITIVES_ASM)
diff -r c010342f7605 -r 646b9196a628 source/common/vec/CMakeLists.txt
--- a/source/common/vec/CMakeLists.txt Sun Oct 06 02:09:00 2013 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-if (MSVC)
- add_definitions(/wd4127) # conditional expression is constant
- add_definitions(/wd4244) # 'argument' : conversion from 'int' to 'char', possible loss of data
- if ("$ENV{CXX}" STREQUAL "icl")
- add_definitions(/Qwd111) # statement is unreachable
- add_definitions(/Qwd128) # loop is unreachable
- add_definitions(/Qwd177) # declared function is unused
- add_definitions(/Qwd185) # dynamic initialization in unreachable code
- add_definitions(/Qwd280) # conditional expression is constant
- add_definitions(/Qwd13200) # function using MMX does not call EMMS
- endif()
- set(PRIMITIVES blockcopy-sse3.cpp
- pixel-sse3.cpp pixel-ssse3.cpp pixel-sse41.cpp
- dct-sse3.cpp dct-ssse3.cpp dct-sse41.cpp
- ipfilter-ssse3.cpp ipfilter-sse41.cpp
- intra-sse3.cpp intra-sse41.cpp)
- if (NOT X64)
- # x64 implies SSE4, so this flag would have no effect (and it issues a warning)
- set_source_files_properties(blockcopy-sse3.cpp
- pixel-sse3.cpp pixel-ssse3.cpp pixel-sse41.cpp
- dct-sse3.cpp dct-ssse3.cpp dct-sse41.cpp
- ipfilter-ssse3.cpp ipfilter-sse41.cpp
- intra-sse3.cpp intra-sse41.cpp
- PROPERTIES COMPILE_FLAGS /arch:SSE2)
- endif()
- if (MSVC_VERSION EQUAL 1700 OR "$ENV{CXX}" STREQUAL "icl")
- set(PRIMITIVES ${PRIMITIVES} blockcopy-avx2.cpp pixel-avx2.cpp)
- set_source_files_properties( blockcopy-avx2.cpp pixel-avx2.cpp
- PROPERTIES COMPILE_FLAGS /arch:AVX)
- endif()
-endif()
-if(GCC)
- if ("$ENV{CXX}" STREQUAL "icpc")
- add_definitions(-wd13200) # function using MMX does not call EMMS
- endif()
- if("$ENV{CXX}" STREQUAL "icpc" OR NOT GCC_VERSION VERSION_LESS 4.3)
- set(PRIMITIVES blockcopy-sse3.cpp
- pixel-sse3.cpp pixel-ssse3.cpp pixel-sse41.cpp
- ipfilter-ssse3.cpp ipfilter-sse41.cpp
- dct-sse3.cpp dct-ssse3.cpp dct-sse41.cpp
- intra-sse3.cpp intra-sse41.cpp)
- set_source_files_properties(
- blockcopy-sse3.cpp pixel-sse3.cpp dct-sse3.cpp intra-sse3.cpp
- PROPERTIES COMPILE_FLAGS "-msse3")
- set_source_files_properties(
- ipfilter-ssse3.cpp pixel-ssse3.cpp dct-ssse3.cpp
- PROPERTIES COMPILE_FLAGS "-mssse3")
- set_source_files_properties(
- pixel-sse41.cpp ipfilter-sse41.cpp dct-sse41.cpp intra-sse41.cpp
- PROPERTIES COMPILE_FLAGS "-msse4.1")
- endif()
- if("$ENV{CXX}" STREQUAL "icpc" OR NOT GCC_VERSION VERSION_LESS 4.7)
- set(PRIMITIVES ${PRIMITIVES}
- blockcopy-avx2.cpp pixel-avx2.cpp)
- set_source_files_properties(
- blockcopy-avx2.cpp pixel-avx2.cpp
- PROPERTIES COMPILE_FLAGS "-march=core-avx2")
- endif()
-endif(GCC)
-
-file(GLOB VECTORCLASS ../../VectorClass/*.h ../../VectorClass/special/*.h)
-source_group(VectorClass FILES ${VECTORCLASS})
-
-add_library(PrimitivesVec STATIC vec-primitives.cpp ${PRIMITIVES} ${VECTORCLASS}
- # *.inc files listed here show up in Visual Studio, but are not built
- # it is simply a convenience to make them easy to edit
- pixel.inc pixel8.inc pixel16.inc sse.inc)
diff -r c010342f7605 -r 646b9196a628 source/common/x86/CMakeLists.txt
--- a/source/common/x86/CMakeLists.txt Sun Oct 06 02:09:00 2013 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-if (GCC)
- add_definitions(-DHAVE_ALIGNED_STACK=1)
- add_definitions(-Wno-error=unused-parameter)
-else()
- add_definitions(-DHAVE_ALIGNED_STACK=0)
-endif()
-
-set(ASMS pixel-a.asm const-a.asm cpu-a.asm sad-a.asm mc-a.asm mc-a2.asm ipfilter8.asm)
-if (X64)
- add_definitions(-DARCH_X86_64=1)
-else()
- add_definitions(-DARCH_X86_64=0)
- set(ASMS ${ASMS} pixel-32.asm)
-endif()
-
-if(XCODE)
- if (X64)
- set(FLAGS -f macho64 -m amd64 -DPREFIX -DPIC -DARCH_X86_64=1 -DHAVE_ALIGNED_STACK=1)
- else()
- set(FLAGS -f macho -DPREFIX -DPIC -DARCH_X86_64=0 -DHAVE_ALIGNED_STACK=1)
- endif()
- if (HIGH_BIT_DEPTH)
- set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10)
- else()
- set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8)
- endif()
- foreach(ASM ${ASMS})
- set(OBJS ${OBJS} ${ASM}.o)
- add_custom_command(
- OUTPUT ${ASM}.o
- COMMAND ${YASM_EXECUTABLE} ARGS ${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${ASM} -o ${ASM}.o
- DEPENDS ${ASM})
- endforeach()
- add_library(PrimitivesASM asm-primitives.cpp pixel.h ${OBJS})
-elseif(MSVC)
- # this is horrible. ugly, and hacky, and it reproduces logic found
- # in the yasm CMake modules, but this is required because of this cmake bug
- # http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170
- if (X64)
- set(FLAGS -f win64 -m amd64 -DARCH_X86_64=1 -DHAVE_ALIGNED_STACK=0)
- else()
- set(FLAGS -f win32 -DARCH_X86_64=0 -DHAVE_ALIGNED_STACK=0 -DPREFIX)
- endif()
- if (HIGH_BIT_DEPTH)
- set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10)
- else()
- set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8)
- endif()
- foreach(ASM ${ASMS})
- set(OBJS ${OBJS} ${ASM}.obj)
- add_custom_command(
- OUTPUT ${ASM}.obj
- COMMAND ${YASM_EXECUTABLE} ARGS ${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${ASM} -o ${ASM}.obj
- DEPENDS ${ASM})
- endforeach()
- add_library(PrimitivesASM STATIC asm-primitives.cpp pixel.h ${ASMS} ${OBJS})
-else()
- enable_language(ASM_YASM)
- add_library(PrimitivesASM STATIC asm-primitives.cpp pixel.h ${ASMS})
-endif()
More information about the x265-devel
mailing list