-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
110 lines (89 loc) · 3.12 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
102
103
104
105
106
107
108
109
110
# CMake build support courtesy of Axel Gembe <axel@gembe.net>
cmake_minimum_required(VERSION 2.8)
project(QsLog)
# Add CMake modules
set(CMAKE_MODULE_PATH
"${QsLog_SOURCE_DIR}/cmake"
"${CMAKE_MODULE_PATH}"
)
include(QsLogConfigTargets)
# Add a _d to debug binaries
set(CMAKE_DEBUG_POSTFIX "_d")
# Qt5
find_package(Qt5Core REQUIRED)
set(CMAKE_AUTOMOC ON)
# As moc files are generated in the binary dir, tell to always look for includes there
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Specify build paths
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${QsLog_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QsLog_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QsLog_BINARY_DIR}/bin)
set(HEADER_FILES
QsLog.h
QsLogDest.h
QsLogDestConsole.h
QsLogDestFile.h
QsLogDestFunctor.h
QsLogDisableForThisFile.h
QsLogLevel.h
QsLogMessage.h
QsLogSharedLibrary.h
)
set(SOURCE_FILES
QsLog.cpp
QsLogDest.cpp
QsLogDestConsole.cpp
QsLogDestFile.cpp
QsLogDestFunctor.cpp
QsLogMessage.cpp
QsLogLevel.cpp
)
if(APPLE)
# Apple's compiler will not find standard includes like <thread> or <mutex> with 10.7 target otherwise
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
# Use 10.7 OSX SDK
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7")
option(QS_LOG_LINE_NUMBERS "Automatically writes the file and line for each log message" OFF)
if(QS_LOG_LINE_NUMBERS)
add_definitions(-DQS_LOG_LINE_NUMBERS)
endif()
option(QS_LOG_DISABLE "Logging code is replaced with a no-op" OFF)
if(QS_LOG_DISABLE)
add_definitions(-DQS_LOG_DISABLE)
endif()
option(QS_LOG_SEPARATE_THREAD "Messages are queued and written from a separate thread" OFF)
if(QS_LOG_SEPARATE_THREAD)
add_definitions(-DQS_LOG_SEPARATE_THREAD)
endif()
option(QS_LOG_WIN_PRINTF_CONSOLE "Use fprintf instead of OutputDebugString on Windows" OFF)
if(QS_LOG_WIN_PRINTF_CONSOLE)
add_definitions(-DQS_LOG_WIN_PRINTF_CONSOLE)
endif()
option(QS_LOG_IS_SHARED_LIBRARY "Build shared library" ON)
if(QS_LOG_IS_SHARED_LIBRARY)
set(QS_LOG_LIBRARY_TYPE SHARED)
add_definitions(-DQSLOG_IS_SHARED_LIBRARY)
else(QS_LOG_IS_SHARED_LIBRARY)
set(QS_LOG_LIBRARY_TYPE STATIC)
endif(QS_LOG_IS_SHARED_LIBRARY)
option(QS_LOG_BUILD_WINDOW "Build log window, depends on Qt5::Widgets" OFF)
if(QS_LOG_BUILD_WINDOW)
find_package(Qt5Widgets REQUIRED)
list(APPEND ADDITIONAL_LIBRARIES Qt5::Widgets)
list(APPEND HEADER_FILES QsLogWindowModel.h QsLogWindow.h)
list(APPEND SOURCE_FILES QsLogWindowModel.cpp QsLogWindow.cpp)
list(APPEND UI_FILES QsLogWindow.ui)
list(APPEND RES_FILES QsLogWindow.qrc)
qt5_wrap_ui(UI_SOURCE_FILES ${UI_FILES})
qt5_add_resources(RES_SOURCE_FILES ${RES_FILES})
add_definitions(-DQS_LOG_WINDOW)
endif()
add_library(QsLog ${QS_LOG_LIBRARY_TYPE} ${HEADER_FILES} ${SOURCE_FILES} ${UI_SOURCE_FILES} ${RES_SOURCE_FILES})
target_link_libraries(QsLog Qt5::Core ${ADDITIONAL_LIBRARIES})
install(FILES ${HEADER_FILES} DESTINATION include/QsLog)
QsLog_install_target(QsLog "")
option(QS_LOG_BUILD_TESTS "Build unit tests" OFF)
if(QS_LOG_BUILD_TESTS)
add_subdirectory(unittest)
endif()