CMake build system for Windows
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4171 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
new file mode 100644
index 0000000..aaede05
--- /dev/null
+++ b/common/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_subdirectory(os)
+add_subdirectory(zlib)
+add_subdirectory(jpeg)
+add_subdirectory(rdr)
+add_subdirectory(network)
+add_subdirectory(Xregion)
+add_subdirectory(rfb)
diff --git a/common/Makefile.am b/common/Makefile.am
index d805809..15400c2 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -8,3 +8,5 @@
endif
SUBDIRS += rdr network Xregion rfb
+
+EXTRA_DIST = CMakeLists.txt
diff --git a/common/Xregion/CMakeLists.txt b/common/Xregion/CMakeLists.txt
new file mode 100644
index 0000000..d12554c
--- /dev/null
+++ b/common/Xregion/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(Xregion STATIC
+ Region.c)
diff --git a/common/Xregion/Makefile.am b/common/Xregion/Makefile.am
index fb6a1c7..7ea4c80 100644
--- a/common/Xregion/Makefile.am
+++ b/common/Xregion/Makefile.am
@@ -3,3 +3,5 @@
HDRS = region.h Xregion.h
libXregion_la_SOURCES = $(HDRS) Region.c
+
+EXTRA_DIST = CMakeLists.txt
diff --git a/common/jpeg/CMakeLists.txt b/common/jpeg/CMakeLists.txt
new file mode 100644
index 0000000..cd867e7
--- /dev/null
+++ b/common/jpeg/CMakeLists.txt
@@ -0,0 +1,117 @@
+#
+# Setup
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+project(libjpeg-turbo)
+set(VERSION 1.0.90)
+
+if(NOT DEFINED WITH_SIMD)
+ set(WITH_SIMD 1)
+endif()
+
+# Detect whether compiler is 64-bit
+if(MSVC AND CMAKE_CL_64)
+ set(SIMD_X86_64 1)
+ set(64BIT 1)
+elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
+ set(SIMD_X86_64 1)
+ set(64BIT 1)
+endif()
+
+if(64BIT)
+ message(STATUS "64-bit build")
+else()
+ message(STATUS "32-bit build")
+endif()
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/win)
+
+
+#
+# Targets
+#
+
+set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
+ jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c
+ jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c jdatasrc.c
+ jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c
+ jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c
+ jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c
+ jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
+
+if(WITH_SIMD)
+ add_definitions(-DWITH_SIMD)
+ add_subdirectory(simd)
+ if(SIMD_X86_64)
+ set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
+ else()
+ set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
+ endif()
+ # This tells CMake that the "source" files haven't been generated yet
+ set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
+else()
+ set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
+ message(STATUS "Not using SIMD acceleration")
+endif()
+
+add_library(jpeg STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
+if(WITH_SIMD)
+ add_dependencies(jpeg simd)
+endif()
+
+add_executable(jpegut jpegut.c turbojpegl.c)
+target_link_libraries(jpegut jpeg)
+
+add_executable(jpgtest jpgtest.cxx bmp.c turbojpegl.c)
+target_link_libraries(jpgtest jpeg)
+
+add_executable(cjpeg cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
+ rdtarga.c)
+set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS
+ "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
+target_link_libraries(cjpeg jpeg)
+
+add_executable(djpeg djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
+ wrppm.c wrtarga.c)
+set_property(TARGET djpeg PROPERTY COMPILE_FLAGS
+ "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
+target_link_libraries(djpeg jpeg)
+
+add_executable(jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c)
+target_link_libraries(jpegtran jpeg)
+
+
+#
+# Tests
+#
+
+enable_testing()
+add_test(jpegut jpegut)
+add_test(cjpeg-int cjpeg -dct int -outfile testoutint.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
+add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
+add_test(cjpeg-fast cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
+add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
+add_test(cjpeg-float cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
+if(WITH_SIMD)
+add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
+else()
+add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
+endif()
+add_test(djpeg-int djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
+add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
+add_test(djpeg-fast djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
+add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
+add_test(djpeg-float djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
+if(WITH_SIMD)
+add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
+else()
+add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
+endif()
+add_test(djpeg-256 djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
+add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimg.bmp testout.bmp)
+add_test(cjpeg-prog cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
+add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
+add_test(jpegtran-prog jpegtran -outfile testoutt.jpg testoutp.jpg)
+add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
diff --git a/common/jpeg/Makefile.am b/common/jpeg/Makefile.am
index bae191a..cd1c221 100644
--- a/common/jpeg/Makefile.am
+++ b/common/jpeg/Makefile.am
@@ -57,6 +57,18 @@
jpegtran_LDADD = libjpeg.la
+DOCS= README README-turbo.txt LICENSE.txt LGPL.txt
+
+TESTFILES= testorig.jpg testorig.ppm testimg.bmp testimgflt.jpg \
+ testimgfst.jpg testimgint.jpg testimgp.jpg testimgflt.ppm testimgfst.ppm \
+ testimgint.ppm testimgflt-nosimd.jpg
+
+EXTRA_DIST = win $(DOCS) $(TESTFILES) CMakeLists.txt
+
+dist-hook:
+ rm -rf `find $(distdir) -name .svn`
+
+
if WITH_SIMD
test: testclean all
diff --git a/common/jpeg/simd/CMakeLists.txt b/common/jpeg/simd/CMakeLists.txt
new file mode 100644
index 0000000..5be325e
--- /dev/null
+++ b/common/jpeg/simd/CMakeLists.txt
@@ -0,0 +1,62 @@
+if(NOT DEFINED NASM)
+ set(NASM nasm)
+endif()
+
+if(SIMD_X86_64)
+ set(NAFLAGS -fwin64 -DWIN64 -D__x86_64__ -I${CMAKE_SOURCE_DIR}/win/
+ -I${CMAKE_CURRENT_SOURCE_DIR}/)
+else()
+ set(NAFLAGS -fwin32 -DWIN32 -I${CMAKE_SOURCE_DIR}/win/
+ -I${CMAKE_CURRENT_SOURCE_DIR}/)
+endif()
+
+if(MSVC)
+ set(NAFLAGS ${NAFLAGS} -DMSVC)
+endif()
+
+# This only works if building from the command line. There is currently no way
+# to set a variable's value based on the build type when using the MSVC IDE.
+if(CMAKE_BUILD_TYPE STREQUAL "Debug"
+ OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
+ set(NAFLAGS ${NAFLAGS} -g)
+endif()
+
+if(SIMD_X86_64)
+ set(SIMD_BASENAMES jfsseflt-64 jccolss2-64 jdcolss2-64 jcsamss2-64
+ jdsamss2-64 jdmerss2-64 jcqnts2i-64 jfss2fst-64 jfss2int-64 jiss2red-64
+ jiss2int-64 jiss2fst-64 jcqnts2f-64 jiss2flt-64)
+ message(STATUS "Building x86_64 SIMD extensions")
+else()
+ set(SIMD_BASENAMES jsimdcpu jccolmmx jdcolmmx jcsammmx jdsammmx jdmermmx
+ jcqntmmx jfmmxfst jfmmxint jimmxred jimmxint jimmxfst jcqnt3dn jf3dnflt
+ ji3dnflt jcqntsse jfsseflt jisseflt jccolss2 jdcolss2 jcsamss2 jdsamss2
+ jdmerss2 jcqnts2i jfss2fst jfss2int jiss2red jiss2int jiss2fst jcqnts2f
+ jiss2flt)
+ message(STATUS "Building i386 SIMD extensions")
+endif()
+
+if(MSVC_IDE)
+ set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/$(OutDir)")
+else()
+ set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR})
+endif()
+
+foreach(file ${SIMD_BASENAMES})
+ set(DEPFILE "")
+ set(SIMD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${file}.asm)
+ if(${file} MATCHES col)
+ set(DEPFILE ${SIMD_SRC})
+ string(REGEX REPLACE "col" "clr" DEPFILE ${DEPFILE})
+ endif()
+ if(${file} MATCHES mer)
+ set(DEPFILE ${SIMD_SRC})
+ string(REGEX REPLACE "mer" "mrg" DEPFILE ${DEPFILE})
+ endif()
+ set(SIMD_OBJ ${OBJDIR}/${file}.obj)
+ add_custom_command(OUTPUT ${SIMD_OBJ} DEPENDS ${SIMD_SRC} ${DEPFILE} *.inc
+ COMMAND ${NASM} ${NAFLAGS} ${SIMD_SRC} -o${SIMD_OBJ})
+ set(SIMD_OBJS ${SIMD_OBJS} ${SIMD_OBJ})
+endforeach()
+
+set(SIMD_OBJS ${SIMD_OBJS} PARENT_SCOPE)
+add_custom_target(simd DEPENDS ${SIMD_OBJS})
diff --git a/common/jpeg/simd/Makefile.am b/common/jpeg/simd/Makefile.am
index a114c37..81c23af 100644
--- a/common/jpeg/simd/Makefile.am
+++ b/common/jpeg/simd/Makefile.am
@@ -4,7 +4,7 @@
EXTRA_DIST = nasm_lt.sh jcclrmmx.asm jcclrss2.asm jdclrmmx.asm jdclrss2.asm \
jdmrgmmx.asm jdmrgss2.asm jcclrss2-64.asm jdclrss2-64.asm \
- jdmrgss2-64.asm
+ jdmrgss2-64.asm CMakeLists.txt
if SIMD_X86_64
diff --git a/common/network/CMakeLists.txt b/common/network/CMakeLists.txt
new file mode 100644
index 0000000..2afba7c
--- /dev/null
+++ b/common/network/CMakeLists.txt
@@ -0,0 +1,4 @@
+include_directories(${CMAKE_SOURCE_DIR}/common)
+
+add_library(network STATIC
+ TcpSocket.cxx)
diff --git a/common/network/Makefile.am b/common/network/Makefile.am
index 3db5536..ab8d5ae 100644
--- a/common/network/Makefile.am
+++ b/common/network/Makefile.am
@@ -6,3 +6,4 @@
libnetwork_la_CPPFLAGS = -I$(top_srcdir)/common
+EXTRA_DIST = CMakeLists.txt
diff --git a/common/os/CMakeLists.txt b/common/os/CMakeLists.txt
new file mode 100644
index 0000000..bbeec50
--- /dev/null
+++ b/common/os/CMakeLists.txt
@@ -0,0 +1,5 @@
+include_directories(${CMAKE_SOURCE_DIR}/common)
+
+add_library(os STATIC
+ print.c
+ net.c)
diff --git a/common/os/Makefile.am b/common/os/Makefile.am
index 5e37290..ed98579 100644
--- a/common/os/Makefile.am
+++ b/common/os/Makefile.am
@@ -6,3 +6,4 @@
libos_la_CPPFLAGS = -I$(top_srcdir)/common
+EXTRA_DIST = CMakeLists.txt
diff --git a/common/rdr/CMakeLists.txt b/common/rdr/CMakeLists.txt
new file mode 100644
index 0000000..2872fd7
--- /dev/null
+++ b/common/rdr/CMakeLists.txt
@@ -0,0 +1,17 @@
+include_directories(${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/common/zlib)
+
+add_library(rdr STATIC
+ Exception.cxx
+ FdInStream.cxx
+ FdOutStream.cxx
+ HexInStream.cxx
+ HexOutStream.cxx
+ InStream.cxx
+ RandomStream.cxx
+ TLSException.cxx
+ TLSInStream.cxx
+ TLSOutStream.cxx
+ ZlibInStream.cxx
+ ZlibOutStream.cxx)
+
+target_link_libraries(rdr zlib os)
diff --git a/common/rdr/Makefile.am b/common/rdr/Makefile.am
index ff741c8..ef911c2 100644
--- a/common/rdr/Makefile.am
+++ b/common/rdr/Makefile.am
@@ -18,3 +18,5 @@
librdr_la_CPPFLAGS += -I$(top_srcdir)/common/zlib
librdr_la_LIBADD += $(top_builddir)/common/zlib/libz.la
endif
+
+EXTRA_DIST = CMakeLists.txt
diff --git a/common/rfb/CMakeLists.txt b/common/rfb/CMakeLists.txt
new file mode 100644
index 0000000..6bfb5fe
--- /dev/null
+++ b/common/rfb/CMakeLists.txt
@@ -0,0 +1,70 @@
+include_directories(${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/win
+ ${CMAKE_SOURCE_DIR}/common/jpeg ${CMAKE_SOURCE_DIR}/common/jpeg/win)
+
+add_library(rfb STATIC
+ Blacklist.cxx
+ CConnection.cxx
+ CMsgHandler.cxx
+ CMsgReader.cxx
+ CMsgReaderV3.cxx
+ CMsgWriter.cxx
+ CMsgWriterV3.cxx
+ CSecurityPlain.cxx
+ CSecurityStack.cxx
+ CSecurityVeNCrypt.cxx
+ CSecurityVncAuth.cxx
+ CapsContainer.cxx
+ CapsList.cxx
+ ComparingUpdateTracker.cxx
+ Configuration.cxx
+ ConnParams.cxx
+ Cursor.cxx
+ Decoder.cxx
+ d3des.c
+ Encoder.cxx
+ HTTPServer.cxx
+ HextileDecoder.cxx
+ HextileEncoder.cxx
+ KeyRemapper.cxx
+ LogWriter.cxx
+ Logger.cxx
+ Logger_file.cxx
+ Logger_stdio.cxx
+ Password.cxx
+ PixelBuffer.cxx
+ PixelFormat.cxx
+ RREEncoder.cxx
+ RREDecoder.cxx
+ RawDecoder.cxx
+ RawEncoder.cxx
+ Region.cxx
+ SConnection.cxx
+ SMsgHandler.cxx
+ SMsgReader.cxx
+ SMsgReaderV3.cxx
+ SMsgWriter.cxx
+ SMsgWriterV3.cxx
+ ServerCore.cxx
+ Security.cxx
+ SecurityServer.cxx
+ SecurityClient.cxx
+ SSecurityPlain.cxx
+ SSecurityStack.cxx
+ SSecurityVncAuth.cxx
+ SSecurityVeNCrypt.cxx
+ ScaledPixelBuffer.cxx
+ ScaleFilters.cxx
+ Timer.cxx
+ TightDecoder.cxx
+ TightEncoder.cxx
+ TightPalette.cxx
+ TransImageGetter.cxx
+ UpdateTracker.cxx
+ VNCSConnectionST.cxx
+ VNCServerST.cxx
+ ZRLEEncoder.cxx
+ ZRLEDecoder.cxx
+ encodings.cxx
+ util.cxx)
+
+target_link_libraries(rfb jpeg os)
diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am
index ce196c6..796c10b 100644
--- a/common/rfb/Makefile.am
+++ b/common/rfb/Makefile.am
@@ -66,3 +66,5 @@
librfb_la_CPPFLAGS += -I$(top_srcdir)/common/jpeg -I$(top_builddir)/common/jpeg
librfb_la_LIBADD += $(top_builddir)/common/jpeg/libjpeg.la
endif
+
+EXTRA_DIST = CMakeLists.txt
diff --git a/common/zlib/CMakeLists.txt b/common/zlib/CMakeLists.txt
new file mode 100644
index 0000000..3f1db1b
--- /dev/null
+++ b/common/zlib/CMakeLists.txt
@@ -0,0 +1,18 @@
+add_definitions(-DNO_VIZ -DWINDOWS)
+
+add_library(zlib STATIC
+ adler32.c
+ compress.c
+ crc32.c
+ deflate.c
+ gzclose.c
+ gzlib.c
+ gzread.c
+ gzwrite.c
+ inflate.c
+ infback.c
+ inftrees.c
+ inffast.c
+ trees.c
+ uncompr.c
+ zutil.c)
diff --git a/common/zlib/Makefile.am b/common/zlib/Makefile.am
index a8c7318..743ac5c 100644
--- a/common/zlib/Makefile.am
+++ b/common/zlib/Makefile.am
@@ -3,6 +3,8 @@
HDRS = deflate.h infblock.h infcodes.h inffast.h inffixed.h inftrees.h \
infutil.h trees.h zconf.h zlib.h zutil.h
-libz_la_SOURCES = $(HDRS) adler32.c compress.c crc32.c deflate.c gzclose.c \
- gzlib.c gzread.c gzwrite.c inflate.c infback.c inftrees.c inffast.c \
- trees.c uncompr.c zutil.c
+libz_la_SOURCES = $(HDRS) adler32.c compress.c crc32.c deflate.c gzclose.c \
+ gzlib.c gzread.c gzwrite.c inflate.c infback.c inftrees.c inffast.c \
+ trees.c uncompr.c zutil.c
+
+EXTRA_DIST = CMakeLists.txt