From e442abc6807d37466b8a9f46058de41608c1d7a0 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 29 Sep 2020 16:05:09 +0100 Subject: [PATCH 1/8] cmake: copy files from vcpkg --- CMakeLists.txt | 114 ++++++++++++++++++++++++++++++ unofficial-theora-config.cmake.in | 3 + win32/xmingw32/libtheora.def | 61 ++++++++++++++++ 3 files changed, 178 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 unofficial-theora-config.cmake.in create mode 100644 win32/xmingw32/libtheora.def diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..0d4aed76 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,114 @@ +cmake_minimum_required(VERSION 3.0) +project(theora LANGUAGES C) + +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}") +FIND_PACKAGE(Ogg REQUIRED) + +file(GLOB HEADERS + "include/theora/codec.h" + "include/theora/theora.h" + "include/theora/theoradec.h" + "include/theora/theoraenc.h" +) + +set(LIBTHEORA_COMMON + "lib/apiwrapper.c" + "lib/bitpack.c" + "lib/dequant.c" + "lib/fragment.c" + "lib/idct.c" + "lib/info.c" + "lib/internal.c" + "lib/state.c" + "lib/quant.c" + + "lib/x86_vc/mmxfrag.c" + "lib/x86_vc/mmxidct.c" + "lib/x86_vc/mmxstate.c" + "lib/x86_vc/x86cpu.c" + "lib/x86_vc/x86state.c" +) + +set(LIBTHEORA_ENC + "lib/analyze.c" + "lib/encapiwrapper.c" + "lib/encfrag.c" + "lib/encinfo.c" + "lib/encode.c" + "lib/enquant.c" + "lib/fdct.c" + "lib/huffenc.c" + "lib/mathops.c" + "lib/mcenc.c" + "lib/rate.c" + "lib/tokenize.c" + + "lib/x86_vc/mmxencfrag.c" + "lib/x86_vc/mmxfdct.c" + "lib/x86_vc/x86enc.c" +) + +set(LIBTHEORA_DEC + "lib/decapiwrapper.c" + "lib/decinfo.c" + "lib/decode.c" + "lib/huffdec.c" +) + +add_definitions(-D_CRT_SECURE_NO_DEPRECATE) +add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + +option(USE_X86 "Use x86 optimization" OFF) +if(USE_X86) + add_definitions(-DOC_X86_ASM) +endif() + +if (BUILD_SHARED_LIBS) + add_definitions(-DLIBTHEORA_EXPORTS) +endif() + +add_library(theora-common OBJECT ${LIBTHEORA_COMMON} ${HEADERS}) +target_link_libraries(theora-common PUBLIC Ogg::ogg) +target_include_directories(theora-common PUBLIC $ $) +add_library(theora-enc OBJECT ${LIBTHEORA_ENC} ${HEADERS}) +target_link_libraries(theora-enc PUBLIC Ogg::ogg) +target_include_directories(theora-enc PUBLIC $ $) +add_library(theora-dec OBJECT ${LIBTHEORA_DEC} ${HEADERS}) +target_link_libraries(theora-dec PUBLIC Ogg::ogg) +target_include_directories(theora-dec PUBLIC $ $) + +add_library(theora $ $ $ "libtheora.def") +target_link_libraries(theora PUBLIC Ogg::ogg) +target_include_directories(theora PUBLIC $ $) + +add_library(theoraenc $ $ "win32/xmingw32/libtheoraenc-all.def") +target_link_libraries(theoraenc PUBLIC Ogg::ogg) +target_include_directories(theoraenc PUBLIC $ $) + +add_library(theoradec $ $ "win32/xmingw32/libtheoradec-all.def") +target_link_libraries(theoradec PUBLIC Ogg::ogg) +target_include_directories(theoradec PUBLIC $ $) + +include(CMakePackageConfigHelpers) + +configure_package_config_file(unofficial-theora-config.cmake.in unofficial-theora-config.cmake + INSTALL_DESTINATION "lib/unofficial-theora") + +install(FILES ${HEADERS} DESTINATION include/theora) + +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-theora-config.cmake" + DESTINATION "lib/unofficial-theora" +) + +install(TARGETS theora theoraenc theoradec + EXPORT unofficial-theora-targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION bin + ARCHIVE DESTINATION lib +) + +install(EXPORT unofficial-theora-targets + NAMESPACE unofficial::theora:: + DESTINATION "lib/unofficial-theora" +) diff --git a/unofficial-theora-config.cmake.in b/unofficial-theora-config.cmake.in new file mode 100644 index 00000000..af1974f4 --- /dev/null +++ b/unofficial-theora-config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-theora-targets.cmake") diff --git a/win32/xmingw32/libtheora.def b/win32/xmingw32/libtheora.def new file mode 100644 index 00000000..9755b81e --- /dev/null +++ b/win32/xmingw32/libtheora.def @@ -0,0 +1,61 @@ +EXPORTS +; Old alpha API + theora_version_string + theora_version_number + theora_decode_header + theora_decode_init + theora_decode_packetin + theora_decode_YUVout + theora_control + theora_packet_isheader + theora_packet_iskeyframe + theora_granule_shift + theora_granule_frame + theora_granule_time + theora_info_init + theora_info_clear + theora_clear + theora_comment_init + theora_comment_add + theora_comment_add_tag + theora_comment_query + theora_comment_query_count + theora_comment_clear +; New theora-exp API + th_version_string + th_version_number + th_decode_headerin + th_decode_alloc + th_setup_free + th_decode_ctl + th_decode_packetin + th_decode_ycbcr_out + th_decode_free + th_packet_isheader + th_packet_iskeyframe + th_granule_frame + th_granule_time + th_info_init + th_info_clear + th_comment_init + th_comment_add + th_comment_add_tag + th_comment_query + th_comment_query_count + th_comment_clear +; Old alpha API + theora_encode_init + theora_encode_YUVin + theora_encode_packetout + theora_encode_header + theora_encode_comment + theora_encode_tables +; New theora-exp API + th_encode_alloc + th_encode_ctl + th_encode_flushheader + th_encode_ycbcr_in + th_encode_packetout + th_encode_free + TH_VP31_QUANT_INFO + TH_VP31_HUFF_CODES From b5a1ef25aa3cc784f7de8bc31efd9e6a4e897c95 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 29 Sep 2020 16:06:33 +0100 Subject: [PATCH 2/8] cmake: remove unofficial prefix --- CMakeLists.txt | 16 ++++++++-------- theora-config.cmake.in | 3 +++ unofficial-theora-config.cmake.in | 3 --- 3 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 theora-config.cmake.in delete mode 100644 unofficial-theora-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d4aed76..004106b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,24 +91,24 @@ target_include_directories(theoradec PUBLIC $ Date: Tue, 29 Sep 2020 16:09:50 +0100 Subject: [PATCH 3/8] cmake: remove unused option --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 004106b7..bde1473e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,10 +63,6 @@ if(USE_X86) add_definitions(-DOC_X86_ASM) endif() -if (BUILD_SHARED_LIBS) - add_definitions(-DLIBTHEORA_EXPORTS) -endif() - add_library(theora-common OBJECT ${LIBTHEORA_COMMON} ${HEADERS}) target_link_libraries(theora-common PUBLIC Ogg::ogg) target_include_directories(theora-common PUBLIC $ $) From a4d6b9c776a168730e06598928f21a7bf3f353e8 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 29 Sep 2020 16:11:15 +0100 Subject: [PATCH 4/8] cmake: fix path of new def file --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bde1473e..7ba8f476 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,7 @@ add_library(theora-dec OBJECT ${LIBTHEORA_DEC} ${HEADERS}) target_link_libraries(theora-dec PUBLIC Ogg::ogg) target_include_directories(theora-dec PUBLIC $ $) -add_library(theora $ $ $ "libtheora.def") +add_library(theora $ $ $ "win32/xmingw32/libtheora.def") target_link_libraries(theora PUBLIC Ogg::ogg) target_include_directories(theora PUBLIC $ $) From 052b0b7a3c73eacb2a445bccd5e51b44a55defb0 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 29 Sep 2020 17:48:51 +0100 Subject: [PATCH 5/8] cmake: add testing --- .gitignore | 2 ++ CMakeLists.txt | 4 ++++ tests/CMakeLists.txt | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/CMakeLists.txt diff --git a/.gitignore b/.gitignore index f841751f..3af5ded5 100644 --- a/.gitignore +++ b/.gitignore @@ -82,3 +82,5 @@ tests/granulepos_theoraenc tests/noop tests/noop_theora tests/noop_theoraenc + +.vs/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ba8f476..39966879 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.0) project(theora LANGUAGES C) +enable_testing() + set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}") FIND_PACKAGE(Ogg REQUIRED) @@ -108,3 +110,5 @@ install(EXPORT theora-targets NAMESPACE theora:: DESTINATION "lib/theora" ) + +add_subdirectory(tests) \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..c653ebb6 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.0) +project(tests LANGUAGES C) + +add_executable(comment comment.c) +add_executable(comment_theora comment_theora.c) +add_executable(granulepos granulepos.c) +add_executable(granulepos_theora granulepos_theora.c) +add_executable(noop noop.c) +add_executable(noop_theora noop_theora.c) +target_link_libraries(comment PRIVATE theora) +target_link_libraries(comment_theora PRIVATE theora) +target_link_libraries(granulepos PRIVATE theora) +target_link_libraries(granulepos_theora PRIVATE theora) +target_link_libraries(noop PRIVATE theora) +target_link_libraries(noop_theora PRIVATE theora) +add_test(test_comment comment) +add_test(test_comment_theora comment_theora) +add_test(test_granulepos granulepos) +add_test(test_granulepos_theora granulepos_theora) +add_test(test_noop noop) +add_test(test_noop_theora noop_theora) From e2987fe3d121eeca2aee2c5d9796b1194691c365 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 29 Sep 2020 17:50:46 +0100 Subject: [PATCH 6/8] cmake: ignore out/ folder --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3af5ded5..6a9b7db1 100644 --- a/.gitignore +++ b/.gitignore @@ -83,4 +83,5 @@ tests/noop tests/noop_theora tests/noop_theoraenc -.vs/ \ No newline at end of file +.vs/ +out/ \ No newline at end of file From 4a0148a2328c445664b7dbd39010aacfc58ac384 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 29 Sep 2020 17:54:56 +0100 Subject: [PATCH 7/8] cmake: allow tests to run without config.h --- tests/tests.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/tests.h b/tests/tests.h index dd420b21..21c6bf33 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -15,7 +15,9 @@ ********************************************************************/ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include #include From 45a16782f7e7da46153342ddf625ba380919eff1 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 29 Sep 2020 17:58:29 +0100 Subject: [PATCH 8/8] cmake: add settings file for visual studio --- CMakeSettings.json | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 CMakeSettings.json diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 00000000..78e0fcb5 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,76 @@ +{ + "configurations": [ + { + "name": "x86-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x86" ], + "variables": [ + { + "name": "USE_X86", + "value": "True", + "type": "BOOL" + } + ] + }, + { + "name": "x86-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x86" ], + "variables": [ + { + "name": "USE_X86", + "value": "True", + "type": "BOOL" + } + ] + }, + { + "name": "x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { + "name": "USE_X86", + "value": "False", + "type": "BOOL" + } + ] + }, + { + "name": "x64-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [ + { + "name": "USE_X86", + "value": "False", + "type": "BOOL" + } + ] + } + ] +} \ No newline at end of file