summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 323747afa82847eb5df4eb67cadb3fd76f4e1296 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)

cmake_policy(SET CMP0054 OLD)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

message("${CMAKE_MODULE_PATH}")

#set(HUNTER_ROOT /home/ed/hunter)
SET(HUNTER_STATUS_DEBUG ON)
include("cmake/HunterGate.cmake")

HunterGate(
    URL "https://github.com/ruslo/hunter/archive/v0.16.31.tar.gz"
    SHA1 "8fcc0a2d6206e1f2c6fc011e3e694e388d030b53"
)

option(BUILD_FOR_EMBEDDED "Build for device target" ON)

project(bmc-webserver CXX C)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
    message( FATAL_ERROR "In-source builds not allowed. Please make a new directory (usually called build) and run CMake from there. You may need to remove CMakeCache.txt." )
endif()

# general
option(BUILD_SHARED_LIBS "Build Pion as shared library" OFF)
option(BUILD_UT "Enable Unit test" OFF)

# Boost
add_definitions(-DBOOST_ALL_NO_LIB)
set(Boost_USE_STATIC_LIBS ON)
hunter_add_package(Boost COMPONENTS system thread regex)
find_package(Boost COMPONENTS system thread regex REQUIRED)

#Openssl
#hunter_add_package(OpenSSL)
find_package(OpenSSL REQUIRED)
if (NOT OPENSSL_FOUND)
    message(FATAL_ERROR "Could not find OpenSSL")
endif()
include_directories(${OPENSSL_INCLUDE_DIR})

# Crow
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/crow/include)

#g3 logging
option(ADD_FATAL_EXAMPLE "Disable g3 examples" OFF)
add_subdirectory(g3log)
include_directories(g3log/src)

# Debug sanitizers
find_package(Sanitizers)


set(SRC_FILES
    src/example.cpp
    include/crow_g3_logger.hpp
    include/ssl_key_handler.hpp
    include/color_cout_g3_sink.hpp
)

# Executable

add_executable(bmcweb ${SRC_FILES})
#target_link_libraries(example crow)
target_link_libraries(bmcweb Boost::boost Boost::system)
target_link_libraries(bmcweb ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(bmcweb OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(bmcweb g3logger)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

# this needs to be at the end to make sure all includes are handled correctly
get_property(C_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
execute_process(COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/prime_vscode_compile_db.py ${C_INCLUDE_DIRS})