This repository has been archived by the owner on Apr 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
101 lines (82 loc) · 3.41 KB
/
CMakeLists.txt
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
cmake_minimum_required (VERSION 3.16)
project (boost_log_trouble VERSION 0.1.0 LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 20)
set(Boost_USE_STATIC_LIBS ON) # only find static libs
set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)
set(BOOST_LOG_PROJECT_DEPENDENCIES
boost-thread
boost-uuid
boost-proto
boost-log
boost-filesystem
boost-chrono
boost-program-options
protobuf
grpc
cryptopp
azure-storage-cpp)
# add_definitions(-DBOOST_LOG_DYN_LINK)
if(NOT DEFINED ${CMAKE_TOOLCHAIN_FILE})
if(NOT DEFINED ENV{VCPKG_ROOT})
if(WIN32)
set (VCPKG_ROOT $ENV{HOMEDRIVE}$ENV{HOMEPATH}/vcpkg_cpptruths)
set (Boost_INCLUDE_DIR ${VCPKG_ROOT}/installed/x64-windows-static/include)
else()
set (VCPKG_ROOT $ENV{HOME}/.vcpkg_cpptruths)
set (Boost_INCLUDE_DIR ${VCPKG_ROOT}/installed/x64-linux/include)
set (BOOST_ROOT {VCPKG_ROOT}/installed/x64-linux/include CACHE PATH "Boost library path" )
endif()
set (Boost_NO_SYSTEM_PATHS on CACHE BOOL "Do not search system for Boost" )
else()
set (VCPKG_ROOT $ENV{VCPKG_ROOT})
endif()
if(NOT EXISTS ${VCPKG_ROOT})
message("Cloning vcpkg in ${VCPKG_ROOT}")
execute_process (COMMAND git clone https://github.com/Microsoft/vcpkg.git ${VCPKG_ROOT})
else()
execute_process (COMMAND git -C ${VCPKG_ROOT} pull)
endif()
if(NOT EXISTS ${VCPKG_ROOT}/README.md)
message (FATAL_ERROR "***** FATAL ERROR: Could not clone vcpkg *****")
endif()
if(WIN32)
set (VCPKG_EXEC ${VCPKG_ROOT}/vcpkg.exe)
set (VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.bat)
else()
set (VCPKG_EXEC ${VCPKG_ROOT}/vcpkg)
set (VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.sh)
endif()
if(NOT EXISTS ${VCPKG_EXEC})
message ("Bootstrapping vcpkg in ${VCPKG_ROOT}")
execute_process (COMMAND ${VCPKG_BOOTSTRAP} WORKING_DIRECTORY ${VCPKG_ROOT})
endif()
if(NOT EXISTS ${VCPKG_EXEC})
message (FATAL_ERROR "***** FATAL ERROR: Could not bootstrap vcpkg *****")
endif()
set (CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake CACHE STRING "")
message (STATUS "***** Checking project third party dependencies in ${VCPKG_ROOT} *****")
execute_process (COMMAND ${VCPKG_EXEC} install ${BOOST_LOG_PROJECT_DEPENDENCIES} WORKING_DIRECTORY ${VCPKG_ROOT})
endif()
find_package (Boost 1.75.0 REQUIRED COMPONENTS thread log filesystem chrono)
include_directories (${Boost_INCLUDE_DIRS})
include_directories (${CMAKE_CURRENT_SOURCE_DIR} )
message ("boost lib: ${Boost_LIBRARIES}, inc:${Boost_INCLUDE_DIRS}")
## Install the executable to <install_directory>/bin
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
## Install libraries (if any) to <install_directory>/bin
set (LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
## Source file containing the "main" function
set (MAIN_SOURCES main.cpp)
## Specify a name for the generated executable file
set (MAIN_EXE_NAME boost_log_trouble)
add_subdirectory ("Logging")
## 1. Compile...
add_executable (boost_log_trouble main.cpp)
target_include_directories (boost_log_trouble PUBLIC ${Boost_INCLUDE_DIRS})
## 2. Link...
target_link_libraries (boost_log_trouble ${Boost_LIBRARIES} logging)
## 3. Install...
# install( TARGETS ${MAIN_EXE_NAME} RUNTIME DESTINATION bin )