Initial commit.

This commit is contained in:
Mudit Vats
2020-06-01 13:22:04 -07:00
parent 5d000e3d53
commit c1987ceb38
12 changed files with 1519 additions and 1 deletions

131
CMakeLists.txt Normal file
View File

@@ -0,0 +1,131 @@
cmake_minimum_required (VERSION 3.1)
project (rpc VERSION 1.0.0)
set (CMAKE_CXX_STANDARD 11)
# RPC version info
configure_file(version.h.in
version.h)
include_directories(${PROJECT_BINARY_DIR})
# TODO: figure out how to read the LMS version from repo like the main lms CMakeLists.txt
set (LMS_VERSION_STRING 1932.0.0.0)
# Compiler settings [Obtained from CmakeLists.txt for lms]
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DDEBUG -D_DEBUG")
string(APPEND CMAKE_C_FLAGS_DEBUG " -DDEBUG -D_DEBUG")
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
if (UNIX)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
#CMake issue #14983
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
#Secure library usage and secure compile flags
add_definitions (-fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2 -Wformat -Wformat-security)
add_definitions (-fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv)
else (UNIX)
add_definitions (/GS /sdl)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NXCompat /DynamicBase")
#add_definitions (/D UNICODE /D _UNICODE)
add_definitions (/D UNICODE /D _UNICODE /D_NO_ASYNCRTIMP /D_ASYNCRT_EXPORT /D_NO_PPLXIMP /DWIN32 /DMBCS /D_USRDLL /DCPPREST_EXCLUDE_COMPRESSION /D_WINSOCK_DEPRECATED_NO_WARNINGS)
add_compile_options ($<$<CONFIG:Release>:/O2>)
add_compile_options (/MT$<$<CONFIG:Debug>:d>)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif (UNIX)
# Download and unpack lms at configure time
configure_file(lms.cmake.in
lms-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lms-download )
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lms-download )
# Add MEIClient directly to our build. This adds
# the following targets: LmsMEIClient and LIBMETEE
add_subdirectory(${CMAKE_BINARY_DIR}/lms-src/MEIClient
${CMAKE_BINARY_DIR}/lms-build/MEIClient)
add_dependencies(LmsMEIClient libmetee)
if (UNIX)
# Find threads [unix it pthreads]
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
# Find Boost
find_package(Boost COMPONENTS system REQUIRED)
# Find OpenSSL
find_package(OpenSSL)
# Download and build CppRestSDK, If GIT_TAG is changed then need to delete cpprestsdk-prefix because UPDATE_COMMAND is set to ""
include(ExternalProject)
ExternalProject_Add(cpprestsdk
GIT_REPOSITORY https://github.com/Microsoft/cpprestsdk.git
GIT_TAG v2.10.14
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 -DBUILD_SAMPLES=OFF -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=<SOURCE_DIR>/../../install
TEST_COMMAND ""
UPDATE_COMMAND ""
)
ExternalProject_Get_Property(cpprestsdk SOURCE_DIR)
set(CPPRESTSDK_LIBARIES ${SOURCE_DIR}/../../install/lib/)
set(CPPRESTSDK_INCLUDE_DIR ${SOURCE_DIR}/../../install/include/)
add_library(cpprest INTERFACE)
target_link_libraries(cpprest INTERFACE ${CPPRESTSDK_LIBARIES}/libcpprest.a OpenSSL::SSL OpenSSL::Crypto ${Boost_LIBRARIES} Threads::Threads)
target_include_directories(cpprest INTERFACE ${CPPRESTSDK_INCLUDE_DIR})
else (UNIX)
# CppRestSDK
find_package(cpprestsdk CONFIG REQUIRED)
endif (UNIX)
# ccu-poc
add_executable (rpc
AMTHIClient/Include/GetControlModeCommand.h
AMTHIClient/Src/GetControlModeCommand.cpp
commands.h
commands.cpp
lms.h
lms.cpp
main.cpp
)
target_include_directories(rpc PUBLIC
"AMTHIClient/Include/"
)
if (UNIX)
add_dependencies(rpc cpprestsdk)
target_link_libraries (rpc PRIVATE
LmsMEIClient
cpprest
)
else (UNIX)
target_link_libraries (rpc PRIVATE
LmsMEIClient
iphlpapi
cpprestsdk::cpprest
cpprestsdk::cpprestsdk_zlib_internal
cpprestsdk::cpprestsdk_boost_internal
cpprestsdk::cpprestsdk_brotli_internal
${Boost_LIBRARIES}
)
endif (UNIX)