[x265] [PATCH] cmake: introduce multilib support for MSVC
Steve Borho
steve at borho.org
Mon Jun 22 20:57:49 CEST 2015
# HG changeset patch
# User Min Chen
# Date 1434999426 18000
# Mon Jun 22 13:57:06 2015 -0500
# Node ID 2cdab8d3b76066b18f32d1aa13c17fe50f9fa289
# Parent 83a7d824442455ba5e0a6b53ea68e6b7043845de
cmake: introduce multilib support for MSVC
Note, the multilib configuration exposes a bug in MSVC 2008 in that the
anonymous namespaced functions are not truly file local, the unique namespaced
functions are exported and thus collide with other libx265 static libraries. It
is not known if later MSVC compilers are also affected.
To work around this, we tell the linker to ignore duplicate symbols. This seems
to work but is not a terribly robust long-term solution.
diff -r 83a7d8244424 -r 2cdab8d3b760 build/vc10-x86_64/multilib.bat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/build/vc10-x86_64/multilib.bat Mon Jun 22 13:57:06 2015 -0500
@@ -0,0 +1,34 @@
+ at echo off
+if "%VS100COMNTOOLS%" == "" (
+ msg "%username%" "Visual Studio 10 not detected"
+ exit 1
+)
+
+ at mkdir 10bpp
+ at mkdir 8bpp
+
+ at cd 10bpp
+if not exist x265.sln (
+ cmake -G "Visual Studio 10 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DWINXP_SUPPORT=ON
+)
+if exist x265.sln (
+ call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat"
+ MSBuild /property:Configuration="Release" x265.sln
+ copy/y Release\x265-static.lib ..\8bpp\x265-static-10bpp.lib
+)
+ at cd ..
+
+ at cd 8bpp
+if not exist x265-static-10bpp.lib (
+ msg "%username%" "10bpp build failured"
+ exit 1
+)
+if not exist x265.sln (
+ cmake -G "Visual Studio 10 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DWINXP_SUPPORT=ON -DEXTRA_LIB=x265-static-10bpp.lib -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
+)
+if exist x265.sln (
+ call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat"
+ MSBuild /property:Configuration="Release" x265.sln
+ copy/y Release\x265.exe ..
+)
+ at cd ..
diff -r 83a7d8244424 -r 2cdab8d3b760 build/vc11-x86_64/multilib.bat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/build/vc11-x86_64/multilib.bat Mon Jun 22 13:57:06 2015 -0500
@@ -0,0 +1,34 @@
+ at echo off
+if "%VS110COMNTOOLS%" == "" (
+ msg "%username%" "Visual Studio 11 not detected"
+ exit 1
+)
+
+ at mkdir 10bpp
+ at mkdir 8bpp
+
+ at cd 10bpp
+if not exist x265.sln (
+ cmake -G "Visual Studio 11 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DWINXP_SUPPORT=ON
+)
+if exist x265.sln (
+ call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat"
+ MSBuild /property:Configuration="Release" x265.sln
+ copy/y Release\x265-static.lib ..\8bpp\x265-static-10bpp.lib
+)
+ at cd ..
+
+ at cd 8bpp
+if not exist x265-static-10bpp.lib (
+ msg "%username%" "10bpp build failured"
+ exit 1
+)
+if not exist x265.sln (
+ cmake -G "Visual Studio 11 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DWINXP_SUPPORT=ON -DEXTRA_LIB=x265-static-10bpp.lib -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
+)
+if exist x265.sln (
+ call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat"
+ MSBuild /property:Configuration="Release" x265.sln
+ copy/y Release\x265.exe ..
+)
+ at cd ..
diff -r 83a7d8244424 -r 2cdab8d3b760 build/vc12-x86_64/multilib.bat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/build/vc12-x86_64/multilib.bat Mon Jun 22 13:57:06 2015 -0500
@@ -0,0 +1,34 @@
+ at echo off
+if "%VS120COMNTOOLS%" == "" (
+ msg "%username%" "Visual Studio 12 not detected"
+ exit 1
+)
+
+ at mkdir 10bpp
+ at mkdir 8bpp
+
+ at cd 10bpp
+if not exist x265.sln (
+ cmake -G "Visual Studio 12 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DWINXP_SUPPORT=ON
+)
+if exist x265.sln (
+ call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat"
+ MSBuild /property:Configuration="Release" x265.sln
+ copy/y Release\x265-static.lib ..\8bpp\x265-static-10bpp.lib
+)
+ at cd ..
+
+ at cd 8bpp
+if not exist x265-static-10bpp.lib (
+ msg "%username%" "10bpp build failured"
+ exit 1
+)
+if not exist x265.sln (
+ cmake -G "Visual Studio 12 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DWINXP_SUPPORT=ON -DEXTRA_LIB=x265-static-10bpp.lib -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
+)
+if exist x265.sln (
+ call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat"
+ MSBuild /property:Configuration="Release" x265.sln
+ copy/y Release\x265.exe ..
+)
+ at cd ..
diff -r 83a7d8244424 -r 2cdab8d3b760 build/vc9-x86_64/multilib.bat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/build/vc9-x86_64/multilib.bat Mon Jun 22 13:57:06 2015 -0500
@@ -0,0 +1,34 @@
+ at echo off
+if "%VS90COMNTOOLS%" == "" (
+ msg "%username%" "Visual Studio 9 not detected"
+ exit 1
+)
+
+ at mkdir 10bpp
+ at mkdir 8bpp
+
+ at cd 10bpp
+if not exist x265.sln (
+ cmake -G "Visual Studio 9 2008 Win64" ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DWINXP_SUPPORT=ON
+)
+if exist x265.sln (
+ call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat"
+ MSBuild /property:Configuration="Release" x265.sln
+ copy/y Release\x265-static.lib ..\8bpp\x265-static-10bpp.lib
+)
+ at cd ..
+
+ at cd 8bpp
+if not exist x265-static-10bpp.lib (
+ msg "%username%" "10bpp build failured"
+ exit 1
+)
+if not exist x265.sln (
+ cmake -G "Visual Studio 9 2008 Win64" ../../../source -DHIGH_BIT_DEPTH=OFF -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=ON -DWINXP_SUPPORT=ON -DEXTRA_LIB=x265-static-10bpp.lib -DEXTRA_LINK_FLAGS="/FORCE:MULTIPLE"
+)
+if exist x265.sln (
+ call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat"
+ MSBuild /property:Configuration="Release" x265.sln
+ copy/y Release\x265.exe ..
+)
+ at cd ..
diff -r 83a7d8244424 -r 2cdab8d3b760 source/CMakeLists.txt
--- a/source/CMakeLists.txt Mon Jun 22 15:15:33 2015 +0530
+++ b/source/CMakeLists.txt Mon Jun 22 13:57:06 2015 -0500
@@ -271,7 +271,8 @@
set(LIB_INSTALL_DIR lib CACHE STRING "Install location of libraries")
set(BIN_INSTALL_DIR bin CACHE STRING "Install location of executables")
set(EXTRA_LIB "" CACHE STRING "Extra libraries to link against")
-mark_as_advanced(EXTRA_LIB)
+set(EXTRA_LINK_FLAGS "" CACHE STRING "Extra link flags")
+mark_as_advanced(EXTRA_LIB EXTRA_LINK_FLAGS)
if(X64)
# NOTE: We only officially support 16bit-per-pixel compiles of x265
@@ -398,6 +399,9 @@
link_directories(${CMAKE_BINARY_DIR}/../10bit)
target_link_libraries(x265-static ${EXTRA_LIB})
endif()
+if(EXTRA_LINK_FLAGS)
+ list(APPEND LINKER_OPTIONS ${EXTRA_LINK_FLAGS})
+endif()
install(TARGETS x265-static
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
More information about the x265-devel
mailing list