diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index bd93a6e80..cfc8c1c01 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -1,39 +1,27 @@ +if(OS_WINDOWS) + if(NOT MINGW) + add_subdirectory(w32-pthreads) + endif() + add_subdirectory(ipc-util) -if(NOT MINGW) -add_subdirectory(w32-pthreads) + add_subdirectory(blake2) + add_subdirectory(lzma) endif() add_subdirectory(glad) -add_subdirectory(ipc-util) - -if(BUILD_LIBFF) - add_subdirectory(libff) -endif() - add_subdirectory(media-playback) add_subdirectory(file-updater) add_subdirectory(obs-scripting) add_subdirectory(opts-parser) - -if(WIN32) - add_subdirectory(blake2) - add_subdirectory(lzma) -endif() - add_subdirectory(libcaption) +# Use bundled jansson version as fallback find_package(Jansson 2.5 QUIET) +if(NOT TARGET Jansson::Jansson) + message(STATUS "OBS: Jansson >=2.5 not found, building bundled version") -if(NOT JANSSON_FOUND) - message(STATUS "Jansson >=2.5 not found, building bundled version") - - add_subdirectory(jansson) - - set(OBS_JANSSON_IMPORT "jansson" CACHE INTERNAL "Internal var") - set(OBS_JANSSON_INCLUDE_DIRS "" CACHE INTERNAL "Internal var") + add_subdirectory(jansson) + add_library(Jansson::Jansson ALIAS jansson) else() - message(STATUS "Using system Jansson library") - - set(OBS_JANSSON_IMPORT "${JANSSON_LIBRARIES}" CACHE INTERNAL "Internal var") - set(OBS_JANSSON_INCLUDE_DIRS "${JANSSON_INCLUDE_DIRS}" CACHE INTERNAL "Internal var") + message(STATUS "OBS: OBS-Studio - Using system Jansson library") endif() diff --git a/deps/blake2/CMakeLists.txt b/deps/blake2/CMakeLists.txt index 6c407a202..393efa8d9 100644 --- a/deps/blake2/CMakeLists.txt +++ b/deps/blake2/CMakeLists.txt @@ -1,33 +1,18 @@ -cmake_minimum_required(VERSION 3.2) - project(blake2) -set(BLAKE2_INCLUDE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/src" - CACHE PATH "blake2 include path") +add_library(blake2 STATIC) +add_library(OBS::blake2 ALIAS blake2) -include_directories( - ${LIBblake2_INCLUDE_DIRS} - src -) +target_sources(blake2 PRIVATE src/blake2b-ref.c src/blake2.h src/blake2-impl.h) -if(WIN32) - if(MSVC) - add_compile_options($,/MTd,/MT> /Zl) - endif() - add_definitions( - -Dinline=_inline - -Drestrict=__restrict) +target_include_directories(blake2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) + +if(OS_WINDOWS) + if(MSVC) + target_compile_options(blake2 PRIVATE "$,/MTd,/MT>" /Zl) + endif() + + target_compile_definitions(blake2 PRIVATE inline=_inline restrict=__restrict) endif() -set(blake2_SOURCES - src/blake2b-ref.c) - -set(blake2_HEADERS - src/blake2.h - src/blake2-impl.h) - -add_library(blake2 STATIC - ${blake2_SOURCES} - ${blake2_HEADERS}) set_target_properties(blake2 PROPERTIES FOLDER "deps") diff --git a/deps/file-updater/CMakeLists.txt b/deps/file-updater/CMakeLists.txt index 0b46b6644..3ac04deeb 100644 --- a/deps/file-updater/CMakeLists.txt +++ b/deps/file-updater/CMakeLists.txt @@ -1,31 +1,17 @@ project(file-updater) -find_package(Libcurl REQUIRED) +find_package(CURL REQUIRED) -include_directories(${LIBCURL_INCLUDE_DIRS}) +add_library(file-updater INTERFACE) +add_library(OBS::file-updater ALIAS file-updater) -if(WIN32 AND NOT MINGW) - include_directories(../w32-pthreads) - set(file-updater_PLATFORM_DEPS - w32-pthreads) +target_sources(file-updater INTERFACE file-updater/file-updater.c + file-updater/file-updater.h) + +target_link_libraries(file-updater INTERFACE CURL::libcurl) + +target_include_directories(file-updater INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + +if(OS_WINDOWS AND NOT MINGW) + target_link_libraries(file-updater INTERFACE OBS::w32-pthreads) endif() - -set(file-updater_HEADERS - file-updater/file-updater.h) -set(file-updater_SOURCES - file-updater/file-updater.c) - -add_library(file-updater STATIC - ${file-updater_SOURCES} - ${file-updater_HEADERS}) - -target_include_directories(file-updater - PUBLIC .) - -target_link_libraries(file-updater - ${LIBCURL_LIBRARIES} - ${file-updater_PLATFORM_DEPS} - libobs) -set_target_properties(file-updater PROPERTIES - FOLDER "deps" - POSITION_INDEPENDENT_CODE ON) diff --git a/deps/glad/CMakeLists.txt b/deps/glad/CMakeLists.txt index 83f4efac5..b23f10f2c 100644 --- a/deps/glad/CMakeLists.txt +++ b/deps/glad/CMakeLists.txt @@ -1,76 +1,51 @@ project(glad) -find_package(OpenGL) +find_package(OpenGL REQUIRED) + +add_library(glad SHARED) +add_library(OBS::obsglad ALIAS glad) + +target_sources(glad PRIVATE src/glad.c include/glad/glad.h) + +target_include_directories(glad PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) + +target_compile_definitions(glad PRIVATE GLAD_GLAPI_EXPORT_BUILD) + +target_link_libraries(glad PUBLIC OpenGL::GL) + +set_target_properties( + glad + PROPERTIES OUTPUT_NAME obsglad + FOLDER "deps" + VERSION "${OBS_VERSION_MAJOR}" + SOVERSION "1") + +if(OS_WINDOWS) + set(MODULE_DESCRIPTION "Glad OpenGL Loading Library") + + configure_file(${CMAKE_SOURCE_DIR}/cmake/bundle/windows/obs-module.rc.in + obsglad.rc) + + target_sources(glad PRIVATE src/glad_wgl.c include/glad/glad_wgl.h obsglad.rc) + +elseif(OS_POSIX AND NOT OS_MACOS) + find_package(OpenGL REQUIRED) + find_package(X11 REQUIRED) + + target_link_libraries(glad PRIVATE X11::X11) + + target_sources(glad PRIVATE src/glad_glx.c include/glad/glad_glx.h) + + if(TARGET OpenGL::EGL) + target_sources(glad PRIVATE src/glad_egl.c include/glad/glad_egl.h) + + target_link_libraries(glad PRIVATE OpenGL::EGL) + endif() -if(NOT WIN32 AND NOT APPLE) - find_package(X11 REQUIRED) - find_package(EGL REQUIRED) endif() -set(glad_SOURCES - src/glad.c - include/glad/glad.h) - -if(WIN32) - set(MODULE_DESCRIPTION "Glad OpenGL Loading Library") - configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obsglad.rc) - set(glad_PLATFORM_SOURCES - src/glad_wgl.c - include/glad/glad_wgl.h - obsglad.rc) -elseif(NOT APPLE) - set(glad_PLATFORM_SOURCES - src/glad_egl.c - src/glad_glx.c - include/glad/glad_egl.h - include/glad/glad_glx.h) -endif() - -set(glad_include_dirs - PRIVATE ${OPENGL_INCLUDE_DIR}) - -if (UNIX AND NOT APPLE) -list (APPEND glad_include_dirs - PRIVATE - ${X11_X11_INCLUDE_PATH} - ${EGL_INCLUDE_DIRS}) -endif() - -add_library(glad SHARED - ${glad_SOURCES} - ${glad_PLATFORM_SOURCES}) -set_target_properties(glad PROPERTIES - FOLDER "deps" - OUTPUT_NAME obsglad - VERSION "0" - SOVERSION "0" - POSITION_INDEPENDENT_CODE ON) -target_include_directories(glad - PUBLIC include - ${glad_include_dirs}) -target_compile_definitions(glad - PRIVATE GLAD_GLAPI_EXPORT_BUILD) - if(NOT MSVC) - target_compile_options(glad - PRIVATE -DPIC -fvisibility=hidden) + target_compile_options(glad PRIVATE -fvisibility=hidden) endif() -if(NOT WIN32 AND NOT APPLE) - set(glad_PLATFORM_DEPS - ${X11_X11_LIB} - ${EGL_LIBRARIES}) - - # only link to libdl on linux - if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(glad_PLATFORM_DEPS - ${glad_PLATFORM_DEPS} - -ldl) - endif() -endif() - -target_link_libraries(glad - ${glad_PLATFORM_DEPS} - ${OPENGL_gl_LIBRARY}) - -install_obs_core(glad) +setup_binary_target(glad) diff --git a/deps/ipc-util/CMakeLists.txt b/deps/ipc-util/CMakeLists.txt index 66f63a07e..8250503a5 100644 --- a/deps/ipc-util/CMakeLists.txt +++ b/deps/ipc-util/CMakeLists.txt @@ -1,37 +1,23 @@ -# TODO: Add posix support -if(NOT WIN32) - return() -endif() - project(ipc-util) -set(ipc-util_HEADERS - ipc-util/pipe.h) +add_library(ipc-util STATIC) +add_library(OBS::ipc-util ALIAS ipc-util) -if(WIN32) - set(ipc-util_HEADERS - ${ipc-util_HEADERS} - ipc-util/pipe-windows.h) - set(ipc-util_SOURCES - ipc-util/pipe-windows.c) +target_sources(ipc-util PRIVATE ipc-util/pipe.h) + +set_target_properties(ipc-util PROPERTIES FOLDER "deps" + POSITION_INDEPENDENT_CODE ON) + +target_include_directories(ipc-util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +if(OS_WINDOWS) + if(MSVC) + target_compile_options(ipc-util PRIVATE "$,/MTd,/MT>" + /Zl) + endif() + + target_sources(ipc-util PRIVATE ipc-util/pipe-windows.c + ipc-util/pipe-windows.h) else() - set(ipc-util_HEADERS - ${ipc-util_HEADERS} - ipc-util/pipe-posix.h) - set(ipc-util_SOURCES - ipc-util/pipe-posix.c) + target_sources(ipc-util PRIVATE ipc-util/pipe-posix.c ipc-util/pipe-posic.h) endif() - -if(MSVC) - add_compile_options($,/MTd,/MT> /Zl) -endif() - -add_library(ipc-util STATIC - ${ipc-util_SOURCES} - ${ipc-util_HEADERS}) -set_target_properties(ipc-util PROPERTIES - FOLDER "deps" - POSITION_INDEPENDENT_CODE ON) -target_include_directories(ipc-util - PUBLIC .) -target_link_libraries(ipc-util) diff --git a/deps/jansson/CMakeLists.txt b/deps/jansson/CMakeLists.txt index a0b27c149..e514324a7 100644 --- a/deps/jansson/CMakeLists.txt +++ b/deps/jansson/CMakeLists.txt @@ -1,12 +1,10 @@ # Notes: # -# Author: Paul Harris, June 2012 -# Additions: Joakim Soderberg, Febuary 2013 +# Author: Paul Harris, June 2012 Additions: Joakim Soderberg, Febuary 2013 # # Supports: building static/shared, release/debug/etc, can also build html docs -# and some of the tests. -# Note that its designed for out-of-tree builds, so it will not pollute your -# source tree. +# and some of the tests. Note that its designed for out-of-tree builds, so it +# will not pollute your source tree. # # TODO 1: Finish implementing tests. api tests are working, but the valgrind # variants are not flagging problems. @@ -15,60 +13,53 @@ # # TODO 3: Consolidate version numbers, currently the version number is written # into: * cmake (here) * autotools (the configure) * source code header files. -# Should not be written directly into header files, autotools/cmake can do -# that job. +# Should not be written directly into header files, autotools/cmake can do that +# job. # -# Brief intro on how to use cmake: -# > mkdir build (somewhere - we do out-of-tree builds) -# > use cmake, ccmake, or cmake-gui to configure the project. for linux, you -# can only choose one variant: release,debug,etc... and static or shared. -# >> example: -# >> cd build -# >> ccmake -i ../path_to_jansson_dir -# >> inside, configure your options. press C until there are no lines -# with * next to them. -# >> note, I like to configure the 'install' path to ../install, so I get -# self-contained clean installs I can point other projects to. -# >> press G to 'generate' the project files. -# >> make (to build the project) -# >> make install -# >> make test (to run the tests, if you enabled them) +# Brief intro on how to use cmake: > mkdir build (somewhere - we do out-of-tree +# builds) > use cmake, ccmake, or cmake-gui to configure the project. for linux, +# you can only choose one variant: release,debug,etc... and static or shared. >> +# example: >> cd build >> ccmake -i ../path_to_jansson_dir >> inside, configure +# your options. press C until there are no lines with * next to them. >> note, +# I like to configure the 'install' path to ../install, so I get self-contained +# clean installs I can point other projects to. >> press G to 'generate' the +# project files. >> make (to build the project) >> make install >> make test (to +# run the tests, if you enabled them) # -# Brief description on how it works: -# There is a small heirachy of CMakeLists.txt files which define how the -# project is built. -# Header file detection etc is done, and the results are written into config.h -# and jansson_config.h, which are generated from the corresponding -# config.h.cmake and jansson_config.h.cmake template files. -# The generated header files end up in the build directory - not in -# the source directory. -# The rest is down to the usual make process. +# Brief description on how it works: There is a small heirachy of CMakeLists.txt +# files which define how the project is built. Header file detection etc is +# done, and the results are written into config.h and jansson_config.h, which +# are generated from the corresponding config.h.cmake and jansson_config.h.cmake +# template files. The generated header files end up in the build directory - not +# in the source directory. The rest is down to the usual make process. - - -cmake_minimum_required (VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8.12) # required for exports? cmake_minimum_required (VERSION 2.8.6) -project (jansson C) +project(jansson C) # Options option(JANSSON_BUILD_SHARED_LIBS "Build shared libraries." OFF) option(USE_URANDOM "Use /dev/urandom to seed the hash function." ON) option(USE_WINDOWS_CRYPTOAPI "Use CryptGenRandom to seed the hash function." ON) -if (MSVC) - # This option must match the settings used in your program, in particular if you - # are linking statically - option(JANSSON_STATIC_CRT "Link the static CRT libraries" ON ) -endif () +if(MSVC) + # This option must match the settings used in your program, in particular if + # you are linking statically + option(JANSSON_STATIC_CRT "Link the static CRT libraries" ON) +endif() # Disabled by OBS option(JANSSON_EXAMPLES "Compile example applications" OFF) -if (UNIX) - option(JANSSON_COVERAGE "(GCC Only! Requires gcov/lcov to be installed). Include target for doing coverage analysis for the test suite. Note that -DCMAKE_BUILD_TYPE=Debug must be set" OFF) - option(JANSSON_COVERALLS "Generate coverage info for Coveralls" OFF) - option(JANSSON_COVERALLS_UPLOAD "Upload coverage info to Coveralls (Only works via Travis)" ON) -endif () +if(UNIX) + option( + JANSSON_COVERAGE + "(GCC Only! Requires gcov/lcov to be installed). Include target for doing coverage analysis for the test suite. Note that -DCMAKE_BUILD_TYPE=Debug must be set" + OFF) + option(JANSSON_COVERALLS "Generate coverage info for Coveralls" OFF) + option(JANSSON_COVERALLS_UPLOAD + "Upload coverage info to Coveralls (Only works via Travis)" ON) +endif() # Set some nicer output dirs. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) @@ -76,16 +67,14 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) set(JANSSON_TEMP_DIR ${PROJECT_BINARY_DIR}/tmp) -# Give the debug version a different postfix for windows, -# so both the debug and release version can be built in the -# same build-tree on Windows (MSVC). -if (WIN32) - set(CMAKE_DEBUG_POSTFIX "_d") -endif (WIN32) +# Give the debug version a different postfix for windows, so both the debug and +# release version can be built in the same build-tree on Windows (MSVC). +if(WIN32) + set(CMAKE_DEBUG_POSTFIX "_d") +endif(WIN32) -# This is how I thought it should go -# set (JANSSON_VERSION "2.3.1") -# set (JANSSON_SOVERSION 2) +# This is how I thought it should go set (JANSSON_VERSION "2.3.1") set +# (JANSSON_SOVERSION 2) set(JANSSON_DISPLAY_VERSION "2.9") @@ -96,502 +85,519 @@ set(JANSSON_SOVERSION 4) # for CheckFunctionKeywords set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include (CheckCSourceCompiles) -include (CheckFunctionExists) -include (CheckFunctionKeywords) -include (CheckIncludeFiles) -include (CheckTypeSize) +include(CheckCSourceCompiles) +include(CheckFunctionExists) +include(CheckFunctionKeywords) +include(CheckIncludeFiles) +include(CheckTypeSize) -if (MSVC) - # Turn off Microsofts "security" warnings. - add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo" ) +if(MSVC) + # Turn off Microsofts "security" warnings. + add_definitions("/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo") - # Disabled by OBS, options already set by top level CMakeLists - if (FALSE) - if (JANSSON_STATIC_CRT) - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") - endif() - endif() + # Disabled by OBS, options already set by top level CMakeLists + if(FALSE) + if(JANSSON_STATIC_CRT) + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") + endif() + endif() endif() -if (NOT WIN32 AND NOT APPLE) - add_definitions("-fPIC") +if(NOT WIN32 AND NOT APPLE) + add_definitions("-fPIC") endif() message("C compiler: ${CMAKE_C_COMPILER_ID}") # Coverage only works with GCC for a debug build. -if (JANSSON_COVERALLS) - set(JANSSON_COVERAGE ON) +if(JANSSON_COVERALLS) + set(JANSSON_COVERAGE ON) endif() -if (JANSSON_COVERAGE) - include(CodeCoverage) - include(Coveralls) +if(JANSSON_COVERAGE) + include(CodeCoverage) + include(Coveralls) - # This adds coverage arguments to gcc/clang. - coveralls_turn_on_coverage() + # This adds coverage arguments to gcc/clang. + coveralls_turn_on_coverage() endif() -check_include_files (endian.h HAVE_ENDIAN_H) -check_include_files (fcntl.h HAVE_FCNTL_H) -check_include_files (sched.h HAVE_SCHED_H) -check_include_files (unistd.h HAVE_UNISTD_H) -check_include_files (sys/param.h HAVE_SYS_PARAM_H) -check_include_files (sys/stat.h HAVE_SYS_STAT_H) -check_include_files (sys/time.h HAVE_SYS_TIME_H) -check_include_files (sys/time.h HAVE_SYS_TYPES_H) +check_include_files(endian.h HAVE_ENDIAN_H) +check_include_files(fcntl.h HAVE_FCNTL_H) +check_include_files(sched.h HAVE_SCHED_H) +check_include_files(unistd.h HAVE_UNISTD_H) +check_include_files(sys/param.h HAVE_SYS_PARAM_H) +check_include_files(sys/stat.h HAVE_SYS_STAT_H) +check_include_files(sys/time.h HAVE_SYS_TIME_H) +check_include_files(sys/time.h HAVE_SYS_TYPES_H) -check_function_exists (close HAVE_CLOSE) -check_function_exists (getpid HAVE_GETPID) -check_function_exists (gettimeofday HAVE_GETTIMEOFDAY) -check_function_exists (open HAVE_OPEN) -check_function_exists (read HAVE_READ) -check_function_exists (sched_yield HAVE_SCHED_YIELD) +check_function_exists(close HAVE_CLOSE) +check_function_exists(getpid HAVE_GETPID) +check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) +check_function_exists(open HAVE_OPEN) +check_function_exists(read HAVE_READ) +check_function_exists(sched_yield HAVE_SCHED_YIELD) # Check for the int-type includes -check_include_files (stdint.h HAVE_STDINT_H) +check_include_files(stdint.h HAVE_STDINT_H) # Check our 64 bit integer sizes -check_type_size (__int64 __INT64) -check_type_size (int64_t INT64_T) -check_type_size ("long long" LONG_LONG_INT) +check_type_size(__int64 __INT64) +check_type_size(int64_t INT64_T) +check_type_size("long long" LONG_LONG_INT) # Check our 32 bit integer sizes -check_type_size (int32_t INT32_T) -check_type_size (__int32 __INT32) -check_type_size ("long" LONG_INT) -check_type_size ("int" INT) -if (HAVE_INT32_T) - set (JSON_INT32 int32_t) -elseif (HAVE___INT32) - set (JSON_INT32 __int32) -elseif (HAVE_LONG_INT AND (${LONG_INT} EQUAL 4)) - set (JSON_INT32 long) -elseif (HAVE_INT AND (${INT} EQUAL 4)) - set (JSON_INT32 int) -else () - message (FATAL_ERROR "Could not detect a valid 32-bit integer type") -endif () +check_type_size(int32_t INT32_T) +check_type_size(__int32 __INT32) +check_type_size("long" LONG_INT) +check_type_size("int" INT) +if(HAVE_INT32_T) + set(JSON_INT32 int32_t) +elseif(HAVE___INT32) + set(JSON_INT32 __int32) +elseif(HAVE_LONG_INT AND (${LONG_INT} EQUAL 4)) + set(JSON_INT32 long) +elseif(HAVE_INT AND (${INT} EQUAL 4)) + set(JSON_INT32 int) +else() + message(FATAL_ERROR "Could not detect a valid 32-bit integer type") +endif() -check_type_size ("unsigned long" UNSIGNED_LONG_INT) -check_type_size ("unsigned int" UNSIGNED_INT) -check_type_size ("unsigned short" UNSIGNED_SHORT) +check_type_size("unsigned long" UNSIGNED_LONG_INT) +check_type_size("unsigned int" UNSIGNED_INT) +check_type_size("unsigned short" UNSIGNED_SHORT) -check_type_size (uint32_t UINT32_T) -check_type_size (__uint32 __UINT32) -if (HAVE_UINT32_T) - set (JSON_UINT32 uint32_t) -elseif (HAVE___UINT32) - set (JSON_UINT32 __uint32) -elseif (HAVE_UNSIGNED_LONG_INT AND (${UNSIGNED_LONG_INT} EQUAL 4)) - set (JSON_UINT32 "unsigned long") -elseif (HAVE_UNSIGNED_INT AND (${UNSIGNED_INT} EQUAL 4)) - set (JSON_UINT32 "unsigned int") -else () - message (FATAL_ERROR "Could not detect a valid unsigned 32-bit integer type") -endif () +check_type_size(uint32_t UINT32_T) +check_type_size(__uint32 __UINT32) +if(HAVE_UINT32_T) + set(JSON_UINT32 uint32_t) +elseif(HAVE___UINT32) + set(JSON_UINT32 __uint32) +elseif(HAVE_UNSIGNED_LONG_INT AND (${UNSIGNED_LONG_INT} EQUAL 4)) + set(JSON_UINT32 "unsigned long") +elseif(HAVE_UNSIGNED_INT AND (${UNSIGNED_INT} EQUAL 4)) + set(JSON_UINT32 "unsigned int") +else() + message(FATAL_ERROR "Could not detect a valid unsigned 32-bit integer type") +endif() -check_type_size (uint16_t UINT16_T) -check_type_size (__uint16 __UINT16) -if (HAVE_UINT16_T) - set (JSON_UINT16 uint16_t) -elseif (HAVE___UINT16) - set (JSON_UINT16 __uint16) -elseif (HAVE_UNSIGNED_INT AND (${UNSIGNED_INT} EQUAL 2)) - set (JSON_UINT16 "unsigned int") -elseif (HAVE_UNSIGNED_SHORT AND (${UNSIGNED_SHORT} EQUAL 2)) - set (JSON_UINT16 "unsigned short") -else () - message (FATAL_ERROR "Could not detect a valid unsigned 16-bit integer type") -endif () +check_type_size(uint16_t UINT16_T) +check_type_size(__uint16 __UINT16) +if(HAVE_UINT16_T) + set(JSON_UINT16 uint16_t) +elseif(HAVE___UINT16) + set(JSON_UINT16 __uint16) +elseif(HAVE_UNSIGNED_INT AND (${UNSIGNED_INT} EQUAL 2)) + set(JSON_UINT16 "unsigned int") +elseif(HAVE_UNSIGNED_SHORT AND (${UNSIGNED_SHORT} EQUAL 2)) + set(JSON_UINT16 "unsigned short") +else() + message(FATAL_ERROR "Could not detect a valid unsigned 16-bit integer type") +endif() -check_type_size (uint8_t UINT8_T) -check_type_size (__uint8 __UINT8) -if (HAVE_UINT8_T) - set (JSON_UINT8 uint8_t) -elseif (HAVE___UINT8) - set (JSON_UINT8 __uint8) -else () - set (JSON_UINT8 "unsigned char") -endif () +check_type_size(uint8_t UINT8_T) +check_type_size(__uint8 __UINT8) +if(HAVE_UINT8_T) + set(JSON_UINT8 uint8_t) +elseif(HAVE___UINT8) + set(JSON_UINT8 __uint8) +else() + set(JSON_UINT8 "unsigned char") +endif() # Check for ssize_t and SSIZE_T existance. check_type_size(ssize_t SSIZE_T) check_type_size(SSIZE_T UPPERCASE_SSIZE_T) if(NOT HAVE_SSIZE_T) - if(HAVE_UPPERCASE_SSIZE_T) - set(JSON_SSIZE SSIZE_T) - else() - set(JSON_SSIZE int) - endif() + if(HAVE_UPPERCASE_SSIZE_T) + set(JSON_SSIZE SSIZE_T) + else() + set(JSON_SSIZE int) + endif() endif() set(CMAKE_EXTRA_INCLUDE_FILES "") # Check for all the variants of strtoll -check_function_exists (strtoll HAVE_STRTOLL) -check_function_exists (strtoq HAVE_STRTOQ) -check_function_exists (_strtoi64 HAVE__STRTOI64) +check_function_exists(strtoll HAVE_STRTOLL) +check_function_exists(strtoq HAVE_STRTOQ) +check_function_exists(_strtoi64 HAVE__STRTOI64) # Figure out what variant we should use -if (HAVE_STRTOLL) - set (JSON_STRTOINT strtoll) -elseif (HAVE_STRTOQ) - set (JSON_STRTOINT strtoq) -elseif (HAVE__STRTOI64) - set (JSON_STRTOINT _strtoi64) -else () - # fallback to strtol (32 bit) - # this will set all the required variables - set (JSON_STRTOINT strtol) - set (JSON_INT_T long) - set (JSON_INTEGER_FORMAT "\"ld\"") -endif () +if(HAVE_STRTOLL) + set(JSON_STRTOINT strtoll) +elseif(HAVE_STRTOQ) + set(JSON_STRTOINT strtoq) +elseif(HAVE__STRTOI64) + set(JSON_STRTOINT _strtoi64) +else() + # fallback to strtol (32 bit) this will set all the required variables + set(JSON_STRTOINT strtol) + set(JSON_INT_T long) + set(JSON_INTEGER_FORMAT "\"ld\"") +endif() # if we haven't defined JSON_INT_T, then we have a 64 bit conversion function. -# detect what to use for the 64 bit type. -# Note: I will prefer long long if I can get it, as that is what the automake system aimed for. -if (NOT DEFINED JSON_INT_T) - if (HAVE_LONG_LONG_INT AND ((${LONG_LONG_INT}) EQUAL 8)) - set (JSON_INT_T "long long") - elseif (HAVE_INT64_T) - set (JSON_INT_T int64_t) - elseif (HAVE___INT64) - set (JSON_INT_T __int64) - else () - message (FATAL_ERROR "Could not detect 64 bit type, although I detected the strtoll equivalent") - endif () +# detect what to use for the 64 bit type. Note: I will prefer long long if I can +# get it, as that is what the automake system aimed for. +if(NOT DEFINED JSON_INT_T) + if(HAVE_LONG_LONG_INT AND ((${LONG_LONG_INT}) EQUAL 8)) + set(JSON_INT_T "long long") + elseif(HAVE_INT64_T) + set(JSON_INT_T int64_t) + elseif(HAVE___INT64) + set(JSON_INT_T __int64) + else() + message( + FATAL_ERROR + "Could not detect 64 bit type, although I detected the strtoll equivalent" + ) + endif() - # Apparently, Borland BCC and MSVC wants I64d, - # Borland BCC could also accept LD - # and gcc wants ldd, - # I am not sure what cygwin will want, so I will assume I64d - - if (WIN32) # matches both msvc and cygwin - set (JSON_INTEGER_FORMAT "\"I64d\"") - else () - set (JSON_INTEGER_FORMAT "\"lld\"") - endif () -endif () + # Apparently, Borland BCC and MSVC wants I64d, Borland BCC could also accept + # LD and gcc wants ldd, I am not sure what cygwin will want, so I will assume + # I64d + if(WIN32) # matches both msvc and cygwin + set(JSON_INTEGER_FORMAT "\"I64d\"") + else() + set(JSON_INTEGER_FORMAT "\"lld\"") + endif() +endif() # If locale.h and localeconv() are available, define to 1, otherwise to 0. -check_include_files (locale.h HAVE_LOCALE_H) -check_function_exists (localeconv HAVE_LOCALECONV) +check_include_files(locale.h HAVE_LOCALE_H) +check_function_exists(localeconv HAVE_LOCALECONV) -if (HAVE_LOCALECONV AND HAVE_LOCALE_H) - set (JSON_HAVE_LOCALECONV 1) -else () - set (JSON_HAVE_LOCALECONV 0) +if(HAVE_LOCALECONV AND HAVE_LOCALE_H) + set(JSON_HAVE_LOCALECONV 1) +else() + set(JSON_HAVE_LOCALECONV 0) endif() # check if we have setlocale check_function_exists(setlocale HAVE_SETLOCALE) -# Check what the inline keyword is. -# Note that the original JSON_INLINE was always set to just 'inline', so this goes further. +# Check what the inline keyword is. Note that the original JSON_INLINE was +# always set to just 'inline', so this goes further. check_function_keywords("inline") check_function_keywords("__inline") check_function_keywords("__inline__") -if (HAVE_INLINE) - set(JSON_INLINE inline) -elseif (HAVE___INLINE) - set(JSON_INLINE __inline) -elseif (HAVE___INLINE__) - set(JSON_INLINE __inline__) +if(HAVE_INLINE) + set(JSON_INLINE inline) +elseif(HAVE___INLINE) + set(JSON_INLINE __inline) +elseif(HAVE___INLINE__) + set(JSON_INLINE __inline__) else() - # no inline on this platform - set (JSON_INLINE) + # no inline on this platform + set(JSON_INLINE) endif() -check_c_source_compiles ("int main() { unsigned long val; __sync_bool_compare_and_swap(&val, 0, 1); return 0; } " HAVE_SYNC_BUILTINS) -check_c_source_compiles ("int main() { char l; unsigned long v; __atomic_test_and_set(&l, __ATOMIC_RELAXED); __atomic_store_n(&v, 1, __ATOMIC_RELEASE); __atomic_load_n(&v, __ATOMIC_ACQUIRE); return 0; }" HAVE_ATOMIC_BUILTINS) +check_c_source_compiles( + "int main() { unsigned long val; __sync_bool_compare_and_swap(&val, 0, 1); return 0; } " + HAVE_SYNC_BUILTINS) +check_c_source_compiles( + "int main() { char l; unsigned long v; __atomic_test_and_set(&l, __ATOMIC_RELAXED); __atomic_store_n(&v, 1, __ATOMIC_RELEASE); __atomic_load_n(&v, __ATOMIC_ACQUIRE); return 0; }" + HAVE_ATOMIC_BUILTINS) -set (JANSSON_INITIAL_HASHTABLE_ORDER 3 CACHE STRING "Number of buckets new object hashtables contain is 2 raised to this power. The default is 3, so empty hashtables contain 2^3 = 8 buckets.") +set(JANSSON_INITIAL_HASHTABLE_ORDER + 3 + CACHE + STRING + "Number of buckets new object hashtables contain is 2 raised to this power. The default is 3, so empty hashtables contain 2^3 = 8 buckets." +) # configure the public config file -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h) # Copy the jansson.h file to the public include folder -file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/) add_definitions(-DJANSSON_USING_CMAKE) # configure the private config file -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_private_config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_private_config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h) # and tell the source code to include it add_definitions(-DHAVE_CONFIG_H) -include_directories (${CMAKE_CURRENT_BINARY_DIR}/include) -include_directories (${CMAKE_CURRENT_BINARY_DIR}/private_include) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/private_include) # Add the lib sources. file(GLOB JANSSON_SRC src/*.c) set(JANSSON_HDR_PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/src/hashtable.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson_private.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/strbuffer.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/utf.h - ${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h) + ${CMAKE_CURRENT_SOURCE_DIR}/src/hashtable.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson_private.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/strbuffer.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/utf.h + ${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h) -set(JANSSON_HDR_PUBLIC - ${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h) +set(JANSSON_HDR_PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h) source_group("Library Sources" FILES ${JANSSON_SRC}) source_group("Library Private Headers" FILES ${JANSSON_HDR_PRIVATE}) source_group("Library Public Headers" FILES ${JANSSON_HDR_PUBLIC}) if(JANSSON_BUILD_SHARED_LIBS) - add_library(jansson SHARED - ${JANSSON_SRC} - ${JANSSON_HDR_PRIVATE} - ${JANSSON_HDR_PUBLIC} - src/jansson.def) + add_library(jansson SHARED ${JANSSON_SRC} ${JANSSON_HDR_PRIVATE} + ${JANSSON_HDR_PUBLIC} src/jansson.def) - set_target_properties(jansson PROPERTIES - VERSION ${JANSSON_VERSION} - SOVERSION ${JANSSON_SOVERSION}) + set_target_properties(jansson PROPERTIES VERSION ${JANSSON_VERSION} + SOVERSION ${JANSSON_SOVERSION}) else() - add_library(jansson - ${JANSSON_SRC} - ${JANSSON_HDR_PRIVATE} - ${JANSSON_HDR_PUBLIC}) + add_library(jansson ${JANSSON_SRC} ${JANSSON_HDR_PRIVATE} + ${JANSSON_HDR_PUBLIC}) endif() set_target_properties(jansson PROPERTIES FOLDER "deps") -if (JANSSON_EXAMPLES) - add_executable(simple_parse "${PROJECT_SOURCE_DIR}/examples/simple_parse.c") - target_link_libraries(simple_parse jansson) +if(JANSSON_EXAMPLES) + add_executable(simple_parse "${PROJECT_SOURCE_DIR}/examples/simple_parse.c") + target_link_libraries(simple_parse jansson) endif() -# For building Documentation (uses Sphinx) -# Disabled by OBS +# For building Documentation (uses Sphinx) Disabled by OBS option(JANSSON_BUILD_DOCS "Build documentation (uses python-sphinx)." OFF) -if (JANSSON_BUILD_DOCS) - find_package(Sphinx) +if(JANSSON_BUILD_DOCS) + find_package(Sphinx) - if (NOT SPHINX_FOUND) - message(WARNING "Sphinx not found. Cannot generate documentation! + if(NOT SPHINX_FOUND) + message(WARNING "Sphinx not found. Cannot generate documentation! Set -DJANSSON_BUILD_DOCS=OFF to get rid of this message.") - else() - if (Sphinx_VERSION_STRING VERSION_LESS 1.0) - message(WARNING "Your Sphinx version is too old! + else() + if(Sphinx_VERSION_STRING VERSION_LESS 1.0) + message( + WARNING + "Your Sphinx version is too old! This project requires Sphinx v1.0 or above to produce proper documentation (you have v${Sphinx_VERSION_STRING}). You will get output but it will have errors.") + endif() + + # configured documentation tools and intermediate build results + set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build") + + # Sphinx cache with pickled ReST documents + set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees") + + # CMake could be used to build the conf.py file too, eg it could + # automatically write the version of the program or change the theme. if(NOT + # DEFINED SPHINX_THEME) set(SPHINX_THEME default) endif() + # + # if(NOT DEFINED SPHINX_THEME_DIR) set(SPHINX_THEME_DIR) endif() + # + # configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" + # "${BINARY_BUILD_DIR}/conf.py" @ONLY) + + # TODO: Add support for all sphinx builders: + # http://sphinx-doc.org/builders.html + + # Add documentation targets. + set(DOC_TARGETS html) + + option(JANSSON_BUILD_MAN "Create a target for building man pages." ON) + + if(JANSSON_BUILD_MAN) + if(Sphinx_VERSION_STRING VERSION_LESS 1.0) + message( + WARNING + "Sphinx version 1.0 > is required to build man pages. You have v${Sphinx_VERSION_STRING}." + ) + else() + list(APPEND DOC_TARGETS man) endif() + endif() - # configured documentation tools and intermediate build results - set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build") + option(JANSSON_BUILD_LATEX + "Create a target for building latex docs (to create PDF)." OFF) - # Sphinx cache with pickled ReST documents - set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees") + if(JANSSON_BUILD_LATEX) + find_package(LATEX) - # CMake could be used to build the conf.py file too, - # eg it could automatically write the version of the program or change the theme. - # if(NOT DEFINED SPHINX_THEME) - # set(SPHINX_THEME default) - # endif() - # - # if(NOT DEFINED SPHINX_THEME_DIR) - # set(SPHINX_THEME_DIR) - # endif() - # - # configure_file( - # "${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" - # "${BINARY_BUILD_DIR}/conf.py" - # @ONLY) - - # TODO: Add support for all sphinx builders: http://sphinx-doc.org/builders.html - - # Add documentation targets. - set(DOC_TARGETS html) - - option(JANSSON_BUILD_MAN "Create a target for building man pages." ON) - - if (JANSSON_BUILD_MAN) - if (Sphinx_VERSION_STRING VERSION_LESS 1.0) - message(WARNING "Sphinx version 1.0 > is required to build man pages. You have v${Sphinx_VERSION_STRING}.") - else() - list(APPEND DOC_TARGETS man) - endif() + if(NOT LATEX_COMPILER) + message("Couldn't find Latex, can't build latex docs using Sphinx") + else() + message( + "Latex found! If you have problems building, see Sphinx documentation for required Latex packages." + ) + list(APPEND DOC_TARGETS latex) endif() + endif() - option(JANSSON_BUILD_LATEX "Create a target for building latex docs (to create PDF)." OFF) + # The doc target will build all documentation targets. + add_custom_target(doc) - if (JANSSON_BUILD_LATEX) - find_package(LATEX) + foreach(DOC_TARGET ${DOC_TARGETS}) + add_custom_target( + ${DOC_TARGET} + ${SPHINX_EXECUTABLE} + # -q # Enable for quiet mode + -b + ${DOC_TARGET} + -d + "${SPHINX_CACHE_DIR}" + # -c "${BINARY_BUILD_DIR}" # enable if using cmake-generated conf.py + "${CMAKE_CURRENT_SOURCE_DIR}/doc" + "${CMAKE_CURRENT_BINARY_DIR}/doc/${DOC_TARGET}" + COMMENT "Building ${DOC_TARGET} documentation with Sphinx") - if (NOT LATEX_COMPILER) - message("Couldn't find Latex, can't build latex docs using Sphinx") - else() - message("Latex found! If you have problems building, see Sphinx documentation for required Latex packages.") - list(APPEND DOC_TARGETS latex) - endif() - endif() + add_dependencies(doc ${DOC_TARGET}) + endforeach() - # The doc target will build all documentation targets. - add_custom_target(doc) - - foreach (DOC_TARGET ${DOC_TARGETS}) - add_custom_target(${DOC_TARGET} - ${SPHINX_EXECUTABLE} - # -q # Enable for quiet mode - -b ${DOC_TARGET} - -d "${SPHINX_CACHE_DIR}" - # -c "${BINARY_BUILD_DIR}" # enable if using cmake-generated conf.py - "${CMAKE_CURRENT_SOURCE_DIR}/doc" - "${CMAKE_CURRENT_BINARY_DIR}/doc/${DOC_TARGET}" - COMMENT "Building ${DOC_TARGET} documentation with Sphinx") - - add_dependencies(doc ${DOC_TARGET}) - endforeach() - - message("Building documentation enabled for: ${DOC_TARGETS}") - endif() -endif () + message("Building documentation enabled for: ${DOC_TARGETS}") + endif() +endif() # Disabled by OBS -option(JANSSON_WITHOUT_TESTS "Don't build tests ('make test' to execute tests)" ON) +option(JANSSON_WITHOUT_TESTS "Don't build tests ('make test' to execute tests)" + ON) -if (NOT JANSSON_WITHOUT_TESTS) - option(JANSSON_TEST_WITH_VALGRIND "Enable valgrind tests." OFF) +if(NOT JANSSON_WITHOUT_TESTS) + option(JANSSON_TEST_WITH_VALGRIND "Enable valgrind tests." OFF) - ENABLE_TESTING() + enable_testing() - if (JANSSON_TEST_WITH_VALGRIND) - # TODO: Add FindValgrind.cmake instead of having a hardcoded path. + if(JANSSON_TEST_WITH_VALGRIND) + # TODO: Add FindValgrind.cmake instead of having a hardcoded path. - add_definitions(-DVALGRIND) + add_definitions(-DVALGRIND) - # enable valgrind - set(CMAKE_MEMORYCHECK_COMMAND valgrind) - set(CMAKE_MEMORYCHECK_COMMAND_OPTIONS - "--error-exitcode=1 --leak-check=full --show-reachable=yes --track-origins=yes -q") + # enable valgrind + set(CMAKE_MEMORYCHECK_COMMAND valgrind) + set(CMAKE_MEMORYCHECK_COMMAND_OPTIONS + "--error-exitcode=1 --leak-check=full --show-reachable=yes --track-origins=yes -q" + ) - set(MEMCHECK_COMMAND - "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}") - separate_arguments(MEMCHECK_COMMAND) - endif () + set(MEMCHECK_COMMAND + "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}") + separate_arguments(MEMCHECK_COMMAND) + endif() - # - # Test suites. - # - if (CMAKE_COMPILER_IS_GNUCC) - add_definitions(-Wall -Wextra -Wdeclaration-after-statement) - endif () + # + # Test suites. + # + if(CMAKE_COMPILER_IS_GNUCC) + add_definitions(-Wall -Wextra -Wdeclaration-after-statement) + endif() - set(api_tests - test_array - test_copy - test_dump - test_dump_callback - test_equal - test_load - test_loadb - test_number - test_object - test_pack - test_simple - test_unpack) + set(api_tests + test_array + test_copy + test_dump + test_dump_callback + test_equal + test_load + test_loadb + test_number + test_object + test_pack + test_simple + test_unpack) - # Doing arithmetic on void pointers is not allowed by Microsofts compiler - # such as secure_malloc and secure_free is doing, so exclude it for now. - if (NOT MSVC) - list(APPEND api_tests test_memory_funcs) - endif() + # Doing arithmetic on void pointers is not allowed by Microsofts compiler such + # as secure_malloc and secure_free is doing, so exclude it for now. + if(NOT MSVC) + list(APPEND api_tests test_memory_funcs) + endif() - # Helper macro for building and linking a test program. - macro(build_testprog name dir) - add_executable(${name} ${dir}/${name}.c) - add_dependencies(${name} jansson) - target_link_libraries(${name} jansson) - endmacro(build_testprog) + # Helper macro for building and linking a test program. + macro(build_testprog name dir) + add_executable(${name} ${dir}/${name}.c) + add_dependencies(${name} jansson) + target_link_libraries(${name} jansson) + endmacro(build_testprog) - # Create executables and tests/valgrind tests for API tests. - foreach (test ${api_tests}) - build_testprog(${test} ${PROJECT_SOURCE_DIR}/test/suites/api) + # Create executables and tests/valgrind tests for API tests. + foreach(test ${api_tests}) + build_testprog(${test} ${PROJECT_SOURCE_DIR}/test/suites/api) - if (JANSSON_TEST_WITH_VALGRIND) - add_test(memcheck__${test} - ${MEMCHECK_COMMAND} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test} - WORKING_DIRECTORY ${JANSSON_TEMP_DIR}) - else() - add_test(${test} - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test} - WORKING_DIRECTORY ${JANSSON_TEMP_DIR}) - endif () - endforeach () + if(JANSSON_TEST_WITH_VALGRIND) + add_test(memcheck__${test} ${MEMCHECK_COMMAND} + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test} + WORKING_DIRECTORY ${JANSSON_TEMP_DIR}) + else() + add_test(${test} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test} + WORKING_DIRECTORY ${JANSSON_TEMP_DIR}) + endif() + endforeach() - # Test harness for the suites tests. - build_testprog(json_process ${PROJECT_SOURCE_DIR}/test/bin) + # Test harness for the suites tests. + build_testprog(json_process ${PROJECT_SOURCE_DIR}/test/bin) - set(SUITE_TEST_CMD ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process) - set(SUITES encoding-flags valid invalid invalid-unicode) - foreach (SUITE ${SUITES}) - file(GLOB TESTDIRS ${jansson_SOURCE_DIR}/test/suites/${SUITE}/*) + set(SUITE_TEST_CMD ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process) + set(SUITES encoding-flags valid invalid invalid-unicode) + foreach(SUITE ${SUITES}) + file(GLOB TESTDIRS ${jansson_SOURCE_DIR}/test/suites/${SUITE}/*) - foreach (TESTDIR ${TESTDIRS}) - if (IS_DIRECTORY ${TESTDIR}) - get_filename_component(TNAME ${TESTDIR} NAME) + foreach(TESTDIR ${TESTDIRS}) + if(IS_DIRECTORY ${TESTDIR}) + get_filename_component(TNAME ${TESTDIR} NAME) - if (JANSSON_TEST_WITH_VALGRIND) - add_test(memcheck__${SUITE}__${TNAME} - ${MEMCHECK_COMMAND} ${SUITE_TEST_CMD} ${TESTDIR}) - else() - add_test(${SUITE}__${TNAME} - ${SUITE_TEST_CMD} ${TESTDIR}) - endif() + if(JANSSON_TEST_WITH_VALGRIND) + add_test(memcheck__${SUITE}__${TNAME} ${MEMCHECK_COMMAND} + ${SUITE_TEST_CMD} ${TESTDIR}) + else() + add_test(${SUITE}__${TNAME} ${SUITE_TEST_CMD} ${TESTDIR}) + endif() - if ((${SUITE} STREQUAL "valid" OR ${SUITE} STREQUAL "invalid") AND NOT EXISTS ${TESTDIR}/nostrip) - if (JANSSON_TEST_WITH_VALGRIND) - add_test(memcheck__${SUITE}__${TNAME}__strip - ${MEMCHECK_COMMAND} ${SUITE_TEST_CMD} --strip ${TESTDIR}) - else() - add_test(${SUITE}__${TNAME}__strip - ${SUITE_TEST_CMD} --strip ${TESTDIR}) - endif() - endif () - endif () - endforeach () - endforeach () + if((${SUITE} STREQUAL "valid" OR ${SUITE} STREQUAL "invalid") + AND NOT EXISTS ${TESTDIR}/nostrip) + if(JANSSON_TEST_WITH_VALGRIND) + add_test(memcheck__${SUITE}__${TNAME}__strip ${MEMCHECK_COMMAND} + ${SUITE_TEST_CMD} --strip ${TESTDIR}) + else() + add_test(${SUITE}__${TNAME}__strip ${SUITE_TEST_CMD} --strip + ${TESTDIR}) + endif() + endif() + endif() + endforeach() + endforeach() - if (JANSSON_COVERAGE) - setup_target_for_coverage( - coverage # Coverage make target "make coverage". - coverage # Name of output directory. - make # Name of test runner executable. - test) # Arguments to the test runner above (make test). + if(JANSSON_COVERAGE) + setup_target_for_coverage( + coverage # Coverage make target "make coverage". + coverage # Name of output directory. + make # Name of test runner executable. + test) # Arguments to the test runner above (make test). - if (JANSSON_COVERALLS) - set(COVERAGE_SRCS ${JANSSON_SRC}) - coveralls_setup("${COVERAGE_SRCS}" ${JANSSON_COVERALLS_UPLOAD}) - endif () - endif () + if(JANSSON_COVERALLS) + set(COVERAGE_SRCS ${JANSSON_SRC}) + coveralls_setup("${COVERAGE_SRCS}" ${JANSSON_COVERALLS_UPLOAD}) + endif() + endif() - # Enable using "make check" just like the autotools project. - # By default cmake creates a target "make test" - add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} - DEPENDS json_process ${api_tests}) -endif () + # Enable using "make check" just like the autotools project. By default cmake + # creates a target "make test" + add_custom_target( + check + COMMAND ${CMAKE_CTEST_COMMAND} + DEPENDS json_process ${api_tests}) +endif() # # Installation preparation. # # Allow the user to override installation directories. -set(JANSSON_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") -set(JANSSON_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") -set(JANSSON_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") +set(JANSSON_INSTALL_LIB_DIR + lib + CACHE PATH "Installation directory for libraries") +set(JANSSON_INSTALL_BIN_DIR + bin + CACHE PATH "Installation directory for executables") +set(JANSSON_INSTALL_INCLUDE_DIR + include + CACHE PATH "Installation directory for header files") if(WIN32 AND NOT CYGWIN) set(DEF_INSTALL_CMAKE_DIR cmake) @@ -599,96 +605,101 @@ else() set(DEF_INSTALL_CMAKE_DIR lib/cmake/jansson) endif() -set(JANSSON_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") +set(JANSSON_INSTALL_CMAKE_DIR + ${DEF_INSTALL_CMAKE_DIR} + CACHE PATH "Installation directory for CMake files") -# Create pkg-conf file. -# (We use the same files as ./configure does, so we -# have to defined the same variables used there). -set(prefix ${CMAKE_INSTALL_PREFIX}) +# Create pkg-conf file. (We use the same files as ./configure does, so we have +# to defined the same variables used there). +set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX}) -set(libdir ${CMAKE_INSTALL_PREFIX}/${JANSSON_INSTALL_LIB_DIR}) -set(VERSION ${JANSSON_DISPLAY_VERSION}) +set(libdir ${CMAKE_INSTALL_PREFIX}/${JANSSON_INSTALL_LIB_DIR}) +set(VERSION ${JANSSON_DISPLAY_VERSION}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jansson.pc.in ${CMAKE_CURRENT_BINARY_DIR}/jansson.pc @ONLY) # Make sure the paths are absolute. foreach(p LIB BIN INCLUDE CMAKE) - set(var JANSSON_INSTALL_${p}_DIR) - if(NOT IS_ABSOLUTE "${${var}}") - set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") - endif() + set(var JANSSON_INSTALL_${p}_DIR) + if(NOT IS_ABSOLUTE "${${var}}") + set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif() endforeach() -# Export targets (This is used for other CMake projects to easily find the libraries and include files). -export(TARGETS jansson - FILE "${PROJECT_BINARY_DIR}/JanssonTargets.cmake") +# Export targets (This is used for other CMake projects to easily find the +# libraries and include files). +export(TARGETS jansson FILE "${PROJECT_BINARY_DIR}/JanssonTargets.cmake") export(PACKAGE jansson) # Generate the config file for the build-tree. -set(JANSSON__INCLUDE_DIRS - "${PROJECT_SOURCE_DIR}/include" - "${PROJECT_BINARY_DIR}/include") -set(JANSSON_INCLUDE_DIRS ${JANSSON__INCLUDE_DIRS} CACHE PATH "Jansson include directories") +set(JANSSON__INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_BINARY_DIR}/include") +set(JANSSON_INCLUDE_DIRS + ${JANSSON__INCLUDE_DIRS} + CACHE PATH "Jansson include directories") configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in - ${PROJECT_BINARY_DIR}/JanssonConfig.cmake - @ONLY) + ${PROJECT_BINARY_DIR}/JanssonConfig.cmake @ONLY) # Generate the config file for the installation tree. -file(RELATIVE_PATH - REL_INCLUDE_DIR - "${JANSSON_INSTALL_CMAKE_DIR}" - "${JANSSON_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the Cmake dir. +file(RELATIVE_PATH REL_INCLUDE_DIR "${JANSSON_INSTALL_CMAKE_DIR}" + "${JANSSON_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from + # the Cmake dir. -# Note the EVENT_CMAKE_DIR is defined in JanssonConfig.cmake.in, -# we escape it here so it's evaluated when it is included instead -# so that the include dirs are given relative to where the -# config file is located. -set(JANSSON__INCLUDE_DIRS - "\${JANSSON_CMAKE_DIR}/${REL_INCLUDE_DIR}") -configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in - ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/JanssonConfig.cmake - @ONLY) +# Note the EVENT_CMAKE_DIR is defined in JanssonConfig.cmake.in, we escape it +# here so it's evaluated when it is included instead so that the include dirs +# are given relative to where the config file is located. +set(JANSSON__INCLUDE_DIRS "\${JANSSON_CMAKE_DIR}/${REL_INCLUDE_DIR}") +configure_file( + ${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in + ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/JanssonConfig.cmake @ONLY) # Generate version info for both build-tree and install-tree. configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfigVersion.cmake.in - ${PROJECT_BINARY_DIR}/JanssonConfigVersion.cmake - @ONLY) + ${PROJECT_BINARY_DIR}/JanssonConfigVersion.cmake @ONLY) # Define the public headers. set_target_properties(jansson PROPERTIES PUBLIC_HEADER "${JANSSON_HDR_PUBLIC}") -#TODO: fix this. +# TODO: fix this. # # Install targets. # # Disabled by OBS option(JANSSON_INSTALL "Generate installation target" OFF) -if (JANSSON_INSTALL) -install(TARGETS jansson - EXPORT JanssonTargets - LIBRARY DESTINATION "${JANSSON_INSTALL_LIB_DIR}" COMPONENT lib - ARCHIVE DESTINATION "${JANSSON_INSTALL_LIB_DIR}" COMPONENT lib - RUNTIME DESTINATION "${JANSSON_INSTALL_BIN_DIR}" COMPONENT lib # Windows DLLs - PUBLIC_HEADER DESTINATION "${JANSSON_INSTALL_INCLUDE_DIR}" COMPONENT dev) +if(JANSSON_INSTALL) + install( + TARGETS jansson + EXPORT JanssonTargets + LIBRARY DESTINATION "${JANSSON_INSTALL_LIB_DIR}" COMPONENT lib + ARCHIVE DESTINATION "${JANSSON_INSTALL_LIB_DIR}" COMPONENT lib + RUNTIME DESTINATION "${JANSSON_INSTALL_BIN_DIR}" COMPONENT lib # Windows + # DLLs + PUBLIC_HEADER DESTINATION "${JANSSON_INSTALL_INCLUDE_DIR}" COMPONENT dev) -# Install the pkg-config. -install (FILES - ${CMAKE_CURRENT_BINARY_DIR}/jansson.pc - DESTINATION ${JANSSON_INSTALL_LIB_DIR}/pkgconfig COMPONENT dev) + # Install the pkg-config. + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/jansson.pc + DESTINATION ${JANSSON_INSTALL_LIB_DIR}/pkgconfig + COMPONENT dev) -# Install the configs. -install(FILES - ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/JanssonConfig.cmake - ${PROJECT_BINARY_DIR}/JanssonConfigVersion.cmake - DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev) + # Install the configs. + install( + FILES ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/JanssonConfig.cmake + ${PROJECT_BINARY_DIR}/JanssonConfigVersion.cmake + DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" + COMPONENT dev) -# Install exports for the install-tree. -install(EXPORT JanssonTargets - DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev) + # Install exports for the install-tree. + install( + EXPORT JanssonTargets + DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" + COMPONENT dev) endif() # For use when simply using add_library from a parent project to build jansson. -set(JANSSON_LIBRARIES jansson CACHE STRING "Jansson libraries") +set(JANSSON_LIBRARIES + jansson + CACHE STRING "Jansson libraries") -target_include_directories(jansson - PUBLIC src "${CMAKE_CURRENT_BINARY_DIR}/include") +target_include_directories(jansson PUBLIC src + "${CMAKE_CURRENT_BINARY_DIR}/include") diff --git a/deps/libcaption/CMakeLists.txt b/deps/libcaption/CMakeLists.txt index 0dd474cee..97d1c8a17 100644 --- a/deps/libcaption/CMakeLists.txt +++ b/deps/libcaption/CMakeLists.txt @@ -1,41 +1,40 @@ -cmake_minimum_required(VERSION 2.8.12) project(libcaption) -add_definitions(-D__STDC_CONSTANT_MACROS) -if (WIN32) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) -endif() -if (UNIX AND NOT APPLE) - add_compile_options("-fPIC") -endif() +add_library(caption STATIC) +add_library(OBS::caption ALIAS caption) -# Don't need to prefix local includes with "caption/*" -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/caption) +target_sources( + caption + PRIVATE src/caption.c + src/utf8.c + caption/utf8.h + src/srt.c + src/scc.c + caption/scc.h + src/mpeg.c + caption/mpeg.h + src/cea708.c + caption/cea708.h + src/xds.c + src/eia608.c + caption/eia608.h + src/eia608_from_utf8.c + src/eia608_charmap.c + caption/eia608_charmap.h + PUBLIC caption/caption.h) -set(CAPTION_SOURCES - src/utf8.c - src/srt.c - src/scc.c - src/mpeg.c - src/cea708.c - src/xds.c - src/caption.c - src/eia608_charmap.c - src/eia608_from_utf8.c - src/eia608.c -) +target_compile_definitions( + caption PRIVATE __STDC_CONSTANT_MACROS + "$<$:_CRT_SECURE_NO_WARNINGS>") -set(CAPTION_HEADERS - caption/utf8.h - caption/scc.h - caption/mpeg.h - caption/cea708.h - caption/eia608.h - caption/caption.h - caption/eia608_charmap.h -) +target_include_directories( + caption + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/caption + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -add_library(caption STATIC ${CAPTION_SOURCES}) -set_target_properties(caption PROPERTIES - FOLDER "deps" - POSITION_INDEPENDENT_CODE ON) +set_target_properties( + caption + PROPERTIES FOLDER "deps" + VERSION "0" + SOVERSION "0" + POSITION_INDEPENDENT_CODE ON) diff --git a/deps/libff/CMakeLists.txt b/deps/libff/CMakeLists.txt index 3ff4baa23..6425075e6 100644 --- a/deps/libff/CMakeLists.txt +++ b/deps/libff/CMakeLists.txt @@ -1,61 +1,57 @@ -cmake_minimum_required (VERSION 2.8.12) -project (libff) +cmake_minimum_required(VERSION 2.8.12) +project(libff) -find_package(FFmpeg REQUIRED - COMPONENTS avcodec avfilter avdevice avutil swscale avformat swresample) +find_package( + FFmpeg REQUIRED + COMPONENTS avcodec + avfilter + avdevice + avutil + swscale + avformat + swresample) include_directories(${FFMPEG_INCLUDE_DIRS}) if(WIN32 AND NOT MINGW) - include_directories(../w32-pthreads) - add_definitions(-Dinline=__inline) + include_directories(../w32-pthreads) + add_definitions(-Dinline=__inline) endif(WIN32 AND NOT MINGW) set(libff_HEADERS - libff/ff-callbacks.h - libff/ff-circular-queue.h - libff/ff-clock.h - libff/ff-frame.h - libff/ff-packet-queue.h - libff/ff-threading.h - libff/ff-timer.h - libff/ff-util.h - # - libff/ff-demuxer.h - # - libff/ff-decoder.h) + libff/ff-callbacks.h + libff/ff-circular-queue.h + libff/ff-clock.h + libff/ff-frame.h + libff/ff-packet-queue.h + libff/ff-threading.h + libff/ff-timer.h + libff/ff-util.h + libff/ff-demuxer.h + libff/ff-decoder.h) set(libff_SOURCES - libff/ff-callbacks.c - libff/ff-circular-queue.c - libff/ff-clock.c - libff/ff-packet-queue.c - libff/ff-timer.c - libff/ff-util.c - # - libff/ff-demuxer.c - # - libff/ff-decoder.c - libff/ff-audio-decoder.c - libff/ff-video-decoder.c) + libff/ff-callbacks.c + libff/ff-circular-queue.c + libff/ff-clock.c + libff/ff-packet-queue.c + libff/ff-timer.c + libff/ff-util.c + libff/ff-demuxer.c + libff/ff-decoder.c + libff/ff-audio-decoder.c + libff/ff-video-decoder.c) -if (WIN32) - list(APPEND libff_SOURCES - libff/ff-threading-windows.c) +if(WIN32) + list(APPEND libff_SOURCES libff/ff-threading-windows.c) else(WIN32) - list(APPEND libff_SOURCES - libff/ff-threading-posix.c) + list(APPEND libff_SOURCES libff/ff-threading-posix.c) endif(WIN32) -add_library (libff STATIC - ${libff_HEADERS} - ${libff_SOURCES}) -set_target_properties(libff PROPERTIES - FOLDER "deps" - POSITION_INDEPENDENT_CODE ON) +add_library(libff STATIC ${libff_HEADERS} ${libff_SOURCES}) +set_target_properties(libff PROPERTIES FOLDER "deps" POSITION_INDEPENDENT_CODE + ON) -target_include_directories(libff - PUBLIC .) +target_include_directories(libff PUBLIC .) -target_link_libraries (libff - ${FFMPEG_LIBRARIES}) +target_link_libraries(libff ${FFMPEG_LIBRARIES}) diff --git a/deps/lzma/CMakeLists.txt b/deps/lzma/CMakeLists.txt index 6e64d3f06..87b433379 100644 --- a/deps/lzma/CMakeLists.txt +++ b/deps/lzma/CMakeLists.txt @@ -1,148 +1,112 @@ -cmake_minimum_required(VERSION 3.2) - project(lzma) -set(LIBLZMA_INCLUDE_DIRS - "${CMAKE_CURRENT_SOURCE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/liblzma/api" - CACHE PATH "lzma include path") +add_library(lzma STATIC) +add_library(OBS::lzma ALIAS lzma) -set(LIBLZMA_CONFIG - "${CMAKE_CURRENT_SOURCE_DIR}/config.h" - CACHE PATH "lzma config.h path") +target_sources(lzma PRIVATE config.h) -include_directories( - ${LIBLZMA_INCLUDE_DIRS} - common - liblzma/api - liblzma/check - liblzma/common - liblzma/delta - liblzma/lz - liblzma/lzma - liblzma/rangecoder - liblzma/simple -) +target_sources( + lzma + PRIVATE liblzma/check/check.c liblzma/check/crc32_table.c + liblzma/check/crc32_fast.c liblzma/check/crc64_table.c + liblzma/check/crc64_fast.c liblzma/check/sha256.c) -add_definitions( - -DHAVE_CONFIG_H - -DTUKLIB_SYMBOL_PREFIX=lzma_) +target_sources( + lzma + PRIVATE liblzma/common/common.c + liblzma/common/block_util.c + liblzma/common/easy_preset.c + liblzma/common/filter_common.c + liblzma/common/hardware_physmem.c + liblzma/common/index.c + liblzma/common/stream_flags_common.c + liblzma/common/vli_size.c + liblzma/common/alone_encoder.c + liblzma/common/block_buffer_encoder.c + liblzma/common/block_encoder.c + liblzma/common/block_header_encoder.c + liblzma/common/easy_buffer_encoder.c + liblzma/common/easy_encoder.c + liblzma/common/easy_encoder_memusage.c + liblzma/common/filter_buffer_encoder.c + liblzma/common/filter_encoder.c + liblzma/common/filter_flags_encoder.c + liblzma/common/index_encoder.c + liblzma/common/stream_buffer_encoder.c + liblzma/common/stream_encoder.c + liblzma/common/stream_flags_encoder.c + liblzma/common/vli_encoder.c + liblzma/common/alone_decoder.c + liblzma/common/auto_decoder.c + liblzma/common/block_buffer_decoder.c + liblzma/common/block_decoder.c + liblzma/common/block_header_decoder.c + liblzma/common/easy_decoder_memusage.c + liblzma/common/filter_buffer_decoder.c + liblzma/common/filter_decoder.c + liblzma/common/filter_flags_decoder.c + liblzma/common/index_decoder.c + liblzma/common/index_hash.c + liblzma/common/stream_buffer_decoder.c + liblzma/common/stream_decoder.c + liblzma/common/stream_flags_decoder.c + liblzma/common/vli_decoder.c) -if(WIN32) - if(MSVC) - add_compile_options($,/MTd,/MT> /Zl) - add_compile_options("/wd4244") - add_compile_options("/wd4267") - endif() - add_definitions( - -Dinline=_inline - -Drestrict=__restrict) +target_sources( + lzma PRIVATE liblzma/delta/delta_common.c liblzma/delta/delta_encoder.c + liblzma/delta/delta_decoder.c) + +target_sources( + lzma + PRIVATE liblzma/lzma/lzma_encoder.c + liblzma/lzma/lzma_encoder_presets.c + liblzma/lzma/lzma_encoder_optimum_fast.c + liblzma/lzma/lzma_encoder_optimum_normal.c + liblzma/lzma/fastpos_table.c + liblzma/lzma/lzma_decoder.c + liblzma/lzma/lzma2_encoder.c + liblzma/lzma/lzma2_decoder.c) + +target_sources(lzma PRIVATE liblzma/lz/lz_encoder.c liblzma/lz/lz_encoder_mf.c + liblzma/lz/lz_decoder.c) + +target_sources(lzma PRIVATE liblzma/rangecoder/price_table.c) + +target_sources( + lzma + PRIVATE liblzma/simple/simple_coder.c + liblzma/simple/simple_encoder.c + liblzma/simple/simple_decoder.c + liblzma/simple/arm.c + liblzma/simple/armthumb.c + liblzma/simple/ia64.c + liblzma/simple/powerpc.c + liblzma/simple/sparc.c + liblzma/simple/x86.c) + +target_compile_definitions(lzma PRIVATE HAVE_CONFIG_H + TUKLIB_SYMBOL_PREFIX=lzma_) + +target_include_directories( + lzma + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/common + ${CMAKE_CURRENT_SOURCE_DIR}/liblzma/check + ${CMAKE_CURRENT_SOURCE_DIR}/liblzma/common + ${CMAKE_CURRENT_SOURCE_DIR}/liblzma/delta + ${CMAKE_CURRENT_SOURCE_DIR}/liblzma/lz + ${CMAKE_CURRENT_SOURCE_DIR}/liblzma/lzma + ${CMAKE_CURRENT_SOURCE_DIR}/liblzma/rangecoder + ${CMAKE_CURRENT_SOURCE_DIR}/liblzma/simple + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/liblzma/api) + +if(OS_WINDOWS) + if(MSVC) + target_compile_options(lzma PRIVATE "$,/MTd,/MT>" /Zl + /wd4244 /wd4267) + endif() + + target_compile_definitions(lzma PRIVATE inline=_inline restrict=__restrict) endif() -set(liblzma_check_SOURCES - liblzma/check/check.c) - -list(APPEND liblzma_check_SOURCES - liblzma/check/crc32_table.c - liblzma/check/crc32_fast.c - liblzma/check/crc64_table.c - liblzma/check/crc64_fast.c - liblzma/check/sha256.c) - -set(liblzma_common_SOURCES - liblzma/common/common.c - liblzma/common/block_util.c - liblzma/common/easy_preset.c - liblzma/common/filter_common.c - liblzma/common/hardware_physmem.c - liblzma/common/index.c - liblzma/common/stream_flags_common.c - liblzma/common/vli_size.c - liblzma/common/alone_encoder.c - liblzma/common/block_buffer_encoder.c - liblzma/common/block_encoder.c - liblzma/common/block_header_encoder.c - liblzma/common/easy_buffer_encoder.c - liblzma/common/easy_encoder.c - liblzma/common/easy_encoder_memusage.c - liblzma/common/filter_buffer_encoder.c - liblzma/common/filter_encoder.c - liblzma/common/filter_flags_encoder.c - liblzma/common/index_encoder.c - liblzma/common/stream_buffer_encoder.c - liblzma/common/stream_encoder.c - liblzma/common/stream_flags_encoder.c - liblzma/common/vli_encoder.c - liblzma/common/alone_decoder.c - liblzma/common/auto_decoder.c - liblzma/common/block_buffer_decoder.c - liblzma/common/block_decoder.c - liblzma/common/block_header_decoder.c - liblzma/common/easy_decoder_memusage.c - liblzma/common/filter_buffer_decoder.c - liblzma/common/filter_decoder.c - liblzma/common/filter_flags_decoder.c - liblzma/common/index_decoder.c - liblzma/common/index_hash.c - liblzma/common/stream_buffer_decoder.c - liblzma/common/stream_decoder.c - liblzma/common/stream_flags_decoder.c - liblzma/common/vli_decoder.c) - -set(liblzma_delta_SOURCES - liblzma/delta/delta_common.c - liblzma/delta/delta_encoder.c - liblzma/delta/delta_decoder.c) - -set(liblzma_lzma_SOURCES - liblzma/lzma/lzma_encoder.c - liblzma/lzma/lzma_encoder_presets.c - liblzma/lzma/lzma_encoder_optimum_fast.c - liblzma/lzma/lzma_encoder_optimum_normal.c - liblzma/lzma/fastpos_table.c - liblzma/lzma/lzma_decoder.c - - liblzma/lzma/lzma2_encoder.c - liblzma/lzma/lzma2_decoder.c) - -set(liblzma_lz_SOURCES - liblzma/lz/lz_encoder.c - liblzma/lz/lz_encoder_mf.c - liblzma/lz/lz_decoder.c) - -set(liblzma_rangecoder_SOURCES - liblzma/rangecoder/price_table.c) - -set(liblzma_simple_SOURCES - liblzma/simple/simple_coder.c - liblzma/simple/simple_encoder.c - liblzma/simple/simple_decoder.c - - liblzma/simple/arm.c - liblzma/simple/armthumb.c - liblzma/simple/ia64.c - liblzma/simple/powerpc.c - liblzma/simple/sparc.c - liblzma/simple/x86.c) - -if (WIN32) - SET_SOURCE_FILES_PROPERTIES( - ${liblzma_check_SOURCES} - ${liblzma_common_SOURCES} - ${liblzma_delta_SOURCES} - ${liblzma_lz_SOURCES} - ${liblzma_lzma_SOURCES} - ${liblzma_rangecoder_SOURCES} - ${liblzma_simple_SOURCES} - PROPERTIES LANGUAGE C) -endif() - -add_library(lzma STATIC - ${liblzma_check_SOURCES} - ${liblzma_common_SOURCES} - ${liblzma_delta_SOURCES} - ${liblzma_lz_SOURCES} - ${liblzma_lzma_SOURCES} - ${liblzma_rangecoder_SOURCES} - ${liblzma_simple_SOURCES}) set_target_properties(lzma PROPERTIES FOLDER "deps") diff --git a/deps/media-playback/CMakeLists.txt b/deps/media-playback/CMakeLists.txt index 621c17a79..e97d3004c 100644 --- a/deps/media-playback/CMakeLists.txt +++ b/deps/media-playback/CMakeLists.txt @@ -1,39 +1,23 @@ project(media-playback) -find_package(FFmpeg REQUIRED - COMPONENTS avcodec avdevice avutil avformat) +option(ENABLE_SIMDE "Enable non-native SSE2 SIMD support" ON) -include_directories( - ${CMAKE_SOURCE_DIR}/libobs - ${FFMPEG_INCLUDE_DIRS} - ) +find_package(FFmpeg REQUIRED COMPONENTS avcodec avdevice avutil avformat) -set(media-playback_HEADERS - media-playback/closest-format.h - media-playback/decode.h - media-playback/media.h - ) -set(media-playback_SOURCES - media-playback/decode.c - media-playback/media.c - ) +add_library(media-playback INTERFACE) +add_library(OBS::media-playback ALIAS media-playback) -add_library(media-playback STATIC - ${media-playback_HEADERS} - ${media-playback_SOURCES} - ) +target_sources( + media-playback + INTERFACE media-playback/media.c media-playback/media.h + media-playback/decode.c media-playback/decode.h + media-playback/closest-format.h) -target_compile_options(media-playback - PUBLIC - ${ARCH_SIMD_FLAGS}) +target_link_libraries(media-playback INTERFACE FFmpeg::avcodec FFmpeg::avdevice + FFmpeg::avutil FFmpeg::avformat) -target_include_directories(media-playback - PUBLIC . - ) +target_include_directories(media-playback INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(media-playback - ${FFMPEG_LIBRARIES} - ) -set_target_properties(media-playback PROPERTIES - FOLDER "deps" - POSITION_INDEPENDENT_CODE ON) +target_compile_options(media-playback INTERFACE ${ARCH_SIMD_FLAGS}) + +target_compile_definitions(media-playback INTERFACE ${ARCH_SIMD_DEFINES}) diff --git a/deps/opts-parser/CMakeLists.txt b/deps/opts-parser/CMakeLists.txt index 27e9a4c30..92d36332a 100644 --- a/deps/opts-parser/CMakeLists.txt +++ b/deps/opts-parser/CMakeLists.txt @@ -1,17 +1,10 @@ project(opts-parser) -set(opts-parser_SOURCES - opts-parser.c) -set(opts-parser_HEADERS - opts-parser.h) +add_library(opts-parser INTERFACE) +add_library(OBS::opts-parser ALIAS opts-parser) -add_library(opts-parser STATIC - ${opts-parser_SOURCES} - ${opts-parser_HEADERS}) -target_include_directories(opts-parser - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(opts-parser - libobs) -set_target_properties(opts-parser PROPERTIES - FOLDER "deps" - POSITION_INDEPENDENT_CODE ON) +target_sources(opts-parser INTERFACE opts-parser.c opts-parser.h) + +target_link_libraries(opts-parser INTERFACE OBS::libobs) + +target_include_directories(opts-parser INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/deps/w32-pthreads/CMakeLists.txt b/deps/w32-pthreads/CMakeLists.txt index e8b5cdab7..ed32281af 100644 --- a/deps/w32-pthreads/CMakeLists.txt +++ b/deps/w32-pthreads/CMakeLists.txt @@ -1,30 +1,25 @@ -project(w32-pthreads) - -if(NOT WIN32) - return() +if(POLICY CMP0090) + cmake_policy(SET CMP0090 NEW) endif() +project(w32-pthreads) + +add_library(w32-pthreads SHARED) +add_library(OBS::w32-pthreads ALIAS w32-pthreads) + +target_sources(w32-pthreads PRIVATE implement.h pthread.c pthread.h sched.h + semaphore.h w32-pthreads.rc) + set(MODULE_DESCRIPTION "POSIX Threads for Windows") -configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in w32-pthreads.rc) -set(w32-pthreads_SOURCES - pthread.c - w32-pthreads.rc) +configure_file(${CMAKE_SOURCE_DIR}/cmake/bundle/windows/obs-module.rc.in + w32-pthreads.rc) -set(w32-pthreads_HEADERS - implement.h - pthread.h - sched.h - semaphore.h) +target_compile_definitions(w32-pthreads PRIVATE __CLEANUP_C PTW32_BUILD) + +target_include_directories( + w32-pthreads PUBLIC "$") -add_library(w32-pthreads SHARED - ${w32-pthreads_SOURCES} - ${w32-pthreads_HEADERS}) -target_compile_definitions(w32-pthreads - PRIVATE __CLEANUP_C PTW32_BUILD) -target_include_directories(w32-pthreads - PUBLIC - "$") -target_link_libraries(w32-pthreads) set_target_properties(w32-pthreads PROPERTIES FOLDER "deps") -install_obs_core(w32-pthreads EXPORT w32-pthreads) +setup_binary_target(w32-pthreads) +export_target(w32-pthreads) diff --git a/deps/w32-pthreads/cmake/w32-pthreadsConfig.cmake.in b/deps/w32-pthreads/cmake/w32-pthreadsConfig.cmake.in new file mode 100644 index 000000000..40afeeefe --- /dev/null +++ b/deps/w32-pthreads/cmake/w32-pthreadsConfig.cmake.in @@ -0,0 +1,6 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") +check_required_components("@PROJECT_NAME@") + +set(LIBOBS_LIBRARIES w32-pthreads)