mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-20 20:23:03 +02:00
CMake presets. (#744)
* CI: use single build action * CMake: use imported targets * CI: do not build boost for linux * CMake: add FORCE_BUNDLED_MINIZIP option * linux: use external minizip and fuzzylite * CMake: add presets * .gitignore: ignore cmake build dirs * github: use cmake presets
This commit is contained in:
parent
a8265c7052
commit
8fc14369a4
80
.github/workflows/github.yml
vendored
80
.github/workflows/github.yml
vendored
@ -8,7 +8,7 @@ on:
|
||||
pull_request:
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -17,22 +17,18 @@ jobs:
|
||||
include:
|
||||
- platform: linux
|
||||
os: ubuntu-20.04
|
||||
cc: clang-10
|
||||
cxx: clang++-10
|
||||
test: 0
|
||||
cmake_args: -G Ninja
|
||||
preset: linux-clang-release
|
||||
- platform: linux
|
||||
os: ubuntu-20.04
|
||||
cc: gcc-9
|
||||
cxx: g++-9
|
||||
test: 0
|
||||
cmake_args: -G Ninja
|
||||
preset: linux-gcc-release
|
||||
- platform: mac
|
||||
os: macos-latest
|
||||
test: 0
|
||||
pack: 1
|
||||
extension: dmg
|
||||
cmake_args: -G Ninja
|
||||
preset: macos-ninja-release
|
||||
- platform: mxe
|
||||
os: ubuntu-20.04
|
||||
mxe: i686-w64-mingw32.shared
|
||||
@ -46,15 +42,14 @@ jobs:
|
||||
test: 0
|
||||
pack: 1
|
||||
extension: exe
|
||||
cmake_args: -G "Visual Studio 17 2022" -A x64 '-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake'
|
||||
|
||||
preset: windows-msvc-release
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@ -63,7 +58,7 @@ jobs:
|
||||
env:
|
||||
MXE_TARGET: ${{ matrix.mxe }}
|
||||
VCMI_BUILD_PLATFORM: x64
|
||||
|
||||
|
||||
- name: Git branch name
|
||||
id: git-branch-name
|
||||
uses: EthanSK/git-branch-name-action@v1
|
||||
@ -77,10 +72,13 @@ jobs:
|
||||
PULL_REQUEST: ${{ github.event.pull_request.number }}
|
||||
|
||||
- name: Configure CMake
|
||||
if: "${{ matrix.preset == '' }}"
|
||||
run: |
|
||||
mkdir '${{github.workspace}}/build'
|
||||
cd '${{github.workspace}}/build'
|
||||
cmake ${{matrix.cmake_args}} .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
|
||||
mkdir -p '${{github.workspace}}/out/build/${{matrix.preset}}'
|
||||
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
|
||||
cmake \
|
||||
../.. -GNinja \
|
||||
${{matrix.cmake_args}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
|
||||
-DENABLE_TEST=${{matrix.test}} \
|
||||
-DPACKAGE_NAME_SUFFIX:STRING="$VCMI_PACKAGE_NAME_SUFFIX" \
|
||||
-DPACKAGE_FILE_NAME:STRING="$VCMI_PACKAGE_FILE_NAME"
|
||||
@ -88,54 +86,58 @@ jobs:
|
||||
CC: ${{ matrix.cc }}
|
||||
CXX: ${{ matrix.cxx }}
|
||||
|
||||
- name: CMake Preset
|
||||
if: "${{ matrix.preset != '' }}"
|
||||
run: |
|
||||
cmake --preset ${{ matrix.preset }}
|
||||
|
||||
- name: Build
|
||||
if: ${{ matrix.platform != 'msvc' }}
|
||||
if: "${{ matrix.preset == '' }}"
|
||||
run: |
|
||||
cd '${{github.workspace}}/build'
|
||||
ninja
|
||||
|
||||
- name: Build MSVC
|
||||
if: ${{ matrix.platform == 'msvc' }}
|
||||
cmake --build '${{github.workspace}}/out/build/${{matrix.preset}}'
|
||||
|
||||
- name: Build Preset
|
||||
if: "${{ matrix.preset != '' }}"
|
||||
run: |
|
||||
cd '${{github.workspace}}/build'
|
||||
cmake --build . --config ${{env.BUILD_TYPE}}
|
||||
cmake --build --preset ${{matrix.preset}}
|
||||
|
||||
- name: Test
|
||||
if: ${{ matrix.test == 1 }}
|
||||
if: ${{ matrix.test == 1 && matrix.preset != ''}}
|
||||
run: |
|
||||
cd '${{github.workspace}}/build'
|
||||
ctest -C Release -V
|
||||
|
||||
ctest --preset ${{matrix.preset}}
|
||||
|
||||
- name: Pack
|
||||
id: cpack
|
||||
if: ${{ matrix.pack == 1 }}
|
||||
run: |
|
||||
cd '${{github.workspace}}/build'
|
||||
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
|
||||
CPACK_PATH=`which -a cpack | grep -m1 -v -i chocolatey`
|
||||
"$CPACK_PATH" -C Release ${{ matrix.cpack_args }}
|
||||
|
||||
"$CPACK_PATH" -C ${{env.BUILD_TYPE}} ${{ matrix.cpack_args }}
|
||||
rm -rf _CPack_Packages
|
||||
|
||||
- name: Additional logs
|
||||
if: ${{ failure() && steps.cpack.outcome == 'failure' && matrix.platform == 'mxe' }}
|
||||
run: |
|
||||
cat '${{github.workspace}}/build/_CPack_Packages/win32/NSIS/project.nsi'
|
||||
cat '${{github.workspace}}/build/_CPack_Packages/win32/NSIS/NSISOutput.log'
|
||||
|
||||
cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/project.nsi'
|
||||
cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/NSISOutput.log'
|
||||
|
||||
- name: Artifacts
|
||||
if: ${{ matrix.pack == 1 }}
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
|
||||
path: ${{github.workspace}}/build/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
|
||||
|
||||
path: |
|
||||
${{github.workspace}}/**/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
|
||||
|
||||
- name: Upload build
|
||||
if: ${{ matrix.pack == 1 && github.ref == 'refs/heads/develop' && matrix.platform != 'msvc' }}
|
||||
run: |
|
||||
cd '${{github.workspace}}/build'
|
||||
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
|
||||
source '${{github.workspace}}/CI/upload_package.sh'
|
||||
env:
|
||||
DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
|
||||
PACKAGE_EXTENSION: ${{ matrix.extension }}
|
||||
|
||||
|
||||
- uses: act10ns/slack@v1
|
||||
with:
|
||||
status: ${{ job.status }}
|
||||
@ -143,7 +145,7 @@ jobs:
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
if: always()
|
||||
|
||||
|
||||
- name: Trigger Android
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
if: ${{ github.ref == 'refs/heads/develop' && matrix.platform == 'mxe' }}
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,6 +3,9 @@
|
||||
/launcher/vcmilauncher
|
||||
/launcher/vcmilauncher_automoc.cpp
|
||||
|
||||
build/
|
||||
.cache/*
|
||||
out/
|
||||
*.dll
|
||||
*.exe
|
||||
*.depend
|
||||
|
@ -8,32 +8,28 @@ else()
|
||||
option(FORCE_BUNDLED_FL "Force to use FuzzyLite included into VCMI's source tree" OFF)
|
||||
endif()
|
||||
|
||||
if(NOT FORCE_BUNDLED_FL)
|
||||
find_package(FuzzyLite)
|
||||
else()
|
||||
set(FL_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
if(TBB_FOUND AND MSVC)
|
||||
get_target_property(TBB_LIB_LOCATION TBB::tbb LOCATION)
|
||||
get_filename_component(TBB_LIB_FOLDER ${TBB_LIB_LOCATION} PATH)
|
||||
get_filename_component(TBB_DLL ${TBB_LIB_FOLDER}/../bin/tbb.dll ABSOLUTE)
|
||||
message("${TBB_DLL}")
|
||||
install(FILES ${TBB_DLL} DESTINATION ${BIN_DIR})
|
||||
install_vcpkg_imported_tgt(TBB::tbb)
|
||||
endif()
|
||||
|
||||
if(FL_FOUND)
|
||||
if(MSVC)
|
||||
get_filename_component(FL_LIB_FOLDER ${FL_LIBRARIES} PATH)
|
||||
get_filename_component(FL_DLL ${FL_LIB_FOLDER}/../bin/fuzzylite.dll ABSOLUTE)
|
||||
message("${FL_DLL}")
|
||||
install(FILES ${FL_DLL} DESTINATION ${BIN_DIR})
|
||||
endif()
|
||||
|
||||
if(NOT FORCE_BUNDLED_FL)
|
||||
find_package(fuzzylite)
|
||||
else()
|
||||
set(fuzzylite_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
if(TARGET fuzzylite::fuzzylite AND MSVC)
|
||||
install_vcpkg_imported_tgt(fuzzylite::fuzzylite)
|
||||
endif()
|
||||
|
||||
if(NOT fuzzylite_FOUND)
|
||||
set(FL_BUILD_BINARY OFF CACHE BOOL "")
|
||||
set(FL_BUILD_SHARED OFF CACHE BOOL "")
|
||||
set(FL_BUILD_TESTS OFF CACHE BOOL "")
|
||||
add_subdirectory(FuzzyLite/fuzzylite EXCLUDE_FROM_ALL)
|
||||
add_library(fuzzylite::fuzzylite ALIAS fl-static)
|
||||
target_include_directories(fl-static PUBLIC ${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite)
|
||||
endif()
|
||||
|
||||
#######################################
|
||||
|
@ -128,18 +128,9 @@ endif()
|
||||
|
||||
add_library(Nullkiller SHARED ${Nullkiller_SRCS} ${Nullkiller_HEADERS})
|
||||
|
||||
if(FL_FOUND)
|
||||
target_include_directories(Nullkiller PUBLIC ${FL_INCLUDE_DIRS})
|
||||
else()
|
||||
target_include_directories(Nullkiller PUBLIC ${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite)
|
||||
endif()
|
||||
target_include_directories(Nullkiller PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(FL_FOUND)
|
||||
target_link_libraries(Nullkiller PRIVATE ${FL_LIBRARIES} vcmi)
|
||||
else()
|
||||
target_link_libraries(Nullkiller PRIVATE fl-static vcmi)
|
||||
endif()
|
||||
target_link_libraries(Nullkiller PRIVATE vcmi fuzzylite::fuzzylite)
|
||||
|
||||
target_link_libraries(Nullkiller PRIVATE TBB::tbb)
|
||||
|
||||
|
@ -109,18 +109,9 @@ endif()
|
||||
|
||||
add_library(VCAI SHARED ${VCAI_SRCS} ${VCAI_HEADERS})
|
||||
|
||||
if(FL_FOUND)
|
||||
target_include_directories(VCAI PUBLIC ${FL_INCLUDE_DIRS})
|
||||
else()
|
||||
target_include_directories(VCAI PUBLIC ${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite)
|
||||
endif()
|
||||
target_include_directories(VCAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(FL_FOUND)
|
||||
target_link_libraries(VCAI PRIVATE ${FL_LIBRARIES} vcmi)
|
||||
else()
|
||||
target_link_libraries(VCAI PRIVATE fl-static vcmi)
|
||||
endif()
|
||||
target_link_libraries(VCAI PRIVATE vcmi fuzzylite::fuzzylite)
|
||||
|
||||
vcmi_set_output_dir(VCAI "AI")
|
||||
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
# Boost
|
||||
wget -nv https://boostorg.jfrog.io/artifactory/main/release/1.66.0/source/boost_1_66_0.tar.gz
|
||||
tar xfz boost_1_66_0.tar.gz
|
||||
cd boost_1_66_0
|
||||
./bootstrap.sh --with-libraries=program_options,filesystem,system,thread,locale,date_time
|
||||
./b2
|
||||
sudo ./b2 install
|
||||
|
||||
# Dependencies
|
||||
sudo apt-get install libboost-all-dev
|
||||
sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
|
||||
sudo apt-get install qtbase5-dev
|
||||
sudo apt-get install ninja-build zlib1g-dev libavformat-dev libswscale-dev libtbb-dev libluajit-5.1-dev
|
||||
sudo apt-get install ninja-build zlib1g-dev libavformat-dev libswscale-dev libtbb-dev libluajit-5.1-dev
|
||||
# Optional dependencies
|
||||
sudo apt-get install libminizip-dev libfuzzylite-dev
|
||||
|
@ -124,6 +124,14 @@ set (CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
||||
|
||||
#Global fallback mapping
|
||||
# RelWithDebInfo falls back to Release, then MinSizeRel
|
||||
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo Release MinSizeRel "")
|
||||
# MinSizeRel falls back to Release, then RelWithDebInfo
|
||||
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL MinSizeRel Release RelWithDebInfo "")
|
||||
# Release falls back to RelWithDebInfo, then MinSizeRel
|
||||
set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE Release RelWithDebInfo MinSizeRel "")
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_MACOSX_RPATH 0)
|
||||
endif(APPLE)
|
||||
@ -216,39 +224,56 @@ endif()
|
||||
# Finding packages #
|
||||
############################################
|
||||
|
||||
set(FFmpeg_FIND_COMPONENTS AVFORMAT SWSCALE)
|
||||
find_package(Boost 1.48.0 COMPONENTS date_time filesystem locale program_options system thread REQUIRED)
|
||||
find_package(Boost 1.48.0 REQUIRED COMPONENTS date_time filesystem locale program_options system thread)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(FFmpeg REQUIRED)
|
||||
find_package(Minizip)
|
||||
if(MINIZIP_FOUND)
|
||||
add_definitions(-DUSE_SYSTEM_MINIZIP)
|
||||
find_package(ffmpeg REQUIRED COMPONENTS avutil swscale avformat avcodec)
|
||||
option(FORCE_BUNDLED_MINIZIP "Force bundled Minizip library" OFF)
|
||||
if(NOT FORCE_BUNDLED_MINIZIP)
|
||||
find_package(minizip)
|
||||
if(TARGET minizip::minizip)
|
||||
add_definitions(-DUSE_SYSTEM_MINIZIP)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_image REQUIRED)
|
||||
find_package(SDL2_mixer REQUIRED)
|
||||
if(TARGET SDL2_mixer::SDL2_mixer)
|
||||
add_library(SDL2::Mixer ALIAS SDL2_mixer::SDL2_mixer)
|
||||
endif()
|
||||
find_package(SDL2_ttf REQUIRED)
|
||||
if(TARGET SDL2_ttf::SDL2_ttf)
|
||||
add_library(SDL2::TTF ALIAS SDL2_ttf::SDL2_ttf)
|
||||
endif()
|
||||
find_package(TBB REQUIRED)
|
||||
|
||||
if(ENABLE_LAUNCHER)
|
||||
# Widgets finds its own dependencies (QtGui and QtCore).
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Widgets Network REQUIRED)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LUA)
|
||||
find_package(luajit)
|
||||
# MXE paths hardcoded for current dependencies pack - tried and could not make it work another way
|
||||
if((MINGW) AND (${CMAKE_CROSSCOMPILING}) AND (DEFINED MSYS))
|
||||
set(LUA_INCLUDE_DIR "/usr/lib/mxe/usr/i686-w64-mingw32.static/include/luajit-2.0")
|
||||
set(LUA_LIBRARY "/usr/lib/mxe/usr/i686-w64-mingw32.static/lib/libluajit-5.1.a")
|
||||
if((MINGW) AND (${CMAKE_CROSSCOMPILING}) AND (DEFINED MSYS) AND (NOT TARGET luajit::luajit))
|
||||
add_library(luajit::luajit STATIC IMPORTED)
|
||||
set_target_properties(luajit::luajit PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "/usr/lib/mxe/usr/i686-w64-mingw32.static/include/luajit-2.0")
|
||||
set_target_properties(luajit::luajit PROPERTIES
|
||||
IMPORTED_LOCATION "/usr/lib/mxe/usr/i686-w64-mingw32.static/lib/libluajit-5.1.a")
|
||||
endif()
|
||||
find_package(LuaJIT)
|
||||
if(LUAJIT_FOUND)
|
||||
if(TARGET luajit::luajit)
|
||||
message(STATUS "Using LuaJIT provided by system")
|
||||
else()
|
||||
message(STATUS "Cannot find LuaJIT! Fallback to using usual Lua.")
|
||||
find_package(Lua REQUIRED)
|
||||
if(Lua_FOUND)
|
||||
add_library(luajit::luajit UNKNOWN IMPORTED)
|
||||
set_target_properties(luajit::luajit PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}")
|
||||
set_target_properties(luajit::luajit PROPERTIES
|
||||
IMPORTED_LOCATION "${LUA_LIBRARIES}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -318,9 +343,9 @@ endif()
|
||||
if(ENABLE_LUA)
|
||||
add_subdirectory(scripting/lua)
|
||||
endif()
|
||||
if(NOT MINIZIP_FOUND)
|
||||
if(NOT TARGET minizip::minizip)
|
||||
add_subdirectory_with_folder("3rdparty" lib/minizip)
|
||||
set(MINIZIP_LIBRARIES minizip)
|
||||
add_library(minizip::minizip ALIAS minizip)
|
||||
endif()
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(client)
|
||||
@ -371,19 +396,19 @@ if(WIN32)
|
||||
${Qtbin_folder}/Qt5Core${debug_postfix}.dll
|
||||
${Qtbin_folder}/Qt5Gui${debug_postfix}.dll
|
||||
${Qtbin_folder}/Qt5Widgets${debug_postfix}.dll
|
||||
${Qtbin_folder}/Qt5Network${debug_postfix}.dll
|
||||
${Qtbin_folder}/icu*.dll)
|
||||
file(GLOB dep_qwindows
|
||||
${Qtbin_folder}/../plugins/platforms/qwindows${debug_postfix}.dll)
|
||||
endif()
|
||||
|
||||
if (ENABLE_LAUNCHER)
|
||||
file(GLOB dep_files
|
||||
${dep_files}
|
||||
${Qtbin_folder}/Qt5Network${debug_postfix}.dll)
|
||||
get_target_property(integration_type Qt5::QWindowsIntegrationPlugin TYPE)
|
||||
if(NOT(integration_type STREQUAL "INTERFACE_LIBRARY"))
|
||||
get_target_property(integration_loc Qt5::QWindowsIntegrationPlugin LOCATION)
|
||||
install(
|
||||
FILES ${integration_loc}
|
||||
DESTINATION ${BIN_DIR}/platforms
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(FILES ${dep_files} DESTINATION ${BIN_DIR})
|
||||
install(FILES ${dep_qwindows} DESTINATION ${BIN_DIR}/platforms)
|
||||
endif(WIN32)
|
||||
|
||||
#######################################
|
||||
|
135
CMakePresets.json
Normal file
135
CMakePresets.json
Normal file
@ -0,0 +1,135 @@
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default-release",
|
||||
"hidden": true,
|
||||
"binaryDir": "${sourceDir}/out/build/${presetName}",
|
||||
"generator": "Ninja",
|
||||
"cacheVariables": {
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
|
||||
"PACKAGE_FILE_NAME" : "$env{VCMI_PACKAGE_FILE_NAME}",
|
||||
"PACKAGE_NAME_SUFFIX" : "$env{VCMI_PACKAGE_NAME_SUFFIX}",
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
|
||||
"FORCE_BUNDLED_FL" : "0",
|
||||
"ENABLE_TEST": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-release",
|
||||
"displayName": "Clang x86_64-pc-linux-gnu",
|
||||
"description": "VCMI Linux Clang",
|
||||
"inherits": "default-release",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "/usr/bin/clang",
|
||||
"CMAKE_CXX_COMPILER": "/usr/bin/clang++"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-release",
|
||||
"displayName": "GCC x86_64-pc-linux-gnu",
|
||||
"description": "VCMI Linux GCC",
|
||||
"inherits": "default-release",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "/usr/bin/gcc",
|
||||
"CMAKE_CXX_COMPILER": "/usr/bin/g++"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-release",
|
||||
"displayName": "Windows x64 RelWithDebInfo",
|
||||
"description": "VCMI RelWithDebInfo build",
|
||||
"inherits": "default-release",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"architecture": {
|
||||
"value": "x64",
|
||||
"strategy": "set"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
|
||||
"CMAKE_POLICY_DEFAULT_CMP0091": "NEW",
|
||||
"FORCE_BUNDLED_MINIZIP": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-ninja-release",
|
||||
"displayName": "Ninja release",
|
||||
"description": "VCMI MacOS Ninja",
|
||||
"inherits": "default-release"
|
||||
},
|
||||
{
|
||||
"name": "macos-xcode-release",
|
||||
"displayName": "XCode release",
|
||||
"description": "VCMI MacOS Xcode",
|
||||
"inherits": "default-release",
|
||||
"generator": "Xcode"
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "default-release",
|
||||
"hidden": true,
|
||||
"configuration": "RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-release",
|
||||
"configurePreset": "linux-clang-release",
|
||||
"inherits": "default-release"
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-release",
|
||||
"configurePreset": "linux-gcc-release",
|
||||
"inherits": "default-release"
|
||||
},
|
||||
{
|
||||
"name": "macos-xcode-release",
|
||||
"configurePreset": "macos-xcode-release",
|
||||
"inherits": "default-release"
|
||||
},
|
||||
{
|
||||
"name": "macos-ninja-release",
|
||||
"configurePreset": "macos-ninja-release",
|
||||
"inherits": "default-release"
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-release",
|
||||
"configurePreset": "windows-msvc-release",
|
||||
"inherits": "default-release"
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "default-release",
|
||||
"hidden": true,
|
||||
"output": {
|
||||
"shortProgress": true,
|
||||
"verbosity": "verbose"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-release",
|
||||
"configurePreset": "linux-clang-release",
|
||||
"inherits": "default-release"
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-release",
|
||||
"configurePreset": "linux-gcc-release",
|
||||
"inherits": "default-release"
|
||||
},
|
||||
{
|
||||
"name": "macos-xcode-release",
|
||||
"configurePreset": "macos-xcode-release",
|
||||
"inherits": "default-release"
|
||||
},
|
||||
{
|
||||
"name": "macos-ninja-release",
|
||||
"configurePreset": "macos-ninja-release",
|
||||
"inherits": "default-release"
|
||||
},
|
||||
{
|
||||
"name": "windows-msvc-release",
|
||||
"configurePreset": "windows-msvc-release",
|
||||
"inherits": "default-release"
|
||||
}
|
||||
]
|
||||
}
|
@ -173,23 +173,17 @@ if(WIN32)
|
||||
)
|
||||
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT vcmiclient)
|
||||
if(NOT ENABLE_DEBUG_CONSOLE)
|
||||
target_link_libraries(vcmiclient ${SDLMAIN_LIBRARY})
|
||||
target_link_libraries(vcmiclient SDL2::SDL2main)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(vcmiclient PRIVATE
|
||||
vcmi ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${SDL2_MIXER_LIBRARY} ${SDL2_TTF_LIBRARY}
|
||||
${FFMPEG_LIBRARIES} ${FFMPEG_EXTRA_LINKING_OPTIONS} ${TBB_LIBRARIES}
|
||||
vcmi SDL2::SDL2 SDL2::Image SDL2::Mixer SDL2::TTF
|
||||
ffmpeg::swscale ffmpeg::avutil ffmpeg::avcodec ffmpeg::avformat TBB::tbb
|
||||
)
|
||||
|
||||
target_include_directories(vcmiclient
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PUBLIC ${SDL2_INCLUDE_DIR}
|
||||
PRIVATE ${SDL2_TTF_INCLUDE_DIR}
|
||||
PRIVATE ${SDL2_MIXER_INCLUDE_DIR}
|
||||
PRIVATE ${SDL2_IMAGE_INCLUDE_DIR}
|
||||
PRIVATE ${FFMPEG_INCLUDE_DIRS}
|
||||
)
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
vcmi_set_output_dir(vcmiclient "")
|
||||
|
||||
|
@ -1,163 +0,0 @@
|
||||
# vim: ts=2 sw=2
|
||||
# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC)
|
||||
#
|
||||
# Once done this will define
|
||||
# FFMPEG_FOUND - System has the all required components.
|
||||
# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers.
|
||||
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
|
||||
# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components.
|
||||
#
|
||||
# For each of the components it will additionally set.
|
||||
# - AVCODEC
|
||||
# - AVDEVICE
|
||||
# - AVFORMAT
|
||||
# - AVUTIL
|
||||
# - POSTPROCESS
|
||||
# - SWSCALE
|
||||
# the following variables will be defined
|
||||
# <component>_FOUND - System has <component>
|
||||
# <component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
|
||||
# <component>_LIBRARIES - Link these to use <component>
|
||||
# <component>_DEFINITIONS - Compiler switches required for using <component>
|
||||
# <component>_VERSION - The components version
|
||||
#
|
||||
# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
|
||||
# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
|
||||
# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# The default components were taken from a survey over other FindFFMPEG.cmake files
|
||||
if (NOT FFmpeg_FIND_COMPONENTS)
|
||||
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE)
|
||||
endif ()
|
||||
|
||||
if(MSVC)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
### Macro: set_component_found
|
||||
#
|
||||
# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present.
|
||||
#
|
||||
macro(set_component_found _component )
|
||||
if (${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
|
||||
# message(STATUS " - ${_component} found.")
|
||||
set(${_component}_FOUND TRUE)
|
||||
else ()
|
||||
# message(STATUS " - ${_component} not found.")
|
||||
endif ()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
### Macro: find_component
|
||||
#
|
||||
# Checks for the given component by invoking pkgconfig and then looking up the libraries and
|
||||
# include directories.
|
||||
#
|
||||
macro(find_component _component _pkgconfig _library _header)
|
||||
|
||||
if (NOT WIN32)
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_${_component} ${_pkgconfig})
|
||||
endif ()
|
||||
endif (NOT WIN32)
|
||||
|
||||
find_path(${_component}_INCLUDE_DIRS ${_header}
|
||||
HINTS
|
||||
${PC_LIB${_component}_INCLUDEDIR}
|
||||
${PC_LIB${_component}_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES
|
||||
ffmpeg
|
||||
)
|
||||
|
||||
find_library(${_component}_LIBRARIES NAMES ${_library}
|
||||
HINTS
|
||||
${PC_LIB${_component}_LIBDIR}
|
||||
${PC_LIB${_component}_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES
|
||||
${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.")
|
||||
set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.")
|
||||
|
||||
set_component_found(${_component})
|
||||
|
||||
mark_as_advanced(
|
||||
${_component}_INCLUDE_DIRS
|
||||
${_component}_LIBRARIES
|
||||
${_component}_DEFINITIONS
|
||||
${_component}_VERSION)
|
||||
|
||||
endmacro()
|
||||
|
||||
|
||||
# Check for cached results. If there are skip the costly part.
|
||||
if (NOT FFMPEG_LIBRARIES)
|
||||
|
||||
# Check for all possible component.
|
||||
find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h)
|
||||
find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
|
||||
find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
|
||||
find_component(AVUTIL libavutil avutil libavutil/avutil.h)
|
||||
find_component(SWSCALE libswscale swscale libswscale/swscale.h)
|
||||
find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h)
|
||||
|
||||
# Check if the required components were found and add their stuff to the FFMPEG_* vars.
|
||||
foreach (_component ${FFmpeg_FIND_COMPONENTS})
|
||||
if (${_component}_FOUND)
|
||||
# message(STATUS "Required component ${_component} present.")
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES})
|
||||
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS})
|
||||
list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
|
||||
else ()
|
||||
# message(STATUS "Required component ${_component} missing.")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Build the include path with duplicates removed.
|
||||
if (FFMPEG_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
|
||||
endif ()
|
||||
|
||||
# cache the vars.
|
||||
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE)
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE)
|
||||
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE)
|
||||
|
||||
mark_as_advanced(FFMPEG_INCLUDE_DIRS
|
||||
FFMPEG_LIBRARIES
|
||||
FFMPEG_DEFINITIONS)
|
||||
|
||||
endif ()
|
||||
|
||||
# Now set the noncached _FOUND vars for the components.
|
||||
foreach (_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE)
|
||||
set_component_found(${_component})
|
||||
endforeach ()
|
||||
|
||||
# Compile the list of required vars
|
||||
set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS)
|
||||
foreach (_component ${FFmpeg_FIND_COMPONENTS})
|
||||
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS)
|
||||
endforeach ()
|
||||
|
||||
# On OS X we ffmpeg libraries depend on VideoDecodeAcceleration and CoreVideo frameworks
|
||||
IF (APPLE)
|
||||
SET(FFMPEG_EXTRA_LINKING_OPTIONS "-framework VideoDecodeAcceleration -framework CoreVideo -lbz2")
|
||||
ENDIF()
|
||||
|
||||
# Give a nice error message if some of the required vars are missing.
|
||||
find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})
|
@ -1,50 +0,0 @@
|
||||
# Locate LuaJIT library
|
||||
# This module defines
|
||||
# LUAJIT_FOUND, if false, do not try to link to Lua
|
||||
# LUA_INCLUDE_DIR, where to find lua.h
|
||||
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||
#
|
||||
# This module is similar to FindLua51.cmake except that it finds LuaJit instead.
|
||||
|
||||
FIND_PATH(LUA_INCLUDE_DIR luajit.h
|
||||
HINTS
|
||||
$ENV{LUA_DIR}
|
||||
PATH_SUFFIXES include/luajit include/luajit-2.1 include/luajit-2.0 include/luajit-5_1-2.1 include/luajit-5_1-2.0 include
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
)
|
||||
|
||||
FIND_LIBRARY(LUA_LIBRARY
|
||||
NAMES luajit-5.1 lua51
|
||||
HINTS
|
||||
$ENV{LUA_DIR}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
|
||||
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h")
|
||||
FILE(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT .+\"")
|
||||
|
||||
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
|
||||
UNSET(lua_version_str)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJit
|
||||
REQUIRED_VARS LUA_LIBRARY LUA_INCLUDE_DIR
|
||||
VERSION_VAR LUA_VERSION_STRING)
|
||||
|
||||
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)
|
@ -1,196 +1,298 @@
|
||||
#.rst:
|
||||
# FindSDL2
|
||||
# --------
|
||||
#
|
||||
# Locate SDL2 library
|
||||
#
|
||||
# This module defines
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_LIBRARY, the name of the library to link against
|
||||
# SDL2_FOUND, if false, do not try to link to SDL
|
||||
# SDL2_INCLUDE_DIR, where to find SDL.h
|
||||
# SDL2_VERSION_STRING, human-readable string containing the version of SDL
|
||||
#
|
||||
#
|
||||
#
|
||||
# This module responds to the flag:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_BUILDING_LIBRARY
|
||||
# If this is defined, then no SDL2_main will be linked in because
|
||||
# only applications need main().
|
||||
# Otherwise, it is assumed you are building an application and this
|
||||
# module will attempt to locate and set the proper link flags
|
||||
# as part of the returned SDL2_LIBRARY variable.
|
||||
#
|
||||
#
|
||||
#
|
||||
# Don't forget to include SDLmain.h and SDLmain.m your project for the
|
||||
# OS X framework based version. (Other versions link to -lSDL2main which
|
||||
# this module will try to find on your behalf.) Also for OS X, this
|
||||
# module will automatically add the -framework Cocoa on your behalf.
|
||||
#
|
||||
#
|
||||
#
|
||||
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your
|
||||
# configuration and no SDL2_LIBRARY, it means CMake did not find your SDL
|
||||
# library (SDL2.dll, libSDL2.so, SDL.framework, etc). Set
|
||||
# SDL2_LIBRARY_TEMP to point to your SDL library, and configure again.
|
||||
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this
|
||||
# value as appropriate. These values are used to generate the final
|
||||
# SDL2_LIBRARY variable, but when these values are unset, SDL2_LIBRARY
|
||||
# does not get created.
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL. l.e.galup 9-20-02
|
||||
#
|
||||
# Modified by Eric Wing. Added code to assist with automated building
|
||||
# by using environmental variables and providing a more
|
||||
# controlled/consistent search behavior. Added new modifications to
|
||||
# recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
|
||||
# Also corrected the header search path to follow "proper" SDL
|
||||
# guidelines. Added a search for SDLmain which is needed by some
|
||||
# platforms. Added a search for threads which is needed by some
|
||||
# platforms. Added needed compile switches for MinGW.
|
||||
#
|
||||
# On OSX, this will prefer the Framework version (if found) over others.
|
||||
# People will have to manually change the cache values of SDL2_LIBRARY to
|
||||
# override this selection or set the CMake environment
|
||||
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2003-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file kitware license.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
if (NOT WIN32)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(_SDL2 sdl2)
|
||||
set(SDL2_VERSION_STRING ${_SDL2_VERSION})
|
||||
endif ()
|
||||
endif ()
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
find_path(SDL2_INCLUDE_DIR
|
||||
SDL.h
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2
|
||||
--------
|
||||
|
||||
Locate SDL2 library
|
||||
|
||||
This module defines the following 'IMPORTED' targets:
|
||||
|
||||
::
|
||||
|
||||
SDL2::SDL2
|
||||
The SDL2 library, if found.
|
||||
Libraries should link to SDL2::SDL2
|
||||
|
||||
SDL2::SDL2main
|
||||
The SDL2main library, if found.
|
||||
Applications should link to SDL2::SDL2main instead of SDL2::SDL2
|
||||
|
||||
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_LIBRARIES, the name of the library to link against
|
||||
SDL2_INCLUDE_DIRS, where to find SDL.h
|
||||
SDL2_FOUND, if false, do not try to link to SDL2
|
||||
SDL2MAIN_FOUND, if false, do not try to link to SDL2main
|
||||
SDL2_VERSION_STRING, human-readable string containing the version of SDL2
|
||||
|
||||
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_PATH
|
||||
Set a custom SDL2 Library path (default: empty)
|
||||
|
||||
SDL2_NO_DEFAULT_PATH
|
||||
Disable search SDL2 Library in default path.
|
||||
If SDL2_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_INCLUDE_DIR
|
||||
SDL2 headers path.
|
||||
|
||||
SDL2_LIBRARY
|
||||
SDL2 Library (.dll, .so, .a, etc) path.
|
||||
|
||||
SDL2MAIN_LIBRAY
|
||||
SDL2main Library (.a) path.
|
||||
|
||||
SDL2_BUILDING_LIBRARY
|
||||
This flag is useful only when linking to SDL2_LIBRARIES insead of
|
||||
SDL2::SDL2main. It is required only when building a library that links to
|
||||
SDL2_LIBRARIES, because only applications need main() (No need to also
|
||||
link to SDL2main).
|
||||
If this flag is defined, then no SDL2main will be added to SDL2_LIBRARIES
|
||||
and no SDL2::SDL2main target will be created.
|
||||
|
||||
|
||||
Don't forget to include SDLmain.h and SDLmain.m in your project for the
|
||||
OS X framework based version. (Other versions link to -lSDL2main which
|
||||
this module will try to find on your behalf.) Also for OS X, this
|
||||
module will automatically add the -framework Cocoa on your behalf.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2 library
|
||||
(SDL2.dll, libsdl2.so, SDL2.framework, etc). Set SDL2_LIBRARY to point
|
||||
to your SDL2 library, and configure again. Similarly, if you see an
|
||||
empty SDL2MAIN_LIBRARY, you should set this value as appropriate. These
|
||||
values are used to generate the final SDL2_LIBRARIES variable and the
|
||||
SDL2::SDL2 and SDL2::SDL2main targets, but when these values are unset,
|
||||
SDL2_LIBRARIES, SDL2::SDL2 and SDL2::SDL2main does not get created.
|
||||
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2. l.e.galup 9-20-02
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL.cmake to SDL2 (FindSDL2.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_PATH, SDL2_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Mark 'Threads' as a required dependency for non-OSX systems.
|
||||
Modernize the FindSDL2.cmake module by creating specific targets:
|
||||
SDL2::SDL2 and SDL2::SDL2main (for details, see doc above).
|
||||
|
||||
|
||||
Original FindSDL.cmake module:
|
||||
Modified by Eric Wing. Added code to assist with automated building
|
||||
by using environmental variables and providing a more
|
||||
controlled/consistent search behavior. Added new modifications to
|
||||
recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
|
||||
Also corrected the header search path to follow "proper" SDL
|
||||
guidelines. Added a search for SDLmain which is needed by some
|
||||
platforms. Added a search for threads which is needed by some
|
||||
platforms. Added needed compile switches for MinGW.
|
||||
|
||||
On OSX, this will prefer the Framework version (if found) over others.
|
||||
People will have to manually change the cache value of SDL2_LIBRARY to
|
||||
override this selection or set the SDL2_PATH variable or the CMake
|
||||
environment CMAKE_INCLUDE_PATH to modify the search paths.
|
||||
|
||||
Note that the header path has changed from SDL/SDL.h to just SDL.h
|
||||
This needed to change because "proper" SDL convention is #include
|
||||
"SDL.h", not <SDL/SDL.h>. This is done for portability reasons
|
||||
because not all systems place things in SDL/ (see FreeBSD).
|
||||
#]=======================================================================]
|
||||
|
||||
# Define options for searching SDL2 Library in a custom path
|
||||
|
||||
set(SDL2_PATH "" CACHE STRING "Custom SDL2 Library path")
|
||||
|
||||
set(_SDL2_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_PATH)
|
||||
set(_SDL2_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_NO_DEFAULT_PATH ${_SDL2_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2 Library in default path")
|
||||
unset(_SDL2_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_NO_DEFAULT_PATH)
|
||||
set(SDL2_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2 include directory
|
||||
find_path(SDL2_INCLUDE_DIR SDL.h
|
||||
HINTS
|
||||
${_SDL2_INCLUDEDIR}
|
||||
ENV SDL2DIR
|
||||
PATH_SUFFIXES
|
||||
SDL2
|
||||
include/SDL2
|
||||
include
|
||||
${SDL2_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_PATH}
|
||||
DOC "Where the SDL2 headers can be found"
|
||||
)
|
||||
|
||||
set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR}")
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
find_library(SDL2_LIBRARY_TEMP
|
||||
NAMES
|
||||
SDL2
|
||||
# SDL-2.0 is the name used by FreeBSD ports...
|
||||
# don't confuse it for the version number.
|
||||
find_library(SDL2_LIBRARY
|
||||
NAMES SDL2 SDL-2.0
|
||||
HINTS
|
||||
${_SDL2_LIBDIR}
|
||||
ENV SDL2DIR
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
${VC_LIB_PATH_SUFFIX}
|
||||
${SDL2_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_PATH}
|
||||
DOC "Where the SDL2 Library can be found"
|
||||
)
|
||||
|
||||
set(SDL2_LIBRARIES "${SDL2_LIBRARY}")
|
||||
|
||||
if(NOT SDL2_BUILDING_LIBRARY)
|
||||
if(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
||||
if(NOT SDL2_INCLUDE_DIR MATCHES ".framework")
|
||||
# Non-OS X framework versions expect you to also dynamically link to
|
||||
# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||
# seem to provide SDLmain for compatibility even though they don't
|
||||
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||
# seem to provide SDL2main for compatibility even though they don't
|
||||
# necessarily need it.
|
||||
|
||||
if(SDL2_PATH)
|
||||
set(SDL2MAIN_LIBRARY_PATHS "${SDL2_PATH}")
|
||||
endif()
|
||||
|
||||
if(NOT SDL2_NO_DEFAULT_PATH)
|
||||
set(SDL2MAIN_LIBRARY_PATHS
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
"${SDL2MAIN_LIBRARY_PATHS}"
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(SDL2MAIN_LIBRARY
|
||||
NAMES
|
||||
SDL2main
|
||||
NAMES SDL2main
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
${VC_LIB_PATH_SUFFIX}
|
||||
PATHS
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
${SDL2_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2MAIN_LIBRARY_PATHS}
|
||||
DOC "Where the SDL2main library can be found"
|
||||
)
|
||||
unset(SDL2MAIN_LIBRARY_PATHS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# SDL may require threads on your system.
|
||||
# SDL2 may require threads on your system.
|
||||
# The Apple build may not need an explicit flag because one of the
|
||||
# frameworks may already provide it.
|
||||
# But for non-OSX systems, I will use the CMake Threads package.
|
||||
if(NOT APPLE)
|
||||
find_package(Threads)
|
||||
find_package(Threads QUIET)
|
||||
if(NOT Threads_FOUND)
|
||||
set(SDL2_THREADS_NOT_FOUND "Could NOT find Threads (Threads is required by SDL2).")
|
||||
if(SDL2_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_THREADS_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_THREADS_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_THREADS_NOT_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# MinGW needs an additional library, mwindows
|
||||
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
|
||||
# (Actually on second look, I think it only needs one of the m* libraries.)
|
||||
# MinGW needs an additional link flag, -mwindows
|
||||
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows
|
||||
if(MINGW)
|
||||
set(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
|
||||
set(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "link flags for MinGW")
|
||||
endif()
|
||||
|
||||
if(SDL2_LIBRARY_TEMP)
|
||||
# For SDLmain
|
||||
if(SDL2_LIBRARY)
|
||||
# For SDL2main
|
||||
if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY)
|
||||
list(FIND SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" _SDL2_MAIN_INDEX)
|
||||
list(FIND SDL2_LIBRARIES "${SDL2MAIN_LIBRARY}" _SDL2_MAIN_INDEX)
|
||||
if(_SDL2_MAIN_INDEX EQUAL -1)
|
||||
set(SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" ${SDL2_LIBRARY_TEMP})
|
||||
set(SDL2_LIBRARIES "${SDL2MAIN_LIBRARY}" ${SDL2_LIBRARIES})
|
||||
endif()
|
||||
unset(_SDL2_MAIN_INDEX)
|
||||
endif()
|
||||
|
||||
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
|
||||
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||
# though it actually is there if I modify a pre-used variable.
|
||||
# I think it has something to do with the CACHE STRING.
|
||||
# So I use a temporary variable until the end so I can set the
|
||||
# "real" variable in one-shot.
|
||||
if(APPLE)
|
||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
||||
set(SDL2_LIBRARIES ${SDL2_LIBRARIES} -framework Cocoa)
|
||||
endif()
|
||||
|
||||
# For threads, as mentioned Apple doesn't need this.
|
||||
# In fact, there seems to be a problem if I used the Threads package
|
||||
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||
if(NOT APPLE)
|
||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(SDL2_LIBRARIES ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
# For MinGW library
|
||||
if(MINGW)
|
||||
set(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||
set(SDL2_LIBRARIES ${MINGW32_LIBRARY} ${SDL2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# Set the final string here so the GUI reflects the final state.
|
||||
set(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found")
|
||||
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||
set(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h" AND NOT SDL2_VERSION_STRING)
|
||||
# Read SDL2 version
|
||||
if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h")
|
||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
@ -206,11 +308,81 @@ if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h" AND NOT SDL2_
|
||||
unset(SDL2_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
set(SDL2_LIBRARIES ${SDL2_LIBRARY})
|
||||
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
|
||||
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
|
||||
VERSION_VAR SDL2_VERSION_STRING)
|
||||
|
||||
if(SDL2MAIN_LIBRARY)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2main
|
||||
REQUIRED_VARS SDL2MAIN_LIBRARY SDL2_INCLUDE_DIR
|
||||
VERSION_VAR SDL2_VERSION_STRING)
|
||||
endif()
|
||||
|
||||
|
||||
mark_as_advanced(SDL2_PATH
|
||||
SDL2_NO_DEFAULT_PATH
|
||||
SDL2_LIBRARY
|
||||
SDL2MAIN_LIBRARY
|
||||
SDL2_INCLUDE_DIR
|
||||
SDL2_BUILDING_LIBRARY)
|
||||
|
||||
|
||||
# SDL2:: targets (SDL2::SDL2 and SDL2::SDL2main)
|
||||
if(SDL2_FOUND)
|
||||
|
||||
# SDL2::SDL2 target
|
||||
if(SDL2_LIBRARY AND NOT TARGET SDL2::SDL2)
|
||||
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::SDL2 PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}")
|
||||
|
||||
if(APPLE)
|
||||
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||
# For more details, please see above.
|
||||
set_property(TARGET SDL2::SDL2 APPEND PROPERTY
|
||||
INTERFACE_LINK_OPTIONS -framework Cocoa)
|
||||
else()
|
||||
# For threads, as mentioned Apple doesn't need this.
|
||||
# For more details, please see above.
|
||||
set_property(TARGET SDL2::SDL2 APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES Threads::Threads)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# SDL2::SDL2main target
|
||||
# Applications should link to SDL2::SDL2main instead of SDL2::SDL2
|
||||
# For more details, please see above.
|
||||
if(NOT SDL2_BUILDING_LIBRARY AND NOT TARGET SDL2::SDL2main)
|
||||
|
||||
if(SDL2_INCLUDE_DIR MATCHES ".framework" OR NOT SDL2MAIN_LIBRARY)
|
||||
add_library(SDL2::SDL2main INTERFACE IMPORTED)
|
||||
set_property(TARGET SDL2::SDL2main PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES SDL2::SDL2)
|
||||
elseif(SDL2MAIN_LIBRARY)
|
||||
# MinGW requires that the mingw32 library is specified before the
|
||||
# libSDL2main.a static library when linking.
|
||||
# The SDL2::SDL2mainInternal target is used internally to make sure that
|
||||
# CMake respects this condition.
|
||||
add_library(SDL2::SDL2mainInternal UNKNOWN IMPORTED)
|
||||
set_property(TARGET SDL2::SDL2mainInternal PROPERTY
|
||||
IMPORTED_LOCATION "${SDL2MAIN_LIBRARY}")
|
||||
set_property(TARGET SDL2::SDL2mainInternal PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES SDL2::SDL2)
|
||||
|
||||
add_library(SDL2::SDL2main INTERFACE IMPORTED)
|
||||
|
||||
if(MINGW)
|
||||
# MinGW needs an additional link flag '-mwindows' and link to mingw32
|
||||
set_property(TARGET SDL2::SDL2main PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES "mingw32" "-mwindows")
|
||||
endif()
|
||||
|
||||
set_property(TARGET SDL2::SDL2main APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES SDL2::SDL2mainInternal)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1,57 +1,172 @@
|
||||
#.rst:
|
||||
# FindSDL2_image
|
||||
# --------------
|
||||
#
|
||||
# Locate SDL2_image library
|
||||
#
|
||||
# This module defines:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_IMAGE_LIBRARIES, the name of the library to link against
|
||||
# SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
|
||||
# SDL2_IMAGE_FOUND, if false, do not try to link against
|
||||
# SDL2_IMAGE_VERSION_STRING - human-readable string containing the version of SDL2_image
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL.
|
||||
#
|
||||
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
|
||||
# module, but with modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file kitware license.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
if (NOT WIN32)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(_SDL2_IMAGE SDL2_image)
|
||||
set(SDL2_IMAGE_VERSION_STRING ${_SDL2_IMAGE_VERSION})
|
||||
endif ()
|
||||
endif ()
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
find_path(SDL2_IMAGE_INCLUDE_DIR
|
||||
SDL_image.h
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2_image
|
||||
--------------
|
||||
|
||||
Locate SDL2_image library
|
||||
|
||||
This module defines the following 'IMPORTED' target:
|
||||
|
||||
::
|
||||
|
||||
SDL2::Image
|
||||
The SDL2_image library, if found.
|
||||
Have SDL2::SDL2 as a link dependency.
|
||||
|
||||
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_IMAGE_LIBRARIES, the name of the library to link against
|
||||
SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
|
||||
SDL2_IMAGE_FOUND, if false, do not try to link against
|
||||
SDL2_IMAGE_VERSION_STRING - human-readable string containing the
|
||||
version of SDL2_image
|
||||
|
||||
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_IMAGE_PATH
|
||||
Set a custom SDL2_image Library path (default: empty)
|
||||
|
||||
SDL2_IMAGE_NO_DEFAULT_PATH
|
||||
Disable search SDL2_image Library in default path.
|
||||
If SDL2_IMAGE_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_IMAGE_INCLUDE_DIR
|
||||
SDL2_image headers path.
|
||||
|
||||
SDL2_IMAGE_LIBRARY
|
||||
SDL2_image Library (.dll, .so, .a, etc) path.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_IMAGE_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2_image library
|
||||
(SDL2_image.dll, libsdl2_image.so, etc). Set SDL2_IMAGE_LIBRARY to point
|
||||
to your SDL2_image library, and configure again. This value is used to
|
||||
generate the final SDL2_IMAGE_LIBRARIES variable and the SDL2::Image target,
|
||||
but when this value is unset, SDL2_IMAGE_LIBRARIES and SDL2::Image does not
|
||||
get created.
|
||||
|
||||
|
||||
$SDL2IMAGEDIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2IMAGEDIR used in building SDL2_image.
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL_image.cmake to SDL2_image (FindSDL2_image.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_IMAGE_PATH, SDL2_IMAGE_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Add SDL2 as a required dependency.
|
||||
Modernize the FindSDL2_image.cmake module by creating a specific target:
|
||||
SDL2::Image (for details, see doc above).
|
||||
|
||||
Original FindSDL_image.cmake module:
|
||||
Created by Eric Wing. This was influenced by the FindSDL.cmake
|
||||
module, but with modifications to recognize OS X frameworks and
|
||||
additional Unix paths (FreeBSD, etc).
|
||||
#]=======================================================================]
|
||||
|
||||
# SDL2 Library required
|
||||
find_package(SDL2 QUIET)
|
||||
if(NOT SDL2_FOUND)
|
||||
set(SDL2_IMAGE_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_image).")
|
||||
if(SDL2_image_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_IMAGE_SDL2_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_image_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_IMAGE_SDL2_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_IMAGE_SDL2_NOT_FOUND)
|
||||
endif()
|
||||
|
||||
#Try config mode first - conan hack
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(sdl_image CONFIG QUIET)
|
||||
if(TARGET sdl_image::sdl_image)
|
||||
add_library(SDL2::Image ALIAS sdl_image::sdl_image)
|
||||
find_package_handle_standard_args(SDL2_image
|
||||
REQUIRED_VARS sdl_image_LIBRARIES sdl_image_INCLUDE_DIRS
|
||||
VERSION_VAR sdl_image_VERSION_STRING)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Define options for searching SDL2_image Library in a custom path
|
||||
|
||||
set(SDL2_IMAGE_PATH "" CACHE STRING "Custom SDL2_image Library path")
|
||||
|
||||
set(_SDL2_IMAGE_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_IMAGE_PATH)
|
||||
set(_SDL2_IMAGE_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_IMAGE_NO_DEFAULT_PATH ${_SDL2_IMAGE_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2_image Library in default path")
|
||||
unset(_SDL2_IMAGE_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_IMAGE_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_IMAGE_NO_DEFAULT_PATH)
|
||||
set(SDL2_IMAGE_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_image include directory
|
||||
find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
|
||||
HINTS
|
||||
${_SDL2_IMAGE_INCLUDEDIR}
|
||||
ENV SDL2IMAGEDIR
|
||||
ENV SDL2DIR
|
||||
PATH_SUFFIXES
|
||||
SDL2
|
||||
include/SDL2
|
||||
include
|
||||
${SDL2_IMAGE_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
# and ENV{SDL2IMAGEDIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_IMAGE_PATH}
|
||||
DOC "Where the SDL2_image headers can be found"
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
@ -60,19 +175,20 @@ else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_image library
|
||||
find_library(SDL2_IMAGE_LIBRARY
|
||||
NAMES
|
||||
SDL2_image
|
||||
NAMES SDL2_image
|
||||
HINTS
|
||||
${_SDL2_IMAGE_LIBDIR}
|
||||
ENV SDL2IMAGEDIR
|
||||
ENV SDL2DIR
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
${VC_LIB_PATH_SUFFIX}
|
||||
${SDL2_IMAGE_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_IMAGE_PATH}
|
||||
DOC "Where the SDL2_image Library can be found"
|
||||
)
|
||||
|
||||
if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" AND NOT SDL2_IMAGE_VERSION_STRING)
|
||||
# Read SDL2_image version
|
||||
if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h")
|
||||
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
@ -91,10 +207,25 @@ endif()
|
||||
set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
|
||||
set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
|
||||
REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_IMAGE_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(SDL2_IMAGE_PATH
|
||||
SDL2_IMAGE_NO_DEFAULT_PATH
|
||||
SDL2_IMAGE_LIBRARY
|
||||
SDL2_IMAGE_INCLUDE_DIR)
|
||||
|
||||
|
||||
if(SDL2_IMAGE_FOUND)
|
||||
|
||||
# SDL2::Image target
|
||||
if(SDL2_IMAGE_LIBRARY AND NOT TARGET SDL2::Image)
|
||||
add_library(SDL2::Image UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::Image PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_IMAGE_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_IMAGE_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES SDL2::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1,58 +1,159 @@
|
||||
#.rst:
|
||||
# FindSDL2_mixer
|
||||
# --------------
|
||||
#
|
||||
# Locate SDL2_mixer library
|
||||
#
|
||||
# This module defines:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_MIXER_LIBRARIES, the name of the library to link against
|
||||
# SDL2_MIXER_INCLUDE_DIRS, where to find the headers
|
||||
# SDL2_MIXER_FOUND, if false, do not try to link against
|
||||
# SDL2_MIXER_VERSION_STRING - human-readable string containing the version of SDL_mixer
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL.
|
||||
#
|
||||
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
|
||||
# module, but with modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file kitware license.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
if (NOT WIN32)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(_SDL2_MIXER SDL2_mixer)
|
||||
set(SDL2_MIXER_STRING ${_SDL2_MIXER_VERSION})
|
||||
endif ()
|
||||
endif ()
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2_mixer
|
||||
--------------
|
||||
|
||||
Locate SDL2_mixer library
|
||||
|
||||
This module defines the following 'IMPORTED' target:
|
||||
|
||||
::
|
||||
|
||||
SDL2::Mixer
|
||||
The SDL2_mixer library, if found.
|
||||
Have SDL2::SDL2 as a link dependency.
|
||||
|
||||
|
||||
find_path(SDL2_MIXER_INCLUDE_DIR
|
||||
SDL_mixer.h
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_MIXER_LIBRARIES, the name of the library to link against
|
||||
SDL2_MIXER_INCLUDE_DIRS, where to find the headers
|
||||
SDL2_MIXER_FOUND, if false, do not try to link against
|
||||
SDL2_MIXER_VERSION_STRING - human-readable string containing the
|
||||
version of SDL2_mixer
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_MIXER_PATH
|
||||
Set a custom SDL2_mixer Library path (default: empty)
|
||||
|
||||
SDL2_MIXER_NO_DEFAULT_PATH
|
||||
Disable search SDL2_mixer Library in default path.
|
||||
If SDL2_MIXER_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_MIXER_INCLUDE_DIR
|
||||
SDL2_mixer headers path.
|
||||
|
||||
SDL2_MIXER_LIBRARY
|
||||
SDL2_mixer Library (.dll, .so, .a, etc) path.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_MIXER_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2_mixer library
|
||||
(SDL2_mixer.dll, libsdl2_mixer.so, etc). Set SDL2_MIXER_LIBRARY to point
|
||||
to your SDL2_mixer library, and configure again. This value is used to
|
||||
generate the final SDL2_MIXER_LIBRARIES variable and the SDL2::Mixer target,
|
||||
but when this value is unset, SDL2_MIXER_LIBRARIES and SDL2::Mixer does not
|
||||
get created.
|
||||
|
||||
|
||||
$SDL2MIXERDIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2MIXERDIR used in building SDL2_mixer.
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL_mixer.cmake to SDL2_mixer (FindSDL2_mixer.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_MIXER_PATH, SDL2_MIXER_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Add SDL2 as a required dependency.
|
||||
Modernize the FindSDL2_mixer.cmake module by creating a specific target:
|
||||
SDL2::Mixer (for details, see doc above).
|
||||
|
||||
Original FindSDL_mixer.cmake module:
|
||||
Created by Eric Wing. This was influenced by the FindSDL.cmake
|
||||
module, but with modifications to recognize OS X frameworks and
|
||||
additional Unix paths (FreeBSD, etc).
|
||||
#]=======================================================================]
|
||||
|
||||
# SDL2 Library required
|
||||
find_package(SDL2 QUIET)
|
||||
if(NOT SDL2_FOUND)
|
||||
set(SDL2_MIXER_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_mixer).")
|
||||
if(SDL2_mixer_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_MIXER_SDL2_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_mixer_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_MIXER_SDL2_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_MIXER_SDL2_NOT_FOUND)
|
||||
endif()
|
||||
|
||||
|
||||
# Define options for searching SDL2_mixer Library in a custom path
|
||||
|
||||
set(SDL2_MIXER_PATH "" CACHE STRING "Custom SDL2_mixer Library path")
|
||||
|
||||
set(_SDL2_MIXER_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_MIXER_PATH)
|
||||
set(_SDL2_MIXER_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_MIXER_NO_DEFAULT_PATH ${_SDL2_MIXER_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2_mixer Library in default path")
|
||||
unset(_SDL2_MIXER_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_MIXER_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_MIXER_NO_DEFAULT_PATH)
|
||||
set(SDL2_MIXER_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_mixer include directory
|
||||
find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
|
||||
HINTS
|
||||
${_SDL2_MIXER_INCLUDEDIR}
|
||||
ENV SDL2MIXERDIR
|
||||
ENV SDL2DIR
|
||||
PATH_SUFFIXES
|
||||
SDL2
|
||||
include/SDL2
|
||||
include
|
||||
${SDL2_MIXER_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
# and ENV{SDL2MIXERDIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_MIXER_PATH}
|
||||
DOC "Where the SDL2_mixer headers can be found"
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
@ -61,19 +162,20 @@ else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_mixer library
|
||||
find_library(SDL2_MIXER_LIBRARY
|
||||
NAMES
|
||||
SDL2_mixer
|
||||
NAMES SDL2_mixer
|
||||
HINTS
|
||||
${_SDL2_MIXER_LIBDIR}
|
||||
ENV SDL2MIXERDIR
|
||||
ENV SDL2DIR
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
${VC_LIB_PATH_SUFFIX}
|
||||
${SDL2_MIXER_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_MIXER_PATH}
|
||||
DOC "Where the SDL2_mixer Library can be found"
|
||||
)
|
||||
|
||||
if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" AND NOT SDL2_MIXER_STRING)
|
||||
# Read SDL2_mixer version
|
||||
if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h")
|
||||
file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
@ -98,4 +200,21 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
|
||||
REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_MIXER_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(SDL2_MIXER_PATH
|
||||
SDL2_MIXER_NO_DEFAULT_PATH
|
||||
SDL2_MIXER_LIBRARY
|
||||
SDL2_MIXER_INCLUDE_DIR)
|
||||
|
||||
|
||||
if(SDL2_MIXER_FOUND)
|
||||
|
||||
# SDL2::Mixer target
|
||||
if(SDL2_MIXER_LIBRARY AND NOT TARGET SDL2::Mixer)
|
||||
add_library(SDL2::Mixer UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::Mixer PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_MIXER_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES SDL2::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1,57 +1,161 @@
|
||||
#.rst:
|
||||
# FindSDL2_ttf
|
||||
# ------------
|
||||
#
|
||||
# Locate SDL2_ttf library
|
||||
#
|
||||
# This module defines:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_TTF_LIBRARIES, the name of the library to link against
|
||||
# SDL2_TTF_INCLUDE_DIRS, where to find the headers
|
||||
# SDL2_TTF_FOUND, if false, do not try to link against
|
||||
# SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL2_ttf
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL.
|
||||
#
|
||||
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
|
||||
# module, but with modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file kitware license.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
# Copyright 2019 Amine Ben Hassouna <amine.benhassouna@gmail.com>
|
||||
# Copyright 2000-2019 Kitware, Inc. and Contributors
|
||||
# All rights reserved.
|
||||
|
||||
if (NOT WIN32)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(_SDL2_TTF SDL2_ttf)
|
||||
set(SDL2_TTF_VERSION_STRING ${_SDL2_TTF_VERSION})
|
||||
endif ()
|
||||
endif ()
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
find_path(SDL2_TTF_INCLUDE_DIR
|
||||
SDL_ttf.h
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# * Neither the name of Kitware, Inc. nor the names of Contributors
|
||||
# may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindSDL2_ttf
|
||||
------------
|
||||
|
||||
Locate SDL2_ttf library
|
||||
|
||||
This module defines the following 'IMPORTED' target:
|
||||
|
||||
::
|
||||
|
||||
SDL2::TTF
|
||||
The SDL2_ttf library, if found.
|
||||
Have SDL2::SDL2 as a link dependency.
|
||||
|
||||
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
::
|
||||
|
||||
SDL2_TTF_LIBRARIES, the name of the library to link against
|
||||
SDL2_TTF_INCLUDE_DIRS, where to find the headers
|
||||
SDL2_TTF_FOUND, if false, do not try to link against
|
||||
SDL2_TTF_VERSION_STRING - human-readable string containing the
|
||||
version of SDL2_ttf
|
||||
|
||||
|
||||
|
||||
This module responds to the following cache variables:
|
||||
|
||||
::
|
||||
|
||||
SDL2_TTF_PATH
|
||||
Set a custom SDL2_ttf Library path (default: empty)
|
||||
|
||||
SDL2_TTF_NO_DEFAULT_PATH
|
||||
Disable search SDL2_ttf Library in default path.
|
||||
If SDL2_TTF_PATH (default: ON)
|
||||
Else (default: OFF)
|
||||
|
||||
SDL2_TTF_INCLUDE_DIR
|
||||
SDL2_ttf headers path.
|
||||
|
||||
SDL2_TTF_LIBRARY
|
||||
SDL2_ttf Library (.dll, .so, .a, etc) path.
|
||||
|
||||
|
||||
Additional Note: If you see an empty SDL2_TTF_LIBRARY in your project
|
||||
configuration, it means CMake did not find your SDL2_ttf library
|
||||
(SDL2_ttf.dll, libsdl2_ttf.so, etc). Set SDL2_TTF_LIBRARY to point
|
||||
to your SDL2_ttf library, and configure again. This value is used to
|
||||
generate the final SDL2_TTF_LIBRARIES variable and the SDL2::TTF target,
|
||||
but when this value is unset, SDL2_TTF_LIBRARIES and SDL2::TTF does not
|
||||
get created.
|
||||
|
||||
|
||||
$SDL2TTFDIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2TTFDIR used in building SDL2_ttf.
|
||||
|
||||
$SDL2DIR is an environment variable that would correspond to the
|
||||
./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
|
||||
|
||||
|
||||
Created by Amine Ben Hassouna:
|
||||
Adapt FindSDL_ttf.cmake to SDL2_ttf (FindSDL2_ttf.cmake).
|
||||
Add cache variables for more flexibility:
|
||||
SDL2_TTF_PATH, SDL2_TTF_NO_DEFAULT_PATH (for details, see doc above).
|
||||
Add SDL2 as a required dependency.
|
||||
Modernize the FindSDL2_ttf.cmake module by creating a specific target:
|
||||
SDL2::TTF (for details, see doc above).
|
||||
|
||||
Original FindSDL_ttf.cmake module:
|
||||
Created by Eric Wing. This was influenced by the FindSDL.cmake
|
||||
module, but with modifications to recognize OS X frameworks and
|
||||
additional Unix paths (FreeBSD, etc).
|
||||
#]=======================================================================]
|
||||
|
||||
# SDL2 Library required
|
||||
find_package(SDL2 QUIET)
|
||||
if(NOT SDL2_FOUND)
|
||||
set(SDL2_TTF_SDL2_NOT_FOUND "Could NOT find SDL2 (SDL2 is required by SDL2_ttf).")
|
||||
if(SDL2_ttf_FIND_REQUIRED)
|
||||
message(FATAL_ERROR ${SDL2_TTF_SDL2_NOT_FOUND})
|
||||
else()
|
||||
if(NOT SDL2_ttf_FIND_QUIETLY)
|
||||
message(STATUS ${SDL2_TTF_SDL2_NOT_FOUND})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
unset(SDL2_TTF_SDL2_NOT_FOUND)
|
||||
endif()
|
||||
|
||||
|
||||
# Define options for searching SDL2_ttf Library in a custom path
|
||||
|
||||
set(SDL2_TTF_PATH "" CACHE STRING "Custom SDL2_ttf Library path")
|
||||
|
||||
set(_SDL2_TTF_NO_DEFAULT_PATH OFF)
|
||||
if(SDL2_TTF_PATH)
|
||||
set(_SDL2_TTF_NO_DEFAULT_PATH ON)
|
||||
endif()
|
||||
|
||||
set(SDL2_TTF_NO_DEFAULT_PATH ${_SDL2_TTF_NO_DEFAULT_PATH}
|
||||
CACHE BOOL "Disable search SDL2_ttf Library in default path")
|
||||
unset(_SDL2_TTF_NO_DEFAULT_PATH)
|
||||
|
||||
set(SDL2_TTF_NO_DEFAULT_PATH_CMD)
|
||||
if(SDL2_TTF_NO_DEFAULT_PATH)
|
||||
set(SDL2_TTF_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_ttf include directory
|
||||
find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
|
||||
HINTS
|
||||
${_SDL2_TTF_INCLUDEDIR}
|
||||
ENV SDL2TTFDIR
|
||||
ENV SDL2DIR
|
||||
PATH_SUFFIXES
|
||||
SDL2
|
||||
include/SDL2
|
||||
include
|
||||
${SDL2_TTF_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
# and ENV{SDL2TTFDIR}
|
||||
include/SDL2 include
|
||||
PATHS ${SDL2_TTF_PATH}
|
||||
DOC "Where the SDL2_ttf headers can be found"
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
@ -60,19 +164,20 @@ else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# Search for the SDL2_ttf library
|
||||
find_library(SDL2_TTF_LIBRARY
|
||||
NAMES
|
||||
SDL2_ttf
|
||||
NAMES SDL2_ttf
|
||||
HINTS
|
||||
${_SDL2_TTF_LIBDIR}
|
||||
ENV SDL2TTFDIR
|
||||
ENV SDL2DIR
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
${VC_LIB_PATH_SUFFIX}
|
||||
${SDL2_TTF_NO_DEFAULT_PATH_CMD}
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS ${SDL2_TTF_PATH}
|
||||
DOC "Where the SDL2_ttf Library can be found"
|
||||
)
|
||||
|
||||
if(SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" AND NOT SDL2_TTF_VERSION_STRING)
|
||||
# Read SDL2_ttf version
|
||||
if(SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h")
|
||||
file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
@ -97,4 +202,21 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
|
||||
REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_TTF_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(SDL2_TTF_PATH
|
||||
SDL2_TTF_NO_DEFAULT_PATH
|
||||
SDL2_TTF_LIBRARY
|
||||
SDL2_TTF_INCLUDE_DIR)
|
||||
|
||||
|
||||
if(SDL2_TTF_FOUND)
|
||||
|
||||
# SDL2::TTF target
|
||||
if(SDL2_TTF_LIBRARY AND NOT TARGET SDL2::TTF)
|
||||
add_library(SDL2::TTF UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::TTF PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_TTF_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_TTF_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES SDL2::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -3,7 +3,7 @@
|
||||
# find_package(TBB
|
||||
# [REQUIRED] # Fail with error if TBB is not found
|
||||
# ) #
|
||||
# Once done, this will define
|
||||
# Once done, this will define
|
||||
#
|
||||
# TBB_FOUND - system has TBB
|
||||
# TBB_INCLUDE_DIRS - the TBB include directories
|
||||
@ -67,38 +67,29 @@
|
||||
#=============================================================================
|
||||
# FindTBB helper functions and macros
|
||||
#
|
||||
message("** Looking for TBB...")
|
||||
|
||||
# Use TBBConfig.cmake if possible.
|
||||
set(_tbb_find_quiet)
|
||||
|
||||
set(_tbb_find_quiet)
|
||||
if (TBB_FIND_QUIETLY)
|
||||
set(_tbb_find_quiet QUIET)
|
||||
endif ()
|
||||
|
||||
set(_tbb_find_components)
|
||||
set(_tbb_find_optional_components)
|
||||
|
||||
foreach (_tbb_find_component IN LISTS TBB_FIND_COMPONENTS)
|
||||
if (TBB_FIND_REQUIRED_${_tbb_find_component})
|
||||
list(APPEND _tbb_find_components "${_tbb_find_component}")
|
||||
list(APPEND _tbb_find_components "${_tbb_find_component}")
|
||||
else ()
|
||||
list(APPEND _tbb_find_optional_components "${_tbb_find_component}")
|
||||
list(APPEND _tbb_find_optional_components "${_tbb_find_component}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
unset(_tbb_find_component)
|
||||
|
||||
find_package(TBB CONFIG ${_tbb_find_quiet}
|
||||
COMPONENTS ${_tbb_find_components}
|
||||
OPTIONAL_COMPONENTS ${_tbb_find_optional_components})
|
||||
|
||||
unset(_tbb_find_quiet)
|
||||
unset(_tbb_find_components)
|
||||
unset(_tbb_find_optional_components)
|
||||
|
||||
set(TBB_LIBRARIES ${TBB_IMPORTED_TARGETS})
|
||||
|
||||
if (TBB_FOUND)
|
||||
return ()
|
||||
endif ()
|
||||
@ -373,7 +364,7 @@ get_debug_names(TBB_LIBRARY_NAMES)
|
||||
|
||||
|
||||
find_path(TBB_INCLUDE_DIR
|
||||
NAMES tbb/tbb_stddef.h
|
||||
NAMES tbb/tbb.h
|
||||
PATHS ${TBB_INC_SEARCH_PATH})
|
||||
|
||||
find_library(TBB_LIBRARY_RELEASE
|
||||
@ -462,4 +453,4 @@ if(NOT TBB_VERSION)
|
||||
".*#define TBB_COMPATIBLE_INTERFACE_VERSION ([0-9]+).*" "\\1"
|
||||
TBB_COMPATIBLE_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}")
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
196
cmake_modules/Findffmpeg.cmake
Normal file
196
cmake_modules/Findffmpeg.cmake
Normal file
@ -0,0 +1,196 @@
|
||||
|
||||
#[==[
|
||||
Provides the following variables:
|
||||
|
||||
* `ffmpeg_INCLUDE_DIRS`: Include directories necessary to use FFMPEG.
|
||||
* `ffmpeg_LIBRARIES`: Libraries necessary to use FFMPEG. Note that this only
|
||||
includes libraries for the components requested.
|
||||
* `ffmpeg_VERSION`: The version of FFMPEG found.
|
||||
|
||||
The following components are supported:
|
||||
|
||||
* `avcodec`
|
||||
* `avdevice`
|
||||
* `avfilter`
|
||||
* `avformat`
|
||||
* `avresample`
|
||||
* `avutil`
|
||||
* `swresample`
|
||||
* `swscale`
|
||||
|
||||
For each component, the following are provided:
|
||||
|
||||
* `ffmpeg_<component>_FOUND`: Libraries for the component.
|
||||
* `ffmpeg_<component>_INCLUDE_DIRS`: Include directories for
|
||||
the component.
|
||||
* `ffmpeg_<component>_LIBRARIES`: Libraries for the component.
|
||||
* `ffmpeg::<component>`: A target to use with `target_link_libraries`.
|
||||
|
||||
Note that only components requested with `COMPONENTS` or `OPTIONAL_COMPONENTS`
|
||||
are guaranteed to set these variables or provide targets.
|
||||
#]==]
|
||||
|
||||
function (_ffmpeg_find component headername)
|
||||
find_path("ffmpeg_${component}_INCLUDE_DIR"
|
||||
NAMES
|
||||
"lib${component}/${headername}"
|
||||
PATHS
|
||||
"${ffmpeg_ROOT}/include"
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
/sw/include # Fink
|
||||
/opt/local/include # DarwinPorts
|
||||
/opt/csw/include # Blastwave
|
||||
/opt/include
|
||||
/usr/freeware/include
|
||||
PATH_SUFFIXES
|
||||
ffmpeg
|
||||
DOC "FFMPEG's ${component} include directory")
|
||||
mark_as_advanced("ffmpeg_${component}_INCLUDE_DIR")
|
||||
|
||||
# On Windows, static FFMPEG is sometimes built as `lib<name>.a`.
|
||||
if (WIN32)
|
||||
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib")
|
||||
list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib")
|
||||
endif ()
|
||||
|
||||
find_library("ffmpeg_${component}_LIBRARY"
|
||||
NAMES
|
||||
"${component}"
|
||||
PATHS
|
||||
"${ffmpeg_ROOT}/lib"
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
/usr/freeware/lib64
|
||||
"${ffmpeg_ROOT}/bin"
|
||||
DOC "FFMPEG's ${component} library")
|
||||
mark_as_advanced("ffmpeg_${component}_LIBRARY")
|
||||
|
||||
if (ffmpeg_${component}_LIBRARY AND ffmpeg_${component}_INCLUDE_DIR)
|
||||
set(_deps_found TRUE)
|
||||
set(_deps_link)
|
||||
foreach (_ffmpeg_dep IN LISTS ARGN)
|
||||
if (TARGET "ffmpeg::${_ffmpeg_dep}")
|
||||
list(APPEND _deps_link "ffmpeg::${_ffmpeg_dep}")
|
||||
else ()
|
||||
set(_deps_found FALSE)
|
||||
endif ()
|
||||
endforeach ()
|
||||
if (_deps_found)
|
||||
if (NOT TARGET "ffmpeg::${component}")
|
||||
add_library("ffmpeg::${component}" UNKNOWN IMPORTED)
|
||||
set_target_properties("ffmpeg::${component}" PROPERTIES
|
||||
IMPORTED_LOCATION "${ffmpeg_${component}_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${ffmpeg_${component}_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES "${_deps_link}")
|
||||
endif ()
|
||||
set("ffmpeg_${component}_FOUND" 1
|
||||
PARENT_SCOPE)
|
||||
|
||||
set(version_header_path "${ffmpeg_${component}_INCLUDE_DIR}/lib${component}/version.h")
|
||||
if (EXISTS "${version_header_path}")
|
||||
string(TOUPPER "${component}" component_upper)
|
||||
file(STRINGS "${version_header_path}" version
|
||||
REGEX "#define *LIB${component_upper}_VERSION_(MAJOR|MINOR|MICRO) ")
|
||||
string(REGEX REPLACE ".*_MAJOR *\([0-9]*\).*" "\\1" major "${version}")
|
||||
string(REGEX REPLACE ".*_MINOR *\([0-9]*\).*" "\\1" minor "${version}")
|
||||
string(REGEX REPLACE ".*_MICRO *\([0-9]*\).*" "\\1" micro "${version}")
|
||||
if (NOT major STREQUAL "" AND
|
||||
NOT minor STREQUAL "" AND
|
||||
NOT micro STREQUAL "")
|
||||
set("ffmpeg_${component}_VERSION" "${major}.${minor}.${micro}"
|
||||
PARENT_SCOPE)
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
set("ffmpeg_${component}_FOUND" 0
|
||||
PARENT_SCOPE)
|
||||
set(what)
|
||||
if (NOT ffmpeg_${component}_LIBRARY)
|
||||
set(what "library")
|
||||
endif ()
|
||||
if (NOT ffmpeg_${component}_INCLUDE_DIR)
|
||||
if (what)
|
||||
string(APPEND what " or headers")
|
||||
else ()
|
||||
set(what "headers")
|
||||
endif ()
|
||||
endif ()
|
||||
set("ffmpeg_${component}_NOT_FOUND_MESSAGE"
|
||||
"Could not find the ${what} for ${component}."
|
||||
PARENT_SCOPE)
|
||||
endif ()
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
_ffmpeg_find(avutil avutil.h)
|
||||
_ffmpeg_find(avresample avresample.h
|
||||
avutil)
|
||||
_ffmpeg_find(swresample swresample.h
|
||||
avutil)
|
||||
_ffmpeg_find(swscale swscale.h
|
||||
avutil)
|
||||
_ffmpeg_find(avcodec avcodec.h
|
||||
avutil)
|
||||
_ffmpeg_find(avformat avformat.h
|
||||
avcodec avutil)
|
||||
_ffmpeg_find(avfilter avfilter.h
|
||||
avutil)
|
||||
_ffmpeg_find(avdevice avdevice.h
|
||||
avformat avutil)
|
||||
|
||||
if (TARGET ffmpeg::avutil)
|
||||
set(_ffmpeg_version_header_path "${ffmpeg_avutil_INCLUDE_DIR}/libavutil/ffversion.h")
|
||||
if (EXISTS "${_ffmpeg_version_header_path}")
|
||||
file(STRINGS "${_ffmpeg_version_header_path}" _ffmpeg_version
|
||||
REGEX "FFMPEG_VERSION")
|
||||
string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" ffmpeg_VERSION "${_ffmpeg_version}")
|
||||
unset(_ffmpeg_version)
|
||||
else ()
|
||||
set(ffmpeg_VERSION ffmpeg_VERSION-NOTFOUND)
|
||||
endif ()
|
||||
unset(_ffmpeg_version_header_path)
|
||||
endif ()
|
||||
|
||||
set(ffmpeg_INCLUDE_DIRS)
|
||||
set(ffmpeg_LIBRARIES)
|
||||
set(_ffmpeg_required_vars)
|
||||
foreach (_ffmpeg_component IN LISTS ffmpeg_FIND_COMPONENTS)
|
||||
if (TARGET "ffmpeg::${_ffmpeg_component}")
|
||||
set(ffmpeg_${_ffmpeg_component}_INCLUDE_DIRS
|
||||
"${ffmpeg_${_ffmpeg_component}_INCLUDE_DIR}")
|
||||
set(ffmpeg_${_ffmpeg_component}_LIBRARIES
|
||||
"${ffmpeg_${_ffmpeg_component}_LIBRARY}")
|
||||
list(APPEND ffmpeg_INCLUDE_DIRS
|
||||
"${ffmpeg_${_ffmpeg_component}_INCLUDE_DIRS}")
|
||||
list(APPEND ffmpeg_LIBRARIES
|
||||
"${ffmpeg_${_ffmpeg_component}_LIBRARIES}")
|
||||
if (FFMEG_FIND_REQUIRED_${_ffmpeg_component})
|
||||
list(APPEND _ffmpeg_required_vars
|
||||
"ffmpeg_${_ffmpeg_required_vars}_INCLUDE_DIRS"
|
||||
"ffmpeg_${_ffmpeg_required_vars}_LIBRARIES")
|
||||
endif ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
unset(_ffmpeg_component)
|
||||
|
||||
if (ffmpeg_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES ffmpeg_INCLUDE_DIRS)
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ffmpeg
|
||||
REQUIRED_VARS ffmpeg_INCLUDE_DIRS ffmpeg_LIBRARIES ${_ffmpeg_required_vars}
|
||||
VERSION_VAR ffmpeg_VERSION
|
||||
HANDLE_COMPONENTS)
|
||||
unset(_ffmpeg_required_vars)
|
@ -19,7 +19,7 @@
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_path(FL_INCLUDE_DIR
|
||||
find_path(fuzzylite_INCLUDE_DIR
|
||||
fl/fuzzylite.h
|
||||
HINTS
|
||||
ENV FLDIR
|
||||
@ -35,7 +35,7 @@ else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
find_library(FL_LIBRARY
|
||||
find_library(fuzzylite_LIBRARY
|
||||
NAMES
|
||||
fuzzylite
|
||||
HINTS
|
||||
@ -46,12 +46,20 @@ find_library(FL_LIBRARY
|
||||
${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
set(FL_LIBRARIES ${FL_LIBRARY})
|
||||
set(FL_INCLUDE_DIRS ${FL_INCLUDE_DIR})
|
||||
set(fuzzylite_LIBRARIES ${fuzzylite_LIBRARY})
|
||||
set(fuzzylite_INCLUDE_DIRS ${fuzzylite_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FL
|
||||
REQUIRED_VARS FL_LIBRARIES FL_INCLUDE_DIRS)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(fuzzylite
|
||||
REQUIRED_VARS fuzzylite_LIBRARIES fuzzylite_INCLUDE_DIRS)
|
||||
|
||||
mark_as_advanced(FL_LIBRARY FL_INCLUDE_DIR)
|
||||
if (NOT TARGET "fuzzylite::fuzzylite" AND fuzzylite_FOUND)
|
||||
add_library(fuzzylite::fuzzylite UNKNOWN IMPORTED)
|
||||
set_target_properties(fuzzylite::fuzzylite PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${fuzzylite_INCLUDE_DIR}")
|
||||
set_target_properties(fuzzylite::fuzzylite PROPERTIES
|
||||
IMPORTED_LOCATION "${fuzzylite_LIBRARY}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(fuzzylite_LIBRARY fuzzylite_INCLUDE_DIR)
|
58
cmake_modules/Findluajit.cmake
Normal file
58
cmake_modules/Findluajit.cmake
Normal file
@ -0,0 +1,58 @@
|
||||
# Locate LuaJIT library
|
||||
# This module defines
|
||||
# LUAJIT_FOUND, if false, do not try to link to Lua
|
||||
# luajit_INCLUDE_DIR, where to find lua.h
|
||||
# luajit_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||
#
|
||||
# This module is similar to FindLua51.cmake except that it finds LuaJit instead.
|
||||
|
||||
FIND_PATH(luajit_INCLUDE_DIR luajit.h
|
||||
HINTS
|
||||
$ENV{luajit_DIR}
|
||||
PATH_SUFFIXES include/luajit include/luajit-2.1 include/luajit-2.0 include/luajit-5_1-2.1 include/luajit-5_1-2.0 include
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
)
|
||||
|
||||
FIND_LIBRARY(luajit_LIBRARY
|
||||
NAMES luajit-5.1 lua51
|
||||
HINTS
|
||||
$ENV{luajit_DIR}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
|
||||
IF(luajit_INCLUDE_DIR AND EXISTS "${luajit_INCLUDE_DIR}/luajit.h")
|
||||
FILE(STRINGS "${luajit_INCLUDE_DIR}/luajit.h" luajit_version_str REGEX "^#define[ \t]+luajit_RELEASE[ \t]+\"LuaJIT .+\"")
|
||||
|
||||
STRING(REGEX REPLACE "^#define[ \t]+luajit_RELEASE[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" luajit_VERSION_STRING "${luajit_version_str}")
|
||||
UNSET(luajit_version_str)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(luajit
|
||||
REQUIRED_VARS luajit_LIBRARY luajit_INCLUDE_DIR
|
||||
VERSION_VAR luajit_VERSION_STRING)
|
||||
|
||||
if (NOT TARGET "luajit::luajit" AND luajit_FOUND)
|
||||
add_library(luajit::luajit UNKNOWN IMPORTED)
|
||||
set_target_properties(luajit::luajit PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${luajit_INCLUDE_DIR}")
|
||||
set_target_properties(luajit::luajit PROPERTIES
|
||||
IMPORTED_LOCATION "${luajit_LIBRARY}")
|
||||
endif()
|
||||
|
||||
MARK_AS_ADVANCED(luajit_INCLUDE_DIR luajit_LIBRARY)
|
@ -8,10 +8,10 @@
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# MINIZIP_LIBRARY, the name of the library to link against
|
||||
# MINIZIP_FOUND, if false, do not try to link to Minizip
|
||||
# MINIZIP_INCLUDE_DIR, where to find unzip.h
|
||||
# MINIZIP_VERSION_STRING, human-readable string containing the version of Minizip
|
||||
# minizip_LIBRARY, the name of the library to link against
|
||||
# minizip_FOUND, if false, do not try to link to Minizip
|
||||
# minizip_INCLUDE_DIR, where to find unzip.h
|
||||
# minizip_VERSION_STRING, human-readable string containing the version of Minizip
|
||||
#
|
||||
#=============================================================================
|
||||
# Copyright 2003-2009 Kitware, Inc.
|
||||
@ -37,36 +37,44 @@ if (NOT WIN32)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(_MINIZIP minizip)
|
||||
set(MINIZIP_VERSION_STRING ${_MINIZIP_VERSION})
|
||||
set(minizip_VERSION_STRING ${_minizip_VERSION})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
find_path(MINIZIP_INCLUDE_DIR
|
||||
find_path(minizip_INCLUDE_DIR
|
||||
minizip/unzip.h
|
||||
HINTS
|
||||
${_MINIZIP_INCLUDEDIR}
|
||||
${_minizip_INCLUDEDIR}
|
||||
ENV MINIZIPDIR
|
||||
PATH_SUFFIXES
|
||||
MINIZIP
|
||||
include
|
||||
)
|
||||
|
||||
find_library(MINIZIP_LIBRARY
|
||||
find_library(minizip_LIBRARY
|
||||
NAMES
|
||||
minizip
|
||||
HINTS
|
||||
${_MINIZIP_LIBDIR}
|
||||
${_minizip_LIBDIR}
|
||||
ENV MINIZIPDIR
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
set(MINIZIP_LIBRARIES ${MINIZIP_LIBRARY})
|
||||
set(MINIZIP_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIR})
|
||||
set(minizip_LIBRARIES ${minizip_LIBRARY})
|
||||
set(minizip_INCLUDE_DIRS ${minizip_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MINIZIP
|
||||
REQUIRED_VARS MINIZIP_LIBRARY MINIZIP_INCLUDE_DIR
|
||||
VERSION_VAR MINIZIP_VERSION_STRING)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(minizip
|
||||
REQUIRED_VARS minizip_LIBRARY minizip_INCLUDE_DIR
|
||||
VERSION_VAR minizip_VERSION_STRING)
|
||||
|
||||
if (NOT TARGET "minizip::minizip" AND minizip_FOUND)
|
||||
add_library(minizip::minizip UNKNOWN IMPORTED)
|
||||
set_target_properties(minizip::minizip PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${minizip_INCLUDE_DIR}")
|
||||
set_target_properties(minizip::minizip PROPERTIES
|
||||
IMPORTED_LOCATION "${minizip_LIBRARY}")
|
||||
endif()
|
@ -124,3 +124,13 @@ function(vcmi_print_git_commit_hash)
|
||||
message(STATUS "-- -- End of Git information")
|
||||
|
||||
endfunction()
|
||||
|
||||
#install imported target on windows
|
||||
function(install_vcpkg_imported_tgt tgt)
|
||||
get_target_property(TGT_LIB_LOCATION ${tgt} LOCATION)
|
||||
get_filename_component(TGT_LIB_FOLDER ${TGT_LIB_LOCATION} PATH)
|
||||
get_filename_component(tgt_name ${TGT_LIB_LOCATION} NAME_WE)
|
||||
get_filename_component(TGT_DLL ${TGT_LIB_FOLDER}/../bin/${tgt_name}.dll ABSOLUTE)
|
||||
message("${tgt_name}: ${TGT_DLL}")
|
||||
install(FILES ${TGT_DLL} DESTINATION ${BIN_DIR})
|
||||
endfunction(install_vcpkg_imported_tgt)
|
||||
|
@ -101,8 +101,6 @@ endif()
|
||||
target_link_libraries(vcmilauncher vcmi Qt5::Widgets Qt5::Network)
|
||||
target_include_directories(vcmilauncher
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${Qt5Widgets_INCLUDE_DIRS}
|
||||
PRIVATE ${Qt5Network_INCLUDE_DIRS}
|
||||
)
|
||||
vcmi_set_output_dir(vcmilauncher "")
|
||||
|
||||
|
@ -398,17 +398,14 @@ assign_source_group(${lib_SRCS} ${lib_HEADERS})
|
||||
add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS})
|
||||
set_target_properties(vcmi PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1")
|
||||
target_link_libraries(vcmi PUBLIC
|
||||
${MINIZIP_LIBRARIES} ${SDL2_LIBRARY} ${ZLIB_LIBRARIES}
|
||||
${SYSTEM_LIBS} ${Boost_LIBRARIES}
|
||||
minizip::minizip SDL2::SDL2 ZLIB::ZLIB
|
||||
${SYSTEM_LIBS} Boost::boost Boost::thread Boost::filesystem Boost::program_options Boost::locale Boost::date_time
|
||||
)
|
||||
|
||||
target_include_directories(vcmi
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PUBLIC ${CMAKE_HOME_DIRECTORY}
|
||||
PUBLIC ${CMAKE_HOME_DIRECTORY}/include
|
||||
PUBLIC ${Boost_INCLUDE_DIRS}
|
||||
PUBLIC ${ZLIB_INCLUDE_DIR}
|
||||
PRIVATE ${SDL2_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
|
@ -74,11 +74,7 @@ if(WIN32)
|
||||
|
||||
#TODO: check if some equivalent of block below can be used for above block (easy qt dependencies copy)
|
||||
if(ENABLE_LUA)
|
||||
if(EXISTS ${LUA_INCLUDE_DIR}/../../bin/lua51.dll)
|
||||
install(CODE "
|
||||
file(COPY ${LUA_INCLUDE_DIR}/../../bin/lua51.dll DESTINATION \${CMAKE_INSTALL_PREFIX})
|
||||
")
|
||||
endif()
|
||||
install_vcpkg_imported_tgt(luajit::luajit)
|
||||
endif()
|
||||
|
||||
#LuaJIT will not be copied automatically by not meeting criteria for this block of code
|
||||
|
@ -15,7 +15,7 @@ set(lib_HDRS
|
||||
)
|
||||
|
||||
add_library(vcmiERM SHARED ${lib_SRCS} ${lib_HDRS})
|
||||
target_link_libraries(vcmiERM ${Boost_LIBRARIES} vcmi)
|
||||
target_link_libraries(vcmiERM Boost::boost vcmi)
|
||||
|
||||
vcmi_set_output_dir(vcmiERM "scripting")
|
||||
|
||||
|
@ -40,7 +40,7 @@ set(lib_SRCS
|
||||
)
|
||||
|
||||
add_library(vcmiLua SHARED ${lib_SRCS})
|
||||
target_link_libraries(vcmiLua ${Boost_LIBRARIES} ${LUA_LIBRARY} vcmi)
|
||||
target_link_libraries(vcmiLua Boost::boost luajit::luajit vcmi)
|
||||
|
||||
vcmi_set_output_dir(vcmiLua "scripting")
|
||||
|
||||
|
@ -28,7 +28,7 @@ set(server_LIBS vcmi)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
|
||||
set(server_LIBS execinfo ${server_LIBS})
|
||||
endif()
|
||||
target_link_libraries(vcmiserver PRIVATE ${server_LIBS})
|
||||
target_link_libraries(vcmiserver PRIVATE ${server_LIBS} minizip::minizip)
|
||||
|
||||
target_include_directories(vcmiserver
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
Loading…
Reference in New Issue
Block a user