|
| 1 | +cmake_minimum_required (VERSION 3.1.0 FATAL_ERROR) |
| 2 | +project (TriLOc |
| 3 | + VERSION 1.0.0 |
| 4 | + LANGUAGES C CXX) |
| 5 | + |
| 6 | +############## |
| 7 | +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| 8 | + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.6.3") |
| 9 | + message(FATAL_ERROR "Insufficient gcc version, should be at least 4.6.3") |
| 10 | + endif() |
| 11 | +endif() |
| 12 | + |
| 13 | +############# |
| 14 | +enable_testing() |
| 15 | +include_directories (${CMAKE_CURRENT_SOURCE_DIR}) |
| 16 | +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/TinyGarbled) |
| 17 | +include_directories(${PROJECT_BINARY_DIR}) |
| 18 | +include_directories(${PROJECT_BINARY_DIR}/TinyGarbled) |
| 19 | + |
| 20 | +############## |
| 21 | +# build type |
| 22 | +if(NOT CMAKE_BUILD_TYPE) |
| 23 | + set(CMAKE_BUILD_TYPE Debug) |
| 24 | +endif() |
| 25 | + |
| 26 | +if (CMAKE_BUILD_TYPE MATCHES Debug) |
| 27 | + message("Debug build.") |
| 28 | +elseif (CMAKE_BUILD_TYPE MATCHES Release) |
| 29 | + message("Release build.") |
| 30 | +else() |
| 31 | + message("Some other build type.") |
| 32 | +endif () |
| 33 | + |
| 34 | +############### |
| 35 | +# Compiler flags |
| 36 | +set(CMAKE_CXX_FLAGS |
| 37 | + "${CMAKE_CXX_FLAGS} -Wall -Wno-strict-aliasing -march=native") |
| 38 | + |
| 39 | +set (CMAKE_CXX_STANDARD 11) |
| 40 | +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -DDEBUG") |
| 41 | +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG") |
| 42 | + |
| 43 | +############### |
| 44 | +# Library |
| 45 | + |
| 46 | +## Thread |
| 47 | +find_package (Threads) |
| 48 | +## Boost |
| 49 | +set (Boost_USE_STATIC_LIBS OFF) |
| 50 | +set (Boost_USE_MULTITHREADED ON) |
| 51 | +set (Boost_USE_STATIC_RUNTIME OFF) |
| 52 | +find_package (Boost 1.45.0 |
| 53 | + REQUIRED |
| 54 | + COMPONENTS program_options) |
| 55 | + |
| 56 | +if (Boost_FOUND) |
| 57 | + include_directories (${Boost_INCLUDE_DIRS}) |
| 58 | +endif (Boost_FOUND) |
| 59 | + |
| 60 | +## OpenSSL |
| 61 | +find_package (OpenSSL) |
| 62 | + |
| 63 | +if (OPENSSL_FOUND) |
| 64 | + include_directories (${OPENSSL_INCLUDE_DIR}) |
| 65 | +endif (OPENSSL_FOUND) |
| 66 | + |
| 67 | +############### |
| 68 | +# Options |
| 69 | +option (ENABLE_DUMP "Enable dump hex feature" OFF) |
| 70 | +option (ENABLE_LOG "Enable log feature" OFF) |
| 71 | +if (CMAKE_BUILD_TYPE MATCHES Debug) |
| 72 | + message("Turn Log on.") |
| 73 | + SET(ENABLE_LOG ON BOOL "Turn on logs in debug mode.") |
| 74 | +endif (CMAKE_BUILD_TYPE MATCHES Debug) |
| 75 | + |
| 76 | +############### |
| 77 | +# Subdirectory |
| 78 | +add_subdirectory ("TinyGarbled") |
| 79 | +add_subdirectory ("CPP_src") |
0 commit comments