Skip to content

Commit

Permalink
Add cpprest as a submodule for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
kbenne committed Jan 31, 2019
1 parent 98e2fde commit 8db1b93
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 48 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "cpprestsdk"]
path = cpprestsdk
url = https://github.com/Microsoft/cpprestsdk.git
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,11 @@ endif()
option(BUILD_BOOST "Build Boost" OFF)
if(BUILD_BOOST)
if(APPLE)
set(apple-flags "-std=c17 -std=c++17 -stdlib=libc++")
ExternalProject_Add(Boost
URL http://openstudio-resources.s3.amazonaws.com/dependencies/boost_1_68_0.tar.gz
URL_MD5 5d8b4503582fffa9eefdb9045359c239
CONFIGURE_COMMAND cd ${CMAKE_BINARY_DIR}/Boost-prefix/src/Boost && ./bootstrap.sh
PATCH_COMMAND ${PATCH_EXE} -p1 < ${CMAKE_SOURCE_DIR}/dependencies/Boost/xcode_51.patch && ${PATCH_EXE} -p1 < ${CMAKE_SOURCE_DIR}/dependencies/Boost/fchmodat.patch
BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/Boost-prefix/src/Boost && ./b2 toolset=clang cxxflags=${apple-flags} linkflags=${apple-flags} variant=debug,release define=BOOST_CHRONO_HEADER_ONLY --layout=tagged --with-filesystem --with-regex --with-program_options --with-system --with-thread --with-date_time --with-log --prefix=${CMAKE_BINARY_DIR}/Boost-prefix/src/Boost-install -j${BOOST_CPUCOUNT} install
BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/Boost-prefix/src/Boost && ./b2 toolset=clang variant=debug,release define=BOOST_CHRONO_HEADER_ONLY --layout=tagged --with-filesystem --with-random --with-regex --with-program_options --with-system --with-thread --with-date_time --with-log --prefix=${CMAKE_BINARY_DIR}/Boost-prefix/src/Boost-install -j${BOOST_CPUCOUNT} install
INSTALL_COMMAND ""
)
set(BOOST_ROOT ${CMAKE_BINARY_DIR}/Boost-prefix/src/Boost-install)
Expand Down
1 change: 1 addition & 0 deletions cpprestsdk
Submodule cpprestsdk added at 8f0393
93 changes: 48 additions & 45 deletions openstudiocore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,14 @@ endif()
# Compiler and system specific options
if(UNIX)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC -fno-strict-aliasing")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC -fno-strict-aliasing")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fno-strict-aliasing")

# all warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -fno-strict-aliasing -Winvalid-pch -Wnon-virtual-dtor")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -fno-strict-aliasing -Winvalid-pch -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-strict-aliasing -Winvalid-pch")
# Treat all warnings as errors
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual -ftemplate-depth=1024")
else()
Expand Down Expand Up @@ -858,46 +860,6 @@ else()
endif()


# cpprestsdk
if(APPLE)
# TODO
elseif(UNIX)
set(CPPRESTSDK_ZIP "cpprestsdk-2.10.8-Linux-x86_64.tar.xz")
set(CPPRESTSDK_DIR "cpprestsdk-2.10.8-Linux-x86_64")
set(CPPRESTSDK_EXPECTED_HASH "866e8fa7ce1e507fcb19b0ab9b89399c")
if(EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}")
file(MD5 "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" CPPRESTSDK_HASH)
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" OR NOT EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}" OR NOT "${CPPRESTSDK_HASH}" MATCHES "${CPPRESTSDK_EXPECTED_HASH}")
message(STATUS "Downloading cpprestsdk)")
file(DOWNLOAD "http://openstudio-resources.s3.amazonaws.com/dependencies/${CPPRESTSDK_ZIP}" "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" TIMEOUT 120 INACTIVITY_TIMEOUT 120 SHOW_PROGRESS EXPECTED_MD5 ${CPPRESTSDK_EXPECTED_HASH})
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()
#find_package(cpprestsdk REQUIRED PATHS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/cpprestsdk")
set(CPPRESTSDK_INCLUDE_DIR "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/include")
include_directories(${CPPRESTSDK_INCLUDE_DIR})
set(CPPRESTSDK_LIB "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/libcpprest.a")
elseif(WIN32)
set(CPPRESTSDK_ZIP "cpprestsdk-2.10.8-win64.zip")
set(CPPRESTSDK_DIR "cpprestsdk-2.10.8-win64")
set(CPPRESTSDK_EXPECTED_HASH "467df76fa7c96fc3465a4b5f596361f8")
if(EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}")
file(MD5 "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" CPPRESTSDK_HASH)
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" OR NOT EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}" OR NOT "${CPPRESTSDK_HASH}" MATCHES "${CPPRESTSDK_EXPECTED_HASH}")
message(STATUS "Downloading cpprestsdk)")
file(DOWNLOAD "http://openstudio-resources.s3.amazonaws.com/dependencies/${CPPRESTSDK_ZIP}" "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" TIMEOUT 120 INACTIVITY_TIMEOUT 120 SHOW_PROGRESS EXPECTED_MD5 ${CPPRESTSDK_EXPECTED_HASH})
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()
#find_package(cpprestsdk REQUIRED PATHS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/cpprestsdk")
set(CPPRESTSDK_INCLUDE_DIR "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/include")
include_directories(${CPPRESTSDK_INCLUDE_DIR})
set(CPPRESTSDK_LIB_RELEASE "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/cpprest141_2_10.lib")
set(CPPRESTSDK_LIB_DEBUG "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/cpprest141_2_10d.lib")
endif()

set(ALL_RUBY_BINDING_TARGETS "") # global list

# build rdoc
Expand Down Expand Up @@ -1009,8 +971,8 @@ if(NOT EXISTS ${BOOST_INSTALL_DIR})
set(BOOST_ZIP_EXPECTED_MD5 "4ebc2a84ef13ef1853fcf3e6c27fc10c")
endif()
elseif(APPLE)
set(BOOST_ZIP_FILENAME "DOES_NOT_EXIST_boost_1_68_0_osx.tar.gz")
set(BOOST_ZIP_EXPECTED_MD5 "9e4c01a3f5c63e3bbf5cc76021eceb75")
set(BOOST_ZIP_FILENAME "boost_1_68_0_osx.tar.gz")
set(BOOST_ZIP_EXPECTED_MD5 "5bd1957658a14a12e0c0ba2f010c885b")
elseif(EXISTS "/etc/redhat-release")
set(BOOST_ZIP_FILENAME "DOES_NOT_EXIST_boost_1_68_0_redhat.tar.gz")
set(BOOST_ZIP_EXPECTED_MD5 "de952e0c36900a3ad000d74a1c41b7d2")
Expand Down Expand Up @@ -1051,6 +1013,47 @@ mark_as_advanced(
BOOST_THREAD_LIBRARY
)

# cpprestsdk
if(APPLE)
# TODO
add_subdirectory(../cpprestsdk cpprestsdk)
elseif(UNIX)
set(CPPRESTSDK_ZIP "cpprestsdk-2.10.8-Linux-x86_64.tar.xz")
set(CPPRESTSDK_DIR "cpprestsdk-2.10.8-Linux-x86_64")
set(CPPRESTSDK_EXPECTED_HASH "866e8fa7ce1e507fcb19b0ab9b89399c")
if(EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}")
file(MD5 "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" CPPRESTSDK_HASH)
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" OR NOT EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}" OR NOT "${CPPRESTSDK_HASH}" MATCHES "${CPPRESTSDK_EXPECTED_HASH}")
message(STATUS "Downloading cpprestsdk)")
file(DOWNLOAD "http://openstudio-resources.s3.amazonaws.com/dependencies/${CPPRESTSDK_ZIP}" "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" TIMEOUT 120 INACTIVITY_TIMEOUT 120 SHOW_PROGRESS EXPECTED_MD5 ${CPPRESTSDK_EXPECTED_HASH})
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()
#find_package(cpprestsdk REQUIRED PATHS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/cpprestsdk")
set(CPPRESTSDK_INCLUDE_DIR "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/include")
include_directories(${CPPRESTSDK_INCLUDE_DIR})
set(CPPRESTSDK_LIB "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/libcpprest.a")
elseif(WIN32)
set(CPPRESTSDK_ZIP "cpprestsdk-2.10.8-win64.zip")
set(CPPRESTSDK_DIR "cpprestsdk-2.10.8-win64")
set(CPPRESTSDK_EXPECTED_HASH "467df76fa7c96fc3465a4b5f596361f8")
if(EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}")
file(MD5 "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" CPPRESTSDK_HASH)
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" OR NOT EXISTS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}" OR NOT "${CPPRESTSDK_HASH}" MATCHES "${CPPRESTSDK_EXPECTED_HASH}")
message(STATUS "Downloading cpprestsdk)")
file(DOWNLOAD "http://openstudio-resources.s3.amazonaws.com/dependencies/${CPPRESTSDK_ZIP}" "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" TIMEOUT 120 INACTIVITY_TIMEOUT 120 SHOW_PROGRESS EXPECTED_MD5 ${CPPRESTSDK_EXPECTED_HASH})
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${CMAKE_BINARY_DIR}/${CPPRESTSDK_ZIP}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()
#find_package(cpprestsdk REQUIRED PATHS "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/cpprestsdk")
set(CPPRESTSDK_INCLUDE_DIR "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/include")
include_directories(${CPPRESTSDK_INCLUDE_DIR})
set(CPPRESTSDK_LIB_RELEASE "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/cpprest141_2_10.lib")
set(CPPRESTSDK_LIB_DEBUG "${CMAKE_BINARY_DIR}/${CPPRESTSDK_DIR}/lib/cpprest141_2_10d.lib")
endif()

# require these run time checks
add_definitions(-DBOOST_UBLAS_CHECK_ENABLE)
add_definitions(-DBOOST_UBLAS_TYPE_CHECK)
Expand Down

0 comments on commit 8db1b93

Please sign in to comment.