Get vcpkg-based build working on macOS
Use the following command: cmake -G Ninja .. -D CMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake
This commit is contained in:
parent
1e921f1b0b
commit
bd1ea7feb5
116
CMakeLists.txt
116
CMakeLists.txt
@ -9,49 +9,75 @@ set(OPENSPADES_FULL_VERSION "${OpenSpades_VERSION_MAJOR}.${OpenSpades_VERSION_MI
|
||||
|
||||
set(OS_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
set(CMAKE_PREFIX_PATH Sources/Externals)
|
||||
if(VCPKG_TARGET_TRIPLET)
|
||||
set(USE_VCPKG ON)
|
||||
set(CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/vcpkg/installed/${VCPKG_TARGET_TRIPLET}/lib")
|
||||
else()
|
||||
set(USE_VCPKG OFF)
|
||||
set(CMAKE_PREFIX_PATH Sources/Externals)
|
||||
endif()
|
||||
|
||||
# Prefer GLVND OpenGL
|
||||
if(POLICY CMP0072)
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
|
||||
include(cmake/FindSDL2.cmake)
|
||||
if(NOT SDL2_FOUND)
|
||||
message(FATAL_ERROR "SDL 2.0 not found, set ENV{SDL2DIR} to point to SDL 2.0, and optionally set the cmake var SDL2_LIBRARY_TEMP to the lib dir")
|
||||
endif()
|
||||
if(USE_VCPKG)
|
||||
find_package(Ogg CONFIG REQUIRED)
|
||||
find_package(Opus CONFIG REQUIRED)
|
||||
find_package(sdl2-image CONFIG REQUIRED)
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
find_package(freetype CONFIG REQUIRED)
|
||||
|
||||
include(cmake/FindSDL2_image.cmake)
|
||||
if(NOT SDL2_IMAGE_FOUND)
|
||||
message(FATAL_ERROR "SDL_image 2.0 not found, set ENV{SDL2DIR} to point to SDL 2.0, and optionally set the cmake var SDL2_LIBRARY_TEMP to the lib dir")
|
||||
endif()
|
||||
set(SDL2_LIBRARY SDL2::SDL2main SDL2::SDL2-static)
|
||||
set(SDL2_IMAGE_LIBRARY SDL2::SDL2_image)
|
||||
set(FREETYPE_LIBRARIES freetype)
|
||||
|
||||
include(FindOpenGL)
|
||||
if(NOT OPENGL_FOUND AND NOT OPENGL_XMESA_FOUND AND NOT OPENGL_GLU_FOUND)
|
||||
message(FATAL_ERROR "OpenGL not found, please install it")
|
||||
endif()
|
||||
if(NOT APPLE)
|
||||
include(cmake/FindGLEW2.cmake)
|
||||
if(NOT GLEW_FOUND)
|
||||
message(FATAL_ERROR "GLEW not found, please install it and make sure CMake can find it (add it to the PATH)")
|
||||
if(APPLE)
|
||||
# Use system libraries
|
||||
include(FindOpenGL)
|
||||
include(FindCURL)
|
||||
endif()
|
||||
else()
|
||||
include(cmake/FindSDL2.cmake)
|
||||
if(NOT SDL2_FOUND)
|
||||
message(FATAL_ERROR "SDL 2.0 not found, set ENV{SDL2DIR} to point to SDL 2.0, and optionally set the cmake var SDL2_LIBRARY_TEMP to the lib dir")
|
||||
endif()
|
||||
|
||||
include(cmake/FindSDL2_image.cmake)
|
||||
if(NOT SDL2_IMAGE_FOUND)
|
||||
message(FATAL_ERROR "SDL_image 2.0 not found, set ENV{SDL2DIR} to point to SDL 2.0, and optionally set the cmake var SDL2_LIBRARY_TEMP to the lib dir")
|
||||
endif()
|
||||
|
||||
include(FindOpenGL)
|
||||
if(NOT OPENGL_FOUND AND NOT OPENGL_XMESA_FOUND AND NOT OPENGL_GLU_FOUND)
|
||||
message(FATAL_ERROR "OpenGL not found, please install it")
|
||||
endif()
|
||||
if(NOT APPLE)
|
||||
include(cmake/FindGLEW2.cmake)
|
||||
if(NOT GLEW_FOUND)
|
||||
message(FATAL_ERROR "GLEW not found, please install it and make sure CMake can find it (add it to the PATH)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindZLIB)
|
||||
if(NOT ZLIB_FOUND)
|
||||
message(FATAL_ERROR "ZLIB not found, manually set ZLIB_ROOT in CMake")
|
||||
endif()
|
||||
|
||||
include(FindCURL)
|
||||
if(NOT CURL_FOUND)
|
||||
message(FATAL_ERROR "cURL not found, please install it (and make sure it's in your path)")
|
||||
endif()
|
||||
|
||||
include(FindFreetype)
|
||||
if(NOT FREETYPE_FOUND)
|
||||
message(FATAL_ERROR "FreeType not found, please install it (and make sure it's in your path)")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
include(FindZLIB)
|
||||
if(NOT ZLIB_FOUND)
|
||||
message(FATAL_ERROR "ZLIB not found, manually set ZLIB_ROOT in CMake")
|
||||
endif()
|
||||
|
||||
include(FindCURL)
|
||||
if(NOT CURL_FOUND)
|
||||
message(FATAL_ERROR "cURL not found, please install it (and make sure it's in your path)")
|
||||
endif()
|
||||
|
||||
include(FindFreetype)
|
||||
if(NOT FREETYPE_FOUND)
|
||||
message(FATAL_ERROR "FreeType not found, please install it (and make sure it's in your path)")
|
||||
endif()
|
||||
|
||||
# vcpkg's opusfile port doesn't provide a CMake config for opusfile
|
||||
include(cmake/FindOpus.cmake)
|
||||
if(NOT OpusFile_FOUND)
|
||||
message(FATAL_ERROR "libopus/libopusfile not found, please install it (and make sure it's in your path)")
|
||||
@ -193,18 +219,22 @@ endif()
|
||||
configure_file("${PROJECT_SOURCE_DIR}/OpenSpades.h.in" "${PROJECT_BINARY_DIR}/OpenSpades.h")
|
||||
configure_file("${PROJECT_SOURCE_DIR}/OpenSpades.rc.in" "${PROJECT_BINARY_DIR}/OpenSpades.rc")
|
||||
include_directories(BEFORE "${PROJECT_BINARY_DIR}")
|
||||
include_directories("${SDL2_INCLUDE_DIR}")
|
||||
include_directories("${SDL2_IMAGE_INCLUDE_DIR}")
|
||||
if(OPENGL_INCLUDE_DIR)
|
||||
include_directories("${OPENGL_INCLUDE_DIR}")
|
||||
if(USE_VCPKG)
|
||||
include_directories("${PROJECT_SOURCE_DIR}/vcpkg/installed/${VCPKG_TARGET_TRIPLET}/include")
|
||||
else()
|
||||
include_directories("${SDL2_INCLUDE_DIR}")
|
||||
include_directories("${SDL2_IMAGE_INCLUDE_DIR}")
|
||||
if(OPENGL_INCLUDE_DIR)
|
||||
include_directories("${OPENGL_INCLUDE_DIR}")
|
||||
endif()
|
||||
if(NOT APPLE)
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
endif()
|
||||
include_directories("${ZLIB_INCLUDE_DIR}")
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
include_directories(${FREETYPE_INCLUDE_DIRS})
|
||||
include_directories(${OpusFile_INCLUDE_DIR})
|
||||
endif()
|
||||
if(NOT APPLE)
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
endif()
|
||||
include_directories("${ZLIB_INCLUDE_DIR}")
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
include_directories(${FREETYPE_INCLUDE_DIRS})
|
||||
include_directories(${OpusFile_INCLUDE_DIR})
|
||||
|
||||
add_subdirectory(Resources)
|
||||
add_subdirectory(Sources)
|
||||
|
@ -101,6 +101,9 @@ target_link_libraries(OpenSpades ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${OPENGL_
|
||||
if(NOT APPLE)
|
||||
target_link_libraries(OpenSpades ${GLEW_LIBRARY})
|
||||
endif()
|
||||
if(USE_VCPKG)
|
||||
target_link_libraries(OpenSpades Ogg::ogg Opus::opus)
|
||||
endif()
|
||||
|
||||
#todo: MACOSX_BUNDLE_ICON_FILE ?
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include <opusfile.h>
|
||||
#include <opus/opusfile.h>
|
||||
|
||||
#include "OpusAudioStream.h"
|
||||
|
||||
|
6
vcpkg_x86_64-darwin.txt
Normal file
6
vcpkg_x86_64-darwin.txt
Normal file
@ -0,0 +1,6 @@
|
||||
freetype
|
||||
opusfile
|
||||
opus
|
||||
libogg
|
||||
sdl2
|
||||
sdl2-image
|
Loading…
x
Reference in New Issue
Block a user