Skip to content

Commit

Permalink
CMake fixes + CMake search for OpenSSL (macOS) (microsoft#1383)
Browse files Browse the repository at this point in the history
Signed-off-by: Clovis Durand <[email protected]>
Co-authored-by: Billy Robert O'Neal III <[email protected]>
  • Loading branch information
Clovel and BillyONeal authored Apr 24, 2020
1 parent b07011d commit 319dd31
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 94 deletions.
2 changes: 1 addition & 1 deletion Build_iOS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(casablanca-ios NONE)
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9)

enable_testing()

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9)
project(cpprestsdk-root NONE)
enable_testing()
add_subdirectory(Release)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Release/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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()
Expand Down
4 changes: 3 additions & 1 deletion Release/cmake/cpprest_find_openssl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions Release/cmake/cpprestsdk-config-version.in.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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)
2 changes: 1 addition & 1 deletion Release/cmake/cpprestsdk-config.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 5 additions & 4 deletions Release/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 0 additions & 5 deletions azure-devops/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
162 changes: 83 additions & 79 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 319dd31

Please sign in to comment.