未验证 提交 319dd31f 编写于 作者: C Clovis Durand 提交者: GitHub

CMake fixes + CMake search for OpenSSL (macOS) (#1383)

Signed-off-by: NClovis Durand <cd.clovel19@gmail.com>
Co-authored-by: NBilly Robert O'Neal III <bion@microsoft.com>
上级 b07011d3
project(casablanca-ios NONE)
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9)
enable_testing()
......
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9)
project(cpprestsdk-root NONE)
enable_testing()
add_subdirectory(Release)
......@@ -39,7 +39,7 @@ Once you have the library, look at our [tutorial](https://github.com/Microsoft/c
To use from CMake:
```cmake
cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.9)
project(main)
find_package(cpprestsdk REQUIRED)
......
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW) # use MACOSX_RPATH
endif()
......
......@@ -34,11 +34,13 @@ function(cpprest_find_openssl)
if(APPLE)
if(NOT DEFINED OPENSSL_ROOT_DIR)
# Prefer a homebrew version of OpenSSL over the one in /usr/lib
file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/*)
file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl*/*)
# Prefer the latest (make the latest one first)
list(REVERSE OPENSSL_ROOT_DIR)
list(GET OPENSSL_ROOT_DIR 0 OPENSSL_ROOT_DIR)
endif()
# This should prevent linking against the system provided 0.9.8y
message(STATUS "OPENSSL_ROOT_DIR = ${OPENSSL_ROOT_DIR}")
set(_OPENSSL_VERSION "")
endif()
if(UNIX)
......
set(PACKAGE_VERSION @CPPREST_VERSION_MAJOR@.@CPPREST_VERSION_MINOR@.@CPPREST_VERSION_REVISION@)
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
endif(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
......@@ -15,7 +15,7 @@ if(@CPPREST_USES_WINHTTPPAL@)
find_dependency(WINHTTPPAL)
endif()
if(@CPPREST_USES_BOOST@ AND OFF)
if(@CPPREST_USES_BOOST@)
if(UNIX)
find_dependency(Boost COMPONENTS random system thread filesystem chrono atomic date_time regex)
else()
......
......@@ -236,9 +236,9 @@ else()
endif()
if(CPPREST_INSTALL_HEADERS)
install(FILES ${HEADERS_CPPREST} DESTINATION include/cpprest)
install(FILES ${HEADERS_PPLX} DESTINATION include/pplx)
install(FILES ${HEADERS_DETAILS} DESTINATION include/cpprest/details)
install(FILES ${HEADERS_CPPREST} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpprest)
install(FILES ${HEADERS_PPLX} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pplx)
install(FILES ${HEADERS_DETAILS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpprest/details)
endif()
if(CPPREST_INSTALL)
......@@ -281,9 +281,10 @@ if(CPPREST_INSTALL)
)
configure_file(../cmake/cpprestsdk-config.in.cmake "${CMAKE_CURRENT_BINARY_DIR}/cpprestsdk-config.cmake" @ONLY)
configure_file(../cmake/cpprestsdk-config-version.in.cmake "${CMAKE_CURRENT_BINARY_DIR}/cpprestsdk-config-version.cmake" @ONLY)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/cpprestsdk-config.cmake"
FILES "${CMAKE_CURRENT_BINARY_DIR}/cpprestsdk-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cpprestsdk-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CPPREST_EXPORT_DIR}
)
install(
......
......@@ -13,11 +13,6 @@ jobs:
steps:
- script: git submodule update --init vcpkg
displayName: Checkout vcpkg submodule
- task: CacheBeta@0
displayName: Cache vcpkg
inputs:
key: $(vcpkgResponseFile) | $(Build.SourcesDirectory)/.git/modules/vcpkg/HEAD | ${{ parameters.targetPlatform }} | ${{ parameters.image }}
path: '$(vcpkgLocation)'
- task: run-vcpkg@0
displayName: 'Run vcpkg'
inputs:
......
......@@ -68,85 +68,89 @@ jobs:
export NCPU=2
../configure.sh --ndk /usr/local/lib/android/sdk/ndk-bundle
displayName: 'Build for Android'
# - job: MacOS_Homebrew
# pool:
# vmImage: 'macOS-latest'
# steps:
# - script: brew install boost openssl ninja
# displayName: Brew install dependencies
# - script: |
# mkdir build.debug
# mkdir build.release
# mkdir build.release.static
# displayName: Make Build Directories
# - task: CMake@1
# inputs:
# workingDirectory: 'build.debug'
# cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Debug ..'
# - task: CMake@1
# inputs:
# workingDirectory: 'build.release'
# cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release ..'
# - task: CMake@1
# inputs:
# workingDirectory: 'build.release.static'
# cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF ..'
# - script: |
# cd build.debug
# ninja
# displayName: 'Run ninja, debug'
# - script: |
# cd build.debug/Release/Binaries
# ./test_runner *test.dylib
# displayName: 'Run tests, debug'
# - script: |
# cd build.release
# ninja
# displayName: 'Run ninja, release'
# - script: |
# cd build.release/Release/Binaries
# ./test_runner *test.dylib
# displayName: 'Run tests, release'
# - script: |
# cd build.release.static
# ninja
# displayName: 'Run ninja, release static'
# - job: MacOS_Vcpkg
# pool:
# vmImage: 'macOS-latest'
# steps:
# - script: |
# ./vcpkg/bootstrap-vcpkg.sh
# ./vcpkg/vcpkg install zlib openssl boost-system boost-date-time boost-regex websocketpp boost-thread boost-filesystem boost-random boost-chrono boost-interprocess brotli --vcpkg-root ./vcpkg
# displayName: Vcpkg install dependencies
# - script: |
# mkdir build.debug
# mkdir build.release
# displayName: Make Build Directories
# - task: CMake@1
# inputs:
# workingDirectory: 'build.debug'
# cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake ..'
# - task: CMake@1
# inputs:
# workingDirectory: 'build.release'
# cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake ..'
# - script: |
# cd build.debug
# ninja
# displayName: 'Run ninja debug'
# - script: |
# cd build.debug/Release/Binaries
# ./test_runner *test.dylib
# displayName: 'Run Tests debug'
# - script: |
# cd build.release
# ninja
# displayName: 'Run ninja, release'
# - script: |
# cd build.release/Release/Binaries
# ./test_runner *test.dylib
# displayName: 'Run tests, release'
- job: MacOS_Homebrew
pool:
vmImage: 'macOS-latest'
steps:
- script: brew install boost openssl ninja
displayName: Brew install dependencies
- script: git submodule update --init Release/libs/websocketpp
displayName: Checkout websocketpp submodule
- script: |
mkdir build.debug
mkdir build.release
mkdir build.release.static
displayName: Make Build Directories
- task: CMake@1
inputs:
workingDirectory: 'build.debug'
cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Debug ..'
- task: CMake@1
inputs:
workingDirectory: 'build.release'
cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release ..'
- task: CMake@1
inputs:
workingDirectory: 'build.release.static'
cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF ..'
- script: |
cd build.debug
ninja
displayName: 'Run ninja, debug'
- script: |
cd build.debug/Release/Binaries
./test_runner *test.dylib
displayName: 'Run tests, debug'
- script: |
cd build.release
ninja
displayName: 'Run ninja, release'
- script: |
cd build.release/Release/Binaries
./test_runner *test.dylib
displayName: 'Run tests, release'
- script: |
cd build.release.static
ninja
displayName: 'Run ninja, release static'
- job: MacOS_Vcpkg
pool:
vmImage: 'macOS-latest'
steps:
- script: git submodule update --init vcpkg
displayName: Checkout vcpkg submodule
- script: |
./vcpkg/bootstrap-vcpkg.sh
./vcpkg/vcpkg install zlib openssl boost-system boost-date-time boost-regex websocketpp boost-thread boost-filesystem boost-random boost-chrono boost-interprocess brotli --vcpkg-root ./vcpkg
displayName: Vcpkg install dependencies
- script: |
mkdir build.debug
mkdir build.release
displayName: Make Build Directories
- task: CMake@1
inputs:
workingDirectory: 'build.debug'
cmakeArgs: '-G Ninja -DCMAKE_MAKE_PROGRAM=$(Build.SourcesDirectory)/vcpkg/downloads/tools/ninja-1.10.0-osx/ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake ..'
- task: CMake@1
inputs:
workingDirectory: 'build.release'
cmakeArgs: '-G Ninja -DCMAKE_MAKE_PROGRAM=$(Build.SourcesDirectory)/vcpkg/downloads/tools/ninja-1.10.0-osx/ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake ..'
- script: |
cd build.debug
$(Build.SourcesDirectory)/vcpkg/downloads/tools/ninja-1.10.0-osx/ninja
displayName: 'Run ninja debug'
- script: |
cd build.debug/Release/Binaries
./test_runner *test.dylib
displayName: 'Run Tests debug'
- script: |
cd build.release
$(Build.SourcesDirectory)/vcpkg/downloads/tools/ninja-1.10.0-osx/ninja
displayName: 'Run ninja, release'
- script: |
cd build.release/Release/Binaries
./test_runner *test.dylib
displayName: 'Run tests, release'
# - job: MacOS_iOS
# pool:
# vmImage: 'macOS-latest'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册