cmake: Massive update ported from obs-amd-encoder

This includes support for included, referenced, packaged and downloaded obs-studio libraries, cppcheck, packaging using cpack, 7z, zip or InnoSetup and more.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2018-09-26 01:17:08 +02:00
parent 9e58f4a4f7
commit dc0104850a
5 changed files with 855 additions and 207 deletions

View file

@ -1,149 +1,200 @@
cmake_minimum_required(VERSION 3.2) # Experimental new Sources, Filters and Transitions for OBS Studio
PROJECT(obs-stream-effects VERSION 0.4.2.0) # Copyright (C) 2017 - 2018 Michael Fabian Dirks
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# CMake Setup
CMake_Minimum_Required(VERSION 3.1.0)
Include("cmake/util.cmake")
Include("cmake/DownloadProject.cmake")
Include("cmake/cppcheck.cmake")
# Automatic Versioning
Set(VERSION_MAJOR 0)
Set(VERSION_MINOR 4)
Set(VERSION_PATCH 2)
Set(VERSION_TWEAK 0)
Set(PROJECT_COMMIT "N/A")
If(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
Set(GIT_RESULT "")
Set(GIT_OUTPUT "")
EXECUTE_PROCESS(
COMMAND git rev-list --count --topo-order ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}..HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE GIT_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)
If(GIT_RESULT EQUAL 0)
Set(VERSION_TWEAK ${GIT_OUTPUT})
EndIf()
EXECUTE_PROCESS(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE GIT_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)
If(GIT_RESULT EQUAL 0)
Set(PROJECT_COMMIT ${GIT_OUTPUT})
EndIf()
EndIf()
# Define Project
PROJECT(
obs-stream-effects
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}
DESCRIPTION ""
HOMEPAGE_URL "about:blank"
)
################################################################################ ################################################################################
# CMake Setup # CMake / Compiler
################################################################################ ################################################################################
# Detect Build Type
If("${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
Set(PropertyPrefix "")
Else()
Set(PropertyPrefix "${PROJECT_NAME}_")
EndIf()
# Detect Architecture
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
IF("${BITS}" STREQUAL "32")
SET(ARCH "x86")
Else()
SET(ARCH "x64")
ENDIF()
# Configure Installer script
Configure_File(
"${PROJECT_SOURCE_DIR}/ci/installer.iss.in"
"${PROJECT_BINARY_DIR}/ci/installer.iss"
)
# Configure Version Header
Configure_File(
"${PROJECT_SOURCE_DIR}/source/version.h.in"
"${PROJECT_BINARY_DIR}/source/version.h"
)
# Windows Specific Resource Definition
If(WIN32)
Set(PROJECT_PRODUCT_NAME "OBS Studio Stream Effects")
Set(PROJECT_COMPANY_NAME "Xaymar")
Set(PROJECT_COPYRIGHT "Xaymar © 2017 - 2018")
Set(PROJECT_LEGAL_TRADEMARKS_1 "")
Set(PROJECT_LEGAL_TRADEMARKS_2 "")
Set(PROJECT_DESCRIPTION "Stream Effects for OBS Studio")
Configure_File(
"${PROJECT_SOURCE_DIR}/cmake/version.rc.in"
"${PROJECT_BINARY_DIR}/cmake/version.rc"
@ONLY
)
EndIf()
# All Warnings, Extra Warnings, Pedantic
If(MSVC)
# Force to always compile with W4
If(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
String(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
Else()
Set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
EndIf()
ElseIf(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update If necessary
Set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
EndIf()
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}") math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
# Modules ################################################################################
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") # Options
include(ExternalProject) ################################################################################
include(DownloadProject) Set(${PropertyPrefix}OBS_NATIVE FALSE CACHE BOOL "Use native obs-studio build" FORCE)
Set(${PropertyPrefix}OBS_REFERENCE FALSE CACHE BOOL "Use referenced obs-studio build" FORCE)
Set(${PropertyPrefix}OBS_PACKAGE FALSE CACHE BOOL "Use packaged obs-studio build" FORCE)
Set(${PropertyPrefix}OBS_DOWNLOAD FALSE CACHE BOOL "Use downloaded obs-studio build" FORCE)
MARK_AS_ADVANCED(FORCE OBS_NATIVE OBS_PACKAGE OBS_REFERENCE OBS_DOWNLOAD)
If(NOT TARGET libobs)
Set(${PropertyPrefix}OBS_STUDIO_DIR "" CACHE PATH "OBS Studio Source/Package Directory")
Set(${PropertyPrefix}OBS_DOWNLOAD_VERSION "22.0.2" CACHE STRING "OBS Studio Version to download")
EndIf()
If(NOT ${PropertyPrefix}OBS_NATIVE)
Set(CMAKE_PACKAGE_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Path for generated archives.")
Set(CMAKE_PACKAGE_NAME "${PROJECT_NAME}" CACHE STRING "Name for the generated archives.")
Set(CMAKE_PACKAGE_SUFFIX_OVERRIDE "" CACHE STRING "Override for the suffix.")
EndIf()
################################################################################ ################################################################################
# Dependencies # Dependencies
################################################################################ ################################################################################
# OBS Studio / libOBS # Detect OBS Studio Type
IF(NOT TARGET libobs) If(TARGET libobs)
SET(LIBOBS_EXISTS FALSE) Message(STATUS "${PROJECT_NAME}: Using native obs-studio.")
SET(LIBOBS_CUSTOM FALSE CACHE BOOL "Use custom libOBS") CacheSet(${PropertyPrefix}OBS_NATIVE TRUE)
IF(NOT LIBOBS_CUSTOM) Else()
IF(WIN32) CacheSet(${PropertyPrefix}OBS_NATIVE FALSE)
IF (${BITS} STREQUAL "64") IF(EXISTS "${OBS_STUDIO_DIR}/cmake/LibObs/LibObsConfig.cmake")
SET(LIBOBS_URL "https://ci.appveyor.com/api/buildjobs/jp18y3sc5icoq8qs/artifacts/build%2Fobs-studio-x64-vs2017-x64.7z" CACHE STRING "URL to libobs Cpack") Message(STATUS "${PROJECT_NAME}: Using packaged obs-studio.")
ELSE() CacheSet(${PropertyPrefix}OBS_PACKAGE TRUE)
SET(LIBOBS_URL "https://ci.appveyor.com/api/buildjobs/nj276esfv3ho0j49/artifacts/build%2Fobs-studio-x86-vs2017-x86.7z" CACHE STRING "URL to libobs Cpack") ElseIf(EXISTS "${OBS_STUDIO_DIR}/libobs/obs-module.h")
ENDIF() Message(STATUS "${PROJECT_NAME}: Using referenced obs-studio.")
ELSEIF(UNIX AND NOT APPLE) CacheSet(${PropertyPrefix}OBS_REFERENCE TRUE)
IF (${BITS} STREQUAL "64") Else()
SET(LIBOBS_URL "" CACHE STRING "URL to libobs Cpack") Message(STATUS "${PROJECT_NAME}: No OBS Studio detected, using downloadable prebuilt binaries.")
ELSE() CacheSet(${PropertyPrefix}OBS_DOWNLOAD TRUE)
SET(LIBOBS_URL "" CACHE STRING "URL to libobs Cpack") Set(${PropertyPrefix}OBS_DOWNLOAD_URL "https://github.com/Xaymar/obs-studio/releases/download/${OBS_DOWNLOAD_VERSION}/obs-studio-${ARCH}-vs2017.7z")
ENDIF() EndIf()
ELSEIF(APPLE) EndIf()
IF (${BITS} STREQUAL "64")
SET(LIBOBS_URL "" CACHE STRING "URL to libobs Cpack")
ELSE()
SET(LIBOBS_URL "" CACHE STRING "URL to libobs Cpack")
ENDIF()
ENDIF()
# OBS Studio (CPack Release)
download_project(
PROJ libobs
URL "${LIBOBS_URL}"
UPDATE_DISCONNECTED 1
)
INCLUDE("${libobs_SOURCE_DIR}/cmake/LibObs/LibObsConfig.cmake")
ELSE()
SET(LIBOBS_PATH "" CACHE STRING "Path to libOBS")
ENDIF()
ELSE()
SET(LIBOBS_EXISTS TRUE)
ENDIF()
################################################################################ If(${PropertyPrefix}OBS_NATIVE)
# Version Option(BUILD_AMD_ENCODER "Build AMD Encoder module" ON)
################################################################################ If (NOT BUILD_AMD_ENCODER)
Message(STATUS "Not building AMD Encoder")
# Retrieve Tweak version from git. Return()
if(EXISTS "${PROJECT_SOURCE_DIR}/.git") EndIf()
SET(GIT_RESULT "") ElseIf(${PropertyPrefix}OBS_PACKAGE)
SET(GIT_OUTPUT "") Include("${OBS_STUDIO_DIR}/cmake/LibObs/LibObsConfig.cmake")
EXECUTE_PROCESS( ElseIf(${PropertyPrefix}OBS_REFERENCE)
COMMAND git rev-list --count --topo-order ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}..HEAD Set(obsPath "${OBS_STUDIO_DIR}")
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} Include("${OBS_STUDIO_DIR}/cmake/external/Findlibobs.cmake")
RESULT_VARIABLE GIT_RESULT ElseIf(${PropertyPrefix}OBS_DOWNLOAD)
OUTPUT_VARIABLE GIT_OUTPUT download_project(
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ERROR_QUIET PROJ libobs
URL ${OBS_DOWNLOAD_URL}
UPDATE_DISCONNECTED 1
) )
IF(GIT_RESULT EQUAL 0) INCLUDE("${libobs_SOURCE_DIR}/cmake/LibObs/LibObsConfig.cmake")
SET(PROJECT_VERSION_TWEAK ${GIT_OUTPUT}) Else()
ENDIF() Message(CRITICAL "Impossible case reached, very system stability.")
endif() Return()
EndIf()
SET(VERSION_MAJOR PROJECT_VERSION_MAJOR)
SET(VERSION_MINOR PROJECT_VERSION_MINOR)
SET(VERSION_PATCH PROJECT_VERSION_PATCH)
SET(VERSION_TWEAK PROJECT_VERSION_TWEAK)
SET(VERSION_STR "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}")
configure_file(
"${PROJECT_SOURCE_DIR}/source/version.h.in"
"${PROJECT_BINARY_DIR}/source/version.h"
)
################################################################################ ################################################################################
# Code # Code
################################################################################ ################################################################################
SET(obs-stream-effects_HEADERS SET(PROJECT_DATA_LOCALE
"${PROJECT_SOURCE_DIR}/source/plugin.h"
"${PROJECT_SOURCE_DIR}/source/filter-displacement.h"
"${PROJECT_SOURCE_DIR}/source/filter-blur.h"
"${PROJECT_SOURCE_DIR}/source/filter-shape.h"
"${PROJECT_SOURCE_DIR}/source/filter-transform.h"
"${PROJECT_SOURCE_DIR}/source/filter-custom-shader.h"
"${PROJECT_SOURCE_DIR}/source/source-mirror.h"
"${PROJECT_SOURCE_DIR}/source/gfx-effect-source.h"
"${PROJECT_SOURCE_DIR}/source/gfx-source-texture.h"
"${PROJECT_SOURCE_DIR}/source/gs-helper.h"
"${PROJECT_SOURCE_DIR}/source/gs-effect.h"
"${PROJECT_SOURCE_DIR}/source/gs-indexbuffer.h"
"${PROJECT_SOURCE_DIR}/source/gs-limits.h"
# "${PROJECT_SOURCE_DIR}/source/gs-mipmapper.h"
"${PROJECT_SOURCE_DIR}/source/gs-rendertarget.h"
"${PROJECT_SOURCE_DIR}/source/gs-sampler.h"
"${PROJECT_SOURCE_DIR}/source/gs-texture.h"
"${PROJECT_SOURCE_DIR}/source/gs-vertex.h"
"${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.h"
"${PROJECT_SOURCE_DIR}/source/obs-audio-capture.h"
"${PROJECT_BINARY_DIR}/source/version.h"
"${PROJECT_SOURCE_DIR}/source/strings.h"
"${PROJECT_SOURCE_DIR}/source/utility.h"
"${PROJECT_SOURCE_DIR}/source/util-math.h"
"${PROJECT_SOURCE_DIR}/source/util-memory.h"
)
SET(obs-stream-effects_SOURCES
"${PROJECT_SOURCE_DIR}/source/plugin.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-displacement.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-blur.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-shape.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-transform.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-custom-shader.cpp"
"${PROJECT_SOURCE_DIR}/source/source-mirror.cpp"
"${PROJECT_SOURCE_DIR}/source/gfx-effect-source.cpp"
"${PROJECT_SOURCE_DIR}/source/gfx-source-texture.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-helper.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-effect.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-indexbuffer.cpp"
# "${PROJECT_SOURCE_DIR}/source/gs-mipmapper.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-rendertarget.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-sampler.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-texture.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-vertex.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.cpp"
"${PROJECT_SOURCE_DIR}/source/obs-audio-capture.cpp"
"${PROJECT_SOURCE_DIR}/source/utility.cpp"
"${PROJECT_SOURCE_DIR}/source/util-math.cpp"
"${PROJECT_SOURCE_DIR}/source/util-memory.cpp"
)
SET(obs-stream-effects_LOCALE
"${PROJECT_SOURCE_DIR}/data/locale/en-US.ini" "${PROJECT_SOURCE_DIR}/data/locale/en-US.ini"
) )
SET(obs-stream-effects_EFFECTS SET(PROJECT_DATA_EFFECTS
"${PROJECT_SOURCE_DIR}/data/effects/bilateral-blur.effect" "${PROJECT_SOURCE_DIR}/data/effects/bilateral-blur.effect"
"${PROJECT_SOURCE_DIR}/data/effects/box-blur.effect" "${PROJECT_SOURCE_DIR}/data/effects/box-blur.effect"
"${PROJECT_SOURCE_DIR}/data/effects/gaussian-blur.effect" "${PROJECT_SOURCE_DIR}/data/effects/gaussian-blur.effect"
@ -151,100 +202,275 @@ SET(obs-stream-effects_EFFECTS
"${PROJECT_SOURCE_DIR}/data/effects/color-conversion.effect" "${PROJECT_SOURCE_DIR}/data/effects/color-conversion.effect"
"${PROJECT_SOURCE_DIR}/data/effects/mip-mapper.effect" "${PROJECT_SOURCE_DIR}/data/effects/mip-mapper.effect"
) )
SET(obs-stream-effects_SHADERS SET(PROJECT_DATA_SHADERS
# "${PROJECT_SOURCE_DIR}/data/shaders/name.effect" # "${PROJECT_SOURCE_DIR}/data/shaders/name.effect"
) )
SET(obs-stream-effects_SHADERS_FILTER SET(PROJECT_DATA_SHADERS_FILTER
"${PROJECT_SOURCE_DIR}/data/shaders/filter/example.effect" "${PROJECT_SOURCE_DIR}/data/shaders/filter/example.effect"
) )
SET(obs-stream-effects_LIBRARIES SET(PROJECT_LIBRARIES
) )
#set_property(GLOBAL PROPERTY USE_FOLDERS ON) SET(PROJECT_PUBLIC
source_group("Data Files\\Locale" FILES ${obs-stream-effects_LOCALE}) )
source_group("Data Files\\Effects" FILES ${obs-stream-effects_EFFECTS}) SET(PROJECT_PRIVATE
source_group("Data Files\\Shaders" FILES ${obs-stream-effects_SHADERS}) ${PROJECT_DATA_LOCALE}
source_group("Data Files\\Shaders\\Filter" FILES ${obs-stream-effects_SHADERS_FILTER}) ${PROJECT_DATA_EFFECTS}
${PROJECT_DATA_SHADERS}
${PROJECT_DATA_SHADERS_FILTER}
"${PROJECT_SOURCE_DIR}/source/plugin.h"
"${PROJECT_SOURCE_DIR}/source/plugin.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-displacement.h"
"${PROJECT_SOURCE_DIR}/source/filter-displacement.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-blur.h"
"${PROJECT_SOURCE_DIR}/source/filter-blur.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-shape.h"
"${PROJECT_SOURCE_DIR}/source/filter-shape.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-transform.h"
"${PROJECT_SOURCE_DIR}/source/filter-transform.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-custom-shader.h"
"${PROJECT_SOURCE_DIR}/source/filter-custom-shader.cpp"
"${PROJECT_SOURCE_DIR}/source/source-mirror.h"
"${PROJECT_SOURCE_DIR}/source/source-mirror.cpp"
"${PROJECT_SOURCE_DIR}/source/gfx-effect-source.h"
"${PROJECT_SOURCE_DIR}/source/gfx-effect-source.cpp"
"${PROJECT_SOURCE_DIR}/source/gfx-source-texture.h"
"${PROJECT_SOURCE_DIR}/source/gfx-source-texture.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-helper.h"
"${PROJECT_SOURCE_DIR}/source/gs-helper.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-effect.h"
"${PROJECT_SOURCE_DIR}/source/gs-effect.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-indexbuffer.h"
"${PROJECT_SOURCE_DIR}/source/gs-indexbuffer.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-limits.h"
# "${PROJECT_SOURCE_DIR}/source/gs-mipmapper.h"
"${PROJECT_SOURCE_DIR}/source/gs-rendertarget.h"
"${PROJECT_SOURCE_DIR}/source/gs-rendertarget.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-sampler.h"
"${PROJECT_SOURCE_DIR}/source/gs-sampler.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-texture.h"
"${PROJECT_SOURCE_DIR}/source/gs-texture.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-vertex.h"
"${PROJECT_SOURCE_DIR}/source/gs-vertex.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.h"
"${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.cpp"
"${PROJECT_SOURCE_DIR}/source/obs-audio-capture.h"
"${PROJECT_SOURCE_DIR}/source/obs-audio-capture.cpp"
"${PROJECT_BINARY_DIR}/source/version.h"
"${PROJECT_SOURCE_DIR}/source/strings.h"
"${PROJECT_SOURCE_DIR}/source/utility.h"
"${PROJECT_SOURCE_DIR}/source/utility.cpp"
"${PROJECT_SOURCE_DIR}/source/util-math.h"
"${PROJECT_SOURCE_DIR}/source/util-math.cpp"
"${PROJECT_SOURCE_DIR}/source/util-memory.h"
"${PROJECT_SOURCE_DIR}/source/util-memory.cpp"
# "${PROJECT_SOURCE_DIR}/source/gs-mipmapper.cpp"
)
Source_Group("Data Files\\Locale" FILES ${PROJECT_DATA_LOCALE})
Source_Group("Data Files\\Effects" FILES ${PROJECT_DATA_EFFECTS})
Source_Group("Data Files\\Shaders" FILES ${PROJECT_DATA_SHADERS})
Source_Group("Data Files\\Shaders\\Filter" FILES ${PROJECT_DATA_SHADERS_FILTER})
################################################################################ ################################################################################
# Standalone and OBS Studio Build Data # Target
################################################################################ ################################################################################
if(LIBOBS_EXISTS) Add_Library(${PROJECT_NAME} MODULE
# OBS Studio Specific ${PROJECT_PUBLIC}
INCLUDE_DIRECTORIES( ${PROJECT_PRIVATE}
)
# Include Directories
Target_Include_Directories(${PROJECT_NAME}
PUBLIC
"${PROJECT_BINARY_DIR}/source"
"${PROJECT_SOURCE_DIR}/source"
PRIVATE
"${PROJECT_BINARY_DIR}/source"
"${PROJECT_SOURCE_DIR}/source"
"${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}"
"${PROJECT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/source"
"${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/source"
)
SET(LIBOBS_LIBRARIES libobs)
else()
# Compiling
INCLUDE_DIRECTORIES(
"${PROJECT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/source"
"${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/source"
${LIBOBS_INCLUDE_DIRS}
)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
# All Warnings, Extra Warnings, Pedantic
if(MSVC)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
endif()
################################################################################
# Build
################################################################################
ADD_LIBRARY(obs-stream-effects MODULE
${obs-stream-effects_HEADERS}
${obs-stream-effects_SOURCES}
${obs-stream-effects_LOCALE}
${obs-stream-effects_EFFECTS}
${obs-stream-effects_SHADERS}
${obs-stream-effects_SHADERS_FILTER}
)
TARGET_LINK_LIBRARIES(obs-stream-effects
${LIBOBS_LIBRARIES}
${obs-stream-effects_LIBRARIES}
) )
if(LIBOBS_EXISTS) # OBS Studio
install_obs_plugin_with_data(obs-stream-effects data) If(${PropertyPrefix}OBS_NATIVE)
else() Target_Link_Libraries(${PROJECT_NAME}
# Install libobs
INSTALL( )
TARGETS obs-stream-effects ElseIf(${PropertyPrefix}OBS_REFERENCE)
RUNTIME DESTINATION "obs-plugins/${BITS}bit" COMPONENT Runtime Target_Include_Directories(${PROJECT_NAME}
LIBRARY DESTINATION "obs-plugins/${BITS}bit" COMPONENT Runtime PRIVATE
"${OBS_STUDIO_DIR}/libobs"
)
Target_Link_Libraries(${PROJECT_NAME}
"${LIBOBS_LIB}"
)
ElseIf(${PropertyPrefix}OBS_PACKAGE)
Target_Include_Directories(${PROJECT_NAME}
PRIVATE
"${OBS_STUDIO_DIR}/include"
)
Target_Link_Libraries(${PROJECT_NAME}
libobs
)
ElseIf(${PropertyPrefix}OBS_DOWNLOAD)
Target_Link_Libraries(${PROJECT_NAME}
libobs
)
EndIf()
# Link Libraries
TARGET_LINK_LIBRARIES(${PROJECT_NAME}
"${PROJECT_LIBRARIES}"
)
# Definitions
If (WIN32)
Target_Compile_Definitions(${PROJECT_NAME}
PRIVATE
_CRT_SECURE_NO_WARNINGS
# windows.h
WIN32_LEAN_AND_MEAN
NOGPICAPMASKS
NOVIRTUALKEYCODES
NOWINMESSAGES
NOWINSTYLES
NOSYSMETRICS
NOMENUS
NOICONS
NOKEYSTATES
NOSYSCOMMANDS
NORASTEROPS
NOSHOWWINDOW
NOATOM
NOCLIPBOARD
NOCOLOR
NOCTLMGR
NODRAWTEXT
NOGDI
NOKERNEL
NOUSER
NONLS
NOMB
NOMEMMGR
NOMETAFILE
NOMINMAX
NOMSG
NOOPENFILE
NOSCROLL
NOSERVICE
NOSOUND
NOTEXTMETRIC
NOWH
NOWINOFFSETS
NOCOMM
NOKANJI
NOHELP
NOPROFILER
NODEFERWINDOWPOS
NOMCX
NOIME
NOMDI
NOINOUT
)
EndIf()
# File Version
If(WIN32)
Set_Target_Properties(
${PROJECT_NAME}
PROPERTIES
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}
)
Else()
Set_Target_Properties(
${PROJECT_NAME}
PROPERTIES
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}
)
EndIf()
# CPPCheck
If(NOT ${PropertyPrefix}OBS_NATIVE)
SET(excludes )
If(${PropertyPrefix}OBS_REFERENCE)
LIST(APPEND excludes "${OBS_STUDIO_DIR}/libobs")
ElseIf(${PropertyPrefix}OBS_PACKAGE)
LIST(APPEND excludes "${OBS_STUDIO_DIR}/libobs")
ElseIf(${PropertyPrefix}OBS_DOWNLOAD)
LIST(APPEND excludes "${libobs_SOURCE_DIR}")
EndIf()
CppCheck(
EXCLUDE ${excludes}
)
CppCheck_Add_Project(${PROJECT_NAME})
EndIf()
################################################################################
# Installation
################################################################################
If(${PropertyPrefix}OBS_NATIVE)
install_obs_plugin_with_data(${PROJECT_NAME} data)
Else()
Install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION "./obs-plugins/${BITS}bit/" COMPONENT Runtime
LIBRARY DESTINATION "./obs-plugins/${BITS}bit/" COMPONENT Runtime
)
If(MSVC)
Install(
FILES $<TARGET_PDB_FILE:${PROJECT_NAME}>
DESTINATION "./obs-plugins/${BITS}bit/"
OPTIONAL
)
EndIf()
Install(
DIRECTORY "${PROJECT_SOURCE_DIR}/data/"
DESTINATION "./data/obs-plugins/${PROJECT_NAME}/"
)
# Packaging
If("${CMAKE_PACKAGE_SUFFIX_OVERRIDE}" STREQUAL "")
Set(PackageFullName "${CMAKE_PACKAGE_PREFIX}/${CMAKE_PACKAGE_NAME}-${PROJECT_VERSION}")
Else()
Set(PackageFullName "${CMAKE_PACKAGE_PREFIX}/${CMAKE_PACKAGE_NAME}-${CMAKE_PACKAGE_SUFFIX_OVERRIDE}")
EndIf()
Add_Custom_Target(
PACKAGE_7Z
${CMAKE_COMMAND} -E tar cfv "${PackageFullName}.7z" --format=7zip --
"${CMAKE_INSTALL_PREFIX}/obs-plugins"
"${CMAKE_INSTALL_PREFIX}/data"
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
)
Add_Custom_Target(
PACKAGE_ZIP
${CMAKE_COMMAND} -E tar cfv "${PackageFullName}.zip" --format=zip --
"${CMAKE_INSTALL_PREFIX}/obs-plugins"
"${CMAKE_INSTALL_PREFIX}/data"
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
) )
IF(MSVC)
INSTALL(FILES $<TARGET_PDB_FILE:obs-stream-effects> DESTINATION "obs-plugins/${BITS}bit" OPTIONAL)
ENDIF()
INSTALL(DIRECTORY "${PROJECT_SOURCE_DIR}/data/" DESTINATION "data/obs-plugins/obs-stream-effects" OPTIONAL)
# CPack # CPack
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) Set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
SET(CPACK_PACKAGE_VENDOR "Xaymar") Set(CPACK_PACKAGE_VENDOR "Xaymar")
Set(CPACK_PACKAGE_HOMEPAGE_URL "https://xaymar.com/")
SET(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) Set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) Set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) Set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
SET(CPACK_PACKAGE_VERSION_TWEAK ${PROJECT_VERSION_TWEAK}) Set(CPACK_PACKAGE_VERSION_TWEAK ${PROJECT_VERSION_TWEAK})
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${CPACK_PACKAGE_VERSION_TWEAK}") Set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${CPACK_PACKAGE_VERSION_TWEAK}")
Set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
Set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}-source")
Set(CPACK_PACKAGE_CHECKSUM SHA512)
Set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE)
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}-source")
SET(CPACK_PACKAGE_CHECKSUM SHA512)
include(CPack) include(CPack)
endif() EndIf()

114
ci/installer.iss.in Normal file
View file

@ -0,0 +1,114 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Stream Effects for OBS Studio"
#define MyAppVersion "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@"
#define MyAppPublisher "Xaymars Technology Workshop"
#define MyAppURL "http://www.xaymar.com/portfolio/plugin-amd-vce-plugin-for-obs-studio/"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={6559B77C-0F41-4F97-AC9D-2C13DE22D236}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={code:GetDirName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile="@PROJECT_SOURCE_DIR@/LICENSE"
OutputDir="@CMAKE_INSTALL_PREFIX@/../"
OutputBaseFilename=obs-stream-effects-{#MyAppVersion}
Compression=lzma
SolidCompression=yes
VersionInfoVersion={#MyAppVersion}
VersionInfoCompany={#MyAppPublisher}
VersionInfoDescription={#MyAppName} Setup
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "@CMAKE_INSTALL_PREFIX@/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
[Code]
function GetDirName(Value: string): string;
var
InstallPath: string;
begin
// initialize default path, which will be returned when the following registry
// key queries fail due to missing keys or for some different reason
Result := '{pf}\obs-studio';
// query the first registry value; if this succeeds, return the obtained value
if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then
Result := InstallPath
end;
/////////////////////////////////////////////////////////////////////
function GetUninstallString(): String;
var
sUnInstPath: String;
sUnInstallString: String;
begin
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
Result := sUnInstallString;
end;
/////////////////////////////////////////////////////////////////////
function IsUpgrade(): Boolean;
begin
Result := (GetUninstallString() <> '');
end;
/////////////////////////////////////////////////////////////////////
function UnInstallOldVersion(): Integer;
var
sUnInstallString: String;
iResultCode: Integer;
begin
// Return Values:
// 1 - uninstall string is empty
// 2 - error executing the UnInstallString
// 3 - successfully executed the UnInstallString
// default return value
Result := 0;
// get the uninstall string of the old app
sUnInstallString := GetUninstallString();
if sUnInstallString <> '' then begin
sUnInstallString := RemoveQuotes(sUnInstallString);
if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
Result := 3
else
Result := 2;
end else
Result := 1;
end;
/////////////////////////////////////////////////////////////////////
procedure CurStepChanged(CurStep: TSetupStep);
begin
if (CurStep=ssInstall) then
begin
if (IsUpgrade()) then
begin
UnInstallOldVersion();
end;
end;
end;

234
cmake/cppcheck.cmake Normal file
View file

@ -0,0 +1,234 @@
set(CPPCHECK_PROJECTS "")
set(CPPCHECK_ARGUMENTS "")
set(CPPCHECK_PLATFORM "")
set(CPPCHECK_LIBRARIES "")
include(CMakeParseArguments)
function(cppcheck)
set(CPPCHECK_PATH "" CACHE PATH "Path to cppcheck binary")
set(CPPCHECK_BIN "cppcheck.exe" CACHE STRING "CPPCheck Binary File")
set(CPPCHECK_ENABLE_INCONCLUSIVE OFF CACHE BOOL "Enable inconclusive checks?")
set(CPPCHECK_ENABLE_MISSING_INCLUDE ON CACHE BOOL "Check for missing includes?")
set(CPPCHECK_ENABLE_UNUSED_FUNCTION OFF CACHE BOOL "Check for unused functions?")
set(CPPCHECK_ENABLE_INFORMATION ON CACHE BOOL "Enable information messages?")
set(CPPCHECK_ENABLE_PORTABILITY ON CACHE BOOL "Enable portability messages?")
set(CPPCHECK_ENABLE_PERFORMANCE ON CACHE BOOL "Enable performance messages?")
set(CPPCHECK_ENABLE_WARNING ON CACHE BOOL "Enable warning messages?")
set(CPPCHECK_STD_POSIX OFF CACHE BOOL "POSIX Standard Compatibility Checks")
set(CPPCHECK_STD_C89 OFF CACHE BOOL "C89 Standard Compatibility Checks")
set(CPPCHECK_STD_C99 OFF CACHE BOOL "C99 Standard Compatibility Checks")
set(CPPCHECK_STD_C11 ON CACHE BOOL "C11 Standard Compatibility Checks")
set(CPPCHECK_STD_CPP03 OFF CACHE BOOL "C++03 Standard Compatibility Checks")
set(CPPCHECK_STD_CPP11 OFF CACHE BOOL "C++11 Standard Compatibility Checks")
set(CPPCHECK_STD_CPP14 ON CACHE BOOL "C++14 Standard Compatibility Checks")
set(CPPCHECK_FORCE_C OFF CACHE BOOL "Force checking with C language")
set(CPPCHECK_FORCE_CPP OFF CACHE BOOL "Force checking with C++ language (overrides CPPCHECK_FORCE_C)")
set(CPPCHECK_VERBOSE ON CACHE BOOL "Show more detailed error reports")
set(CPPCHECK_QUIET ON CACHE BOOL "Hide progress reports")
set(CPPCHECK_LIBRARIES "" CACHE STRING "List of Libraries to load separated by semicolon")
set(CPPCHECK_EXCLUDE_DIRECTORIES "" CACHE STRING "List of directories to exclude separated by semicolon")
set(CPPCHECK_PARALLEL_TASKS "4" CACHE STRING "Number of threads to use for cppcheck")
if(WIN32)
set(CPPCHECK_WIN32_UNICODE ON CACHE BOOL "Use Unicode character encoding for Win32")
endif()
mark_as_advanced(CPPCHECK_BIN CPPCHECK_QUIET CPPCHECK_VERBOSE CPPCHECK_LIBRARIES CPPCHECK_ENABLE_INCONCLUSIVE CPPCHECK_PARALLEL_TASKS)
# Parse arguments
set(cppcheck_options )
set(cppcheck_oneval )
set(cppcheck_mulval EXCLUDE)
cmake_parse_arguments(
CPPCHECKP
"${cppcheck_options}"
"${cppcheck_oneval}"
"${cppcheck_mulval}"
${ARGN}
)
# Detect Architecture (Bitness)
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
# Detect Platform
if(WIN32)
if(BITS EQUAL "32")
if(CPPCHECK_WIN32_UNICODE)
set(CPPCHECK_PLATFORM "win32W")
else()
set(CPPCHECK_PLATFORM "win32A")
endif()
else()
set(CPPCHECK_PLATFORM "win64")
endif()
elseif(("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") OR ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") OR APPLE)
if(BITS EQUAL "32")
set(CPPCHECK_PLATFORM "unix32")
else()
set(CPPCHECK_PLATFORM "unix64")
endif()
else()
set(CPPCHECK_PLATFORM "unspecified")
endif()
if(WIN32)
list(APPEND CPPCHECK_LIBRARIES "windows")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
list(APPEND CPPCHECK_LIBRARIES "bsd")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
list(APPEND CPPCHECK_LIBRARIES "gnu")
endif()
# Arguments
set(CPPCHECK_ARGUMENTS "")
# Compiler
if(MSVC)
#list(APPEND CPPCHECK_ARGUMENTS --template="{file}|{line}|{severity}|{id}|{message}")
endif()
# Flags
if(CPPCHECK_ENABLE_INCONCLUSIVE)
list(APPEND CPPCHECK_ARGUMENTS --inconclusive)
endif()
if(CPPCHECK_VERBOSE)
list(APPEND CPPCHECK_ARGUMENTS -v)
endif()
if(CPPCHECK_QUIET)
list(APPEND CPPCHECK_ARGUMENTS -q)
endif()
if(CPPCHECK_PLATFORM)
list(APPEND CPPCHECK_ARGUMENTS --platform=${CPPCHECK_PLATFORM})
endif()
if(CPPCHECK_PARALLEL_TASKS)
list(APPEND CPPCHECK_ARGUMENTS -j ${CPPCHECK_PARALLEL_TASKS})
endif()
# Libraries
foreach(_library ${CPPCHECK_LIBRARIES})
list(APPEND CPPCHECK_ARGUMENTS --library=${_library})
endforeach()
# Exclusion
foreach(_path ${CPPCHECK_EXCLUDE_DIRECTORIES})
file(TO_NATIVE_PATH "${_path}" _npath)
if(MSVC)
list(APPEND CPPCHECK_ARGUMENTS --suppress=*:${_npath}\\*)
else()
list(APPEND CPPCHECK_ARGUMENTS -i${_npath})
endif()
endforeach()
if(CPPCHECKP_EXCLUDE)
foreach(_path ${CPPCHECKP_EXCLUDE})
file(TO_NATIVE_PATH "${_path}" _npath)
if(MSVC)
list(APPEND CPPCHECK_ARGUMENTS --suppress=*:${_npath}\\*)
else()
list(APPEND CPPCHECK_ARGUMENTS -i${_npath})
endif()
endforeach()
endif()
# Checks
if(CPPCHECK_ENABLE_MISSING_INCLUDE)
list(APPEND CPPCHECK_ARGUMENTS --enable=missingInclude)
endif()
if(CPPCHECK_ENABLE_UNUSED_FUNCTION)
list(APPEND CPPCHECK_ARGUMENTS --enable=unusedFunction)
endif()
if(CPPCHECK_ENABLE_INFORMATION)
list(APPEND CPPCHECK_ARGUMENTS --enable=information)
endif()
if(CPPCHECK_ENABLE_PORTABILITY)
list(APPEND CPPCHECK_ARGUMENTS --enable=portability)
endif()
if(CPPCHECK_ENABLE_PERFORMANCE)
list(APPEND CPPCHECK_ARGUMENTS --enable=performance)
endif()
if(CPPCHECK_ENABLE_WARNING)
list(APPEND CPPCHECK_ARGUMENTS --enable=warning)
endif()
# Std
if(CPPCHECK_STD_POSIX)
list(APPEND CPPCHECK_ARGUMENTS --std=posix)
endif()
if(CPPCHECK_STD_C89)
list(APPEND CPPCHECK_ARGUMENTS --std=c89)
endif()
if(CPPCHECK_STD_C99)
list(APPEND CPPCHECK_ARGUMENTS --std=c99)
endif()
if(CPPCHECK_STD_C11)
list(APPEND CPPCHECK_ARGUMENTS --std=c11)
endif()
if(CPPCHECK_STD_CPP03)
list(APPEND CPPCHECK_ARGUMENTS --std=c++03)
endif()
if(CPPCHECK_STD_CPP11)
list(APPEND CPPCHECK_ARGUMENTS --std=c++11)
endif()
if(CPPCHECK_STD_CPP14)
list(APPEND CPPCHECK_ARGUMENTS --std=c++14)
endif()
# Force Language
if(CPPCHECK_FORCE_CPP)
list(APPEND CPPCHECK_ARGUMENTS --language=c++)
elseif(CPPCHECK_FORCE_C)
list(APPEND CPPCHECK_ARGUMENTS --language=c)
endif()
add_custom_target(
CPPCHECK
)
# Propagate to parent scope
set(CPPCHECK_PROJECTS "${CPPCHECK_PROJECTS}" PARENT_SCOPE)
set(CPPCHECK_ARGUMENTS "${CPPCHECK_ARGUMENTS}" PARENT_SCOPE)
set(CPPCHECK_PLATFORM "${CPPCHECK_PLATFORM}" PARENT_SCOPE)
set(CPPCHECK_LIBRARIES "${CPPCHECK_LIBRARIES}" PARENT_SCOPE)
endfunction()
function(cppcheck_add_project u_project)
list(APPEND CPPCHECK_PROJECTS ${u_project})
# Include Directories
get_target_property(_INCLUDE_DIRECTORIES ${u_project} INCLUDE_DIRECTORIES)
foreach(_path ${_INCLUDE_DIRECTORIES})
file(TO_NATIVE_PATH "${_path}" _npath)
list(APPEND CPPCHECK_ARGUMENTS -I${_npath})
endforeach()
if(MSVC)
add_custom_target(
CPPCHECK_${u_project}
COMMAND "${CPPCHECK_PATH}/${CPPCHECK_BIN}" ${CPPCHECK_ARGUMENTS} --project=${${u_project}_BINARY_DIR}/${u_project}.sln
COMMAND_EXPAND_LISTS
VERBATIM
)
else()
# Non-MSVC and Unix (Linux, FreeBSD, APPLE) need to have -I, -i, -D and -U specified manually.
# Each file can be added to --file-list= as a comma separated list.
# Defines
get_target_property(_COMPILE_DEFINITIONS ${u_project} COMPILE_DEFINITIONS)
foreach(_def ${_COMPILE_DEFINITIONS})
list(APPEND CPPCHECK_ARGUMENTS -D${_def})
endforeach()
# Source Files
get_target_property(_SOURCES ${u_project} SOURCES)
foreach(_path ${_SOURCES})
file(TO_NATIVE_PATH "${_path}" _npath)
list(APPEND CPPCHECK_ARGUMENTS ${_npath})
endforeach()
add_custom_target(
CPPCHECK_${u_project}
COMMAND "${CPPCHECK_PATH}/${CPPCHECK_BIN}" ${CPPCHECK_ARGUMENTS}
COMMAND_EXPAND_LISTS
VERBATIM
)
endif()
add_dependencies(CPPCHECK CPPCHECK_${u_project})
endfunction()

19
cmake/util.cmake Normal file
View file

@ -0,0 +1,19 @@
Function(CacheSet Name Value)
GET_PROPERTY(V_ADVANCED CACHE "${Name}" PROPERTY ADVANCED)
GET_PROPERTY(V_TYPE CACHE "${Name}" PROPERTY TYPE)
GET_PROPERTY(V_HELPSTRING CACHE "${Name}" PROPERTY HELPSTRING)
Set(${Name} ${Value} CACHE ${V_TYPE} ${V_HELPSTRING} FORCE)
If(${V_ADVANCED})
Mark_As_Advanced(FORCE ${Name})
EndIf()
EndFunction()
Function(CacheClear Name)
GET_PROPERTY(V_ADVANCED CACHE "${Name}" PROPERTY ADVANCED)
GET_PROPERTY(V_TYPE CACHE "${Name}" PROPERTY TYPE)
GET_PROPERTY(V_HELPSTRING CACHE "${Name}" PROPERTY HELPSTRING)
Set(${Name} 0 CACHE ${V_TYPE} ${V_HELPSTRING} FORCE)
If(${V_ADVANCED})
Mark_As_Advanced(FORCE ${Name})
EndIf()
EndFunction()

55
cmake/version.rc.in Normal file
View file

@ -0,0 +1,55 @@
#pragma code_page(65001)
#include <windows.h>
#include <winver.h>
#define VER_FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
#define VER_FILEVERSION_STR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@\0"
#define VER_PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
#define VER_PRODUCTVERSION_STR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@\0"
#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS (VER_DEBUG)
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "@PROJECT_COMPANY_NAME@\0"
VALUE "FileDescription", "@PROJECT_DESCRIPTION@\0"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "@PROJECT_NAME@\0"
VALUE "LegalCopyright", "@PROJECT_COPYRIGHT@\0"
VALUE "LegalTrademarks1", "@PROJECT_LEGAL_TRADEMARKS_1@\0"
VALUE "LegalTrademarks2", "@PROJECT_LEGAL_TRADEMARKS_1@\0"
VALUE "OriginalFilename", "@PROJECT_NAME@\0"
VALUE "ProductName", "@PROJECT_PRODUCT_NAME@\0"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
VALUE "Translation", 0x409, 1252
END
END