Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR) |
| 2 | |
| 3 | cmake_policy(SET CMP0054 OLD) |
| 4 | |
| 5 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 6 | |
| 7 | message("${CMAKE_MODULE_PATH}") |
| 8 | |
| 9 | #set(HUNTER_ROOT /home/ed/hunter) |
| 10 | SET(HUNTER_STATUS_DEBUG ON) |
| 11 | include("cmake/HunterGate.cmake") |
| 12 | |
| 13 | HunterGate( |
| 14 | URL "https://github.com/ruslo/hunter/archive/v0.16.31.tar.gz" |
| 15 | SHA1 "8fcc0a2d6206e1f2c6fc011e3e694e388d030b53" |
| 16 | ) |
| 17 | |
| 18 | option(BUILD_FOR_EMBEDDED "Build for device target" ON) |
| 19 | |
| 20 | project(bmc-webserver CXX C) |
| 21 | |
| 22 | set(CMAKE_CXX_STANDARD 14) |
| 23 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 24 | |
| 25 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 26 | |
| 27 | if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} ) |
| 28 | 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." ) |
| 29 | endif() |
| 30 | |
| 31 | # general |
| 32 | option(BUILD_SHARED_LIBS "Build Pion as shared library" OFF) |
| 33 | option(BUILD_UT "Enable Unit test" OFF) |
| 34 | |
| 35 | # Boost |
| 36 | add_definitions(-DBOOST_ALL_NO_LIB) |
| 37 | set(Boost_USE_STATIC_LIBS ON) |
| 38 | hunter_add_package(Boost COMPONENTS system thread regex) |
| 39 | find_package(Boost COMPONENTS system thread regex REQUIRED) |
| 40 | |
| 41 | #Openssl |
Ed Tanous | 5f34a9c | 2017-02-28 12:35:13 -0800 | [diff] [blame^] | 42 | #hunter_add_package(OpenSSL) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 43 | find_package(OpenSSL REQUIRED) |
| 44 | if (NOT OPENSSL_FOUND) |
| 45 | message(FATAL_ERROR "Could not find OpenSSL") |
| 46 | endif() |
| 47 | include_directories(${OPENSSL_INCLUDE_DIR}) |
| 48 | |
| 49 | # Crow |
| 50 | include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/crow/include) |
| 51 | |
| 52 | #g3 logging |
Ed Tanous | 5f34a9c | 2017-02-28 12:35:13 -0800 | [diff] [blame^] | 53 | option(ADD_FATAL_EXAMPLE "Disable g3 examples" OFF) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 54 | add_subdirectory(g3log) |
| 55 | include_directories(g3log/src) |
| 56 | |
| 57 | # Debug sanitizers |
| 58 | find_package(Sanitizers) |
| 59 | |
Ed Tanous | 5f34a9c | 2017-02-28 12:35:13 -0800 | [diff] [blame^] | 60 | |
| 61 | set(SRC_FILES |
| 62 | src/example.cpp |
| 63 | include/crow_g3_logger.hpp |
| 64 | include/ssl_key_handler.hpp |
| 65 | include/color_cout_g3_sink.hpp |
| 66 | ) |
| 67 | |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 68 | # Executable |
Ed Tanous | 5f34a9c | 2017-02-28 12:35:13 -0800 | [diff] [blame^] | 69 | |
| 70 | add_executable(bmcweb ${SRC_FILES}) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 71 | #target_link_libraries(example crow) |
Ed Tanous | 5f34a9c | 2017-02-28 12:35:13 -0800 | [diff] [blame^] | 72 | target_link_libraries(bmcweb Boost::boost Boost::system) |
| 73 | target_link_libraries(bmcweb ${CMAKE_THREAD_LIBS_INIT}) |
| 74 | target_link_libraries(bmcweb OpenSSL::SSL OpenSSL::Crypto) |
| 75 | target_link_libraries(bmcweb g3logger) |
| 76 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 77 | |
Ed Tanous | 5f34a9c | 2017-02-28 12:35:13 -0800 | [diff] [blame^] | 78 | # this needs to be at the end to make sure all includes are handled correctly |
| 79 | get_property(C_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) |
| 80 | execute_process(COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/prime_vscode_compile_db.py ${C_INCLUDE_DIRS}) |